fix: product page
This commit is contained in:
		| @@ -1,4 +1,4 @@ | |||||||
| import React, {useContext, useEffect, useState} from "react"; | import React, {useContext, useEffect} from "react"; | ||||||
| import {useStore} from "../../utils/useStore"; | import {useStore} from "../../utils/useStore"; | ||||||
| import {Button, Card, Col, Input, message, Modal, Row, Select} from "antd"; | import {Button, Card, Col, Input, message, Modal, Row, Select} from "antd"; | ||||||
| import {observer} from "mobx-react-lite"; | import {observer} from "mobx-react-lite"; | ||||||
| @@ -10,8 +10,6 @@ const {Option} = Select; | |||||||
|  |  | ||||||
| export const Product = observer(() => { | export const Product = observer(() => { | ||||||
|   const store = useStore(); |   const store = useStore(); | ||||||
|  |  | ||||||
|   const [productData, setProductData] = useState([]); |  | ||||||
|   const modalLoader = useContext(ModalLoaderContext); |   const modalLoader = useContext(ModalLoaderContext); | ||||||
|  |  | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
| @@ -36,20 +34,6 @@ export const Product = observer(() => { | |||||||
|     init(); |     init(); | ||||||
|   }, []); |   }, []); | ||||||
|  |  | ||||||
|   // data |  | ||||||
|   useEffect(() => { |  | ||||||
|     console.log("⚡ transaction data store", store.transaction.data); |  | ||||||
|     setProductData(store.transaction.data); |  | ||||||
|   }, [store.transaction.data]); |  | ||||||
|  |  | ||||||
|   // Subcategory |  | ||||||
|   useEffect(() => { |  | ||||||
|     console.log( |  | ||||||
|       "⚡ transaction subcategory store", |  | ||||||
|       store.transaction.dataSubCategories |  | ||||||
|     ); |  | ||||||
|   }, [store.transaction.dataSubCategories]); |  | ||||||
|  |  | ||||||
|   const handleChangeSubcategory = async (item) => { |   const handleChangeSubcategory = async (item) => { | ||||||
|     store.transaction.filterSubCategory = item; |     store.transaction.filterSubCategory = item; | ||||||
|     modalLoader.setLoading(true); |     modalLoader.setLoading(true); | ||||||
| @@ -116,9 +100,9 @@ export const Product = observer(() => { | |||||||
|           /> |           /> | ||||||
|         </Col> |         </Col> | ||||||
|       </Row> |       </Row> | ||||||
|       {productData.length != 0 && ( |       {store.transaction.data.length != 0 && ( | ||||||
|           <Row> |           <Row> | ||||||
|           {productData.map((item, index) => ( |             {store.transaction.data.map((item, index) => ( | ||||||
|                 <Col key={index} xs={24} md={16} lg={8}> |                 <Col key={index} xs={24} md={16} lg={8}> | ||||||
|                   <Card |                   <Card | ||||||
|                       onClick={() => { |                       onClick={() => { | ||||||
| @@ -151,7 +135,7 @@ export const Product = observer(() => { | |||||||
|             ))} |             ))} | ||||||
|           </Row> |           </Row> | ||||||
|       )} |       )} | ||||||
|       {productData.length !== 0 && ( |       {store.transaction.data.length !== 0 && ( | ||||||
|           <Col style={{textAlign: "right", marginTop: "1em"}}> |           <Col style={{textAlign: "right", marginTop: "1em"}}> | ||||||
|             <Button style={{backgroundColor: "#2D9CDB", color: "white"}}> |             <Button style={{backgroundColor: "#2D9CDB", color: "white"}}> | ||||||
|               Beli Sekarang |               Beli Sekarang | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| import React, {useContext, useEffect, useState,message} from "react"; | import React, {message, useContext, useEffect} from "react"; | ||||||
| import {useStore} from "../../utils/useStore"; | import {useStore} from "../../utils/useStore"; | ||||||
| import {Card, Tabs} from "antd"; | import {Card, Tabs} from "antd"; | ||||||
| import {BreadcumbComponent} from "../../component/BreadcumbComponent"; | import {BreadcumbComponent} from "../../component/BreadcumbComponent"; | ||||||
| @@ -14,7 +14,6 @@ export const Transaction = observer(() => { | |||||||
|  |  | ||||||
|   const modalLoader = useContext(ModalLoaderContext); |   const modalLoader = useContext(ModalLoaderContext); | ||||||
|  |  | ||||||
|   // Init |  | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     const init = async () => { |     const init = async () => { | ||||||
|       try { |       try { | ||||||
| @@ -34,14 +33,11 @@ export const Transaction = observer(() => { | |||||||
|     init(); |     init(); | ||||||
|   }, []); |   }, []); | ||||||
|  |  | ||||||
|   // Category |  | ||||||
|   useEffect(() => { |  | ||||||
|     console.log('⚡ transaction category store', store.transaction.dataCategories) |  | ||||||
|   }, [store.transaction.dataCategories]) |  | ||||||
|  |  | ||||||
|   const handleChangeTabs = async (key) => { |   const handleChangeTabs = async (key) => { | ||||||
|     store.transaction.filterCategory = key; |     store.transaction.dataSubCategories = []; | ||||||
|  |     store.transaction.data = []; | ||||||
|     modalLoader.setLoading(true); |     modalLoader.setLoading(true); | ||||||
|  |     store.transaction.filterCategory = key; | ||||||
|     await store.transaction.getDataSubCategories(); |     await store.transaction.getDataSubCategories(); | ||||||
|     modalLoader.setLoading(false); |     modalLoader.setLoading(false); | ||||||
|   }; |   }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user