diff --git a/src/component/PartnerComponent.js b/src/component/PartnerComponent.js index f80a61b..51db6dc 100644 --- a/src/component/PartnerComponent.js +++ b/src/component/PartnerComponent.js @@ -114,7 +114,10 @@ export const PartnerComponent = observer((props) => { key: "action", render: (text, record) => ( - @@ -166,10 +169,18 @@ export const PartnerComponent = observer((props) => { setConfirmLoading(true); try { await store.partner.update(idData, data); - message.success(isChangePassword ? "Failed Change Partner Password" : "Success Update Data Partner"); + message.success( + isChangePassword + ? "Failed Change Partner Password" + : "Success Update Data Partner" + ); //await store.partner.getData() } catch (e) { - message.error(isChangePassword ? "Failed Change Partner Password" : "Failed Update Data Partner"); + message.error( + isChangePassword + ? "Failed Change Partner Password" + : "Failed Update Data Partner" + ); } setConfirmLoading(false); store.partner.visibleModalPartner = false; diff --git a/src/pages/App/DesktopLayout.js b/src/pages/App/DesktopLayout.js index 1b47af9..4316984 100644 --- a/src/pages/App/DesktopLayout.js +++ b/src/pages/App/DesktopLayout.js @@ -10,6 +10,8 @@ import { DatabaseOutlined, FileAddOutlined, FileSyncOutlined, + FileProtectOutlined, + ShoppingCartOutlined, } from "@ant-design/icons"; import { AppRoute, LINKS } from "../../routes/app"; import { useStore } from "../../utils/useStore"; @@ -122,12 +124,12 @@ export const DesktopLayout = observer(() => { {store.authentication.userData.role !== "Retail" && ( - + Membership )} - {store.authentication.userData.role !== "Retail" && ( + {store.authentication.userData.role === "Admin" && ( } @@ -154,10 +156,10 @@ export const DesktopLayout = observer(() => { )} - {store.authentication.userData.role !== "Retail" && ( + {store.authentication.userData.role === "Admin" && ( } + icon={} title="Product" > @@ -180,28 +182,28 @@ export const DesktopLayout = observer(() => { )} - {store.authentication.userData.role !== "Retail" && ( + {store.authentication.userData.role !== "Admin" && ( - + Product )} + {store.authentication.userData.role === "Retail" && ( + + + + Transaction + + + )} - + Payback - {store.authentication.userData.role === "Retail" && ( - - - - Transaction - - - )} diff --git a/src/pages/App/MenuList.js b/src/pages/App/MenuList.js index afc5508..f7796cd 100644 --- a/src/pages/App/MenuList.js +++ b/src/pages/App/MenuList.js @@ -12,6 +12,7 @@ import { MoneyCollectOutlined, ProfileOutlined, ProjectOutlined, + ShoppingCartOutlined, UserOutlined, } from "@ant-design/icons"; import { observer } from "mobx-react-lite"; @@ -59,7 +60,7 @@ export const MenuList = observer((props) => { )} - {store.authentication.userData.role !== "Retail" && ( + {store.authentication.userData.role === "Admin" && ( } title="Config"> @@ -81,7 +82,7 @@ export const MenuList = observer((props) => { )} - {store.authentication.userData.role !== "Retail" && ( + {store.authentication.userData.role === "Admin" && ( } title="Product"> @@ -103,10 +104,18 @@ export const MenuList = observer((props) => { )} - {store.authentication.userData.role === ("Retail" || "Admin") && ( + {store.authentication.userData.role !== "Admin" && ( + + + + Product + + + )} + {store.authentication.userData.role === "Retail" && ( - + Transaction @@ -117,14 +126,6 @@ export const MenuList = observer((props) => { Payback - {store.authentication.userData.role === ("Retail" || "Admin") && ( - - - - Transaction - - - )} diff --git a/src/pages/Membership/Membership.js b/src/pages/Membership/Membership.js index abd6d91..3db8042 100644 --- a/src/pages/Membership/Membership.js +++ b/src/pages/Membership/Membership.js @@ -33,6 +33,8 @@ export const Membership = observer(() => { const [form] = Form.useForm(); const store = useStore(); const [visibleModal, setVisibleModal] = useState(false); + const [isVisibleTopUpModal, setIsVisibleTopUpModal] = useState(false); + const [destination, setDestination] = useState(null); const [initialData, setInitialData] = useState({}); const [confirmLoading, setConfirmLoading] = useState(false); const [isLoading, setIsLoading] = useState(false); @@ -43,6 +45,8 @@ export const Membership = observer(() => { setIsLoading(true); await getData(); store.role.getData(); + if (store.authentication.userData.role === "Admin") + await store.supplier.getData(); setIsLoading(false); } catch (e) { setIsLoading(false); @@ -53,10 +57,10 @@ export const Membership = observer(() => { }, []); const getData = () => { - (store.authentication.userData.role === "Admin") - ? store.membership.getData() - : store.membership.getDataBySuperior(); - } + store.authentication.userData.role === "Admin" + ? store.membership.getData() + : store.membership.getDataBySuperior(); + }; const changeStatus = async (id, isActive) => { const status = isActive ? "inactive" : "active"; @@ -76,13 +80,17 @@ export const Membership = observer(() => { } }; const handleCancelTransaction = () => { - store.supplier.visibleModalTransaction = false; + setIsVisibleTopUpModal(false); + setDestination(null); }; const handleSubmitTransaction = async (data) => { - console.log(data, "isi data2"); setConfirmLoading(true); try { - await store.supplier.createTransaction(data); + data.destination = destination; + + (await store.authentication.userData.role) === "Admin" + ? store.transaction.distributeAdmin(data) + : store.transaction.distribute(data); message.success("Success Top Up"); //await store.supplier.getData() } catch (e) { @@ -90,8 +98,9 @@ export const Membership = observer(() => { message.error("Failed Top Up"); } setConfirmLoading(false); - store.supplier.visibleModalTransaction = false; + setIsVisibleTopUpModal(false); form.resetFields(); + setDestination(null); }; const columns = [ @@ -128,9 +137,20 @@ export const Membership = observer(() => { key: "action", render: (text, record) => ( - + + */} { - - - {store.ui.mediaQuery.isDesktop && ( { { }} >
- - - + {store.authentication.userData.role === "Admin" && ( + + + + )} { - const store = useStore(); - const [visibleModal, setVisibleModal] = useState(false); - const [confirmLoading, setConfirmLoading] = useState(false); - const [initialData, setInitialData] = useState({}); + const store = useStore(); + const [visibleModal, setVisibleModal] = useState(false); + const [confirmLoading, setConfirmLoading] = useState(false); + const [initialData, setInitialData] = useState({}); - // useEffect(() => { - // // const init = async () => { - // // try { - // // setIsLoading(true); - // // await store.membership.getData(); - // // await store.role.getData(); - // // setIsLoading(false); - // // } catch (e) { - // // setIsLoading(false); - // // } - // // }; - // - // // init(); - // }, []); + // useEffect(() => { + // // const init = async () => { + // // try { + // // setIsLoading(true); + // // await store.membership.getData(); + // // await store.role.getData(); + // // setIsLoading(false); + // // } catch (e) { + // // setIsLoading(false); + // // } + // // }; + // + // // init(); + // }, []); - const dummyData = [ - { - key: '1', - id: 1, - name: "John Doe", - picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", - amount: "Rp. 1.000.000", - }, - { - key: '2', - id: 1, - name: "John Doe", - picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", - amount: "Rp. 1.000.000", - }, - { - key: '3', - id: 1, - name: "John Doe", - picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", - amount: "Rp. 1.000.000", - }, - { - key: '4', - id: 1, - name: "John Doe", - picture: "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", - amount: "Rp. 1.000.000", - }, - ] + const dummyData = [ + { + key: "1", + id: 1, + name: "John Doe", + picture: + "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", + amount: "Rp. 1.000.000", + }, + { + key: "2", + id: 1, + name: "John Doe", + picture: + "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", + amount: "Rp. 1.000.000", + }, + { + key: "3", + id: 1, + name: "John Doe", + picture: + "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", + amount: "Rp. 1.000.000", + }, + { + key: "4", + id: 1, + name: "John Doe", + picture: + "https://presidenproperti.com/wp-content/uploads/2018/11/blog-ph.jpg", + amount: "Rp. 1.000.000", + }, + ]; - const columns = [ - { - title: "Name", - dataIndex: "name", - key: "name", - }, - { - title: "Picture", - dataIndex: "picture", - key: "picture", - render: (text, record) => ( - - ), - }, - { - title: "Amount", - dataIndex: "amount", - key: "amount", - }, - { - title: "Action", - key: "action", - width: 100, - render: (text, record) => ( - - - - - ), - }, - ]; + const columns = [ + { + title: "Name", + dataIndex: "name", + key: "name", + }, + { + title: "Picture", + dataIndex: "picture", + key: "picture", + render: (text, record) => ( + + ), + }, + { + title: "Amount", + dataIndex: "amount", + key: "amount", + }, + { + title: "Action", + key: "action", + width: 100, + render: (text, record) => ( + + + + + ), + }, + ]; - const routeData = [ - { - route: LINKS.HOME, - name: "Home", - }, - { - route: LINKS.PAYBACK, - name: Payback, - }, - ]; + if(store.authentication.userData.role === "Retail") columns.pop(); - const onSubmit = async (data) => { - setConfirmLoading(true); - try { - // await store.membership.create(data); - // message.success("Success Add New Member"); - // await store.membership.getData(); - } catch (e) { - console.error(e, "apa errornya"); - message.error("Failed Add Member"); - } - setConfirmLoading(false); - setVisibleModal(false); - }; + const routeData = [ + { + route: LINKS.HOME, + name: "Home", + }, + { + route: LINKS.PAYBACK, + name: Payback, + }, + ]; - const handleAction = async (record, type) => { + const onSubmit = async (data) => { + setConfirmLoading(true); + try { + // await store.membership.create(data); + // message.success("Success Add New Member"); + // await store.membership.getData(); + } catch (e) { + console.error(e, "apa errornya"); + message.error("Failed Add Member"); + } + setConfirmLoading(false); + setVisibleModal(false); + }; - }; + const handleAction = async (record, type) => {}; - return ( -
- {/* -

Some contents...

-

Some contents...

-

Some contents...

-
*/} - - -
- -
- - - - - - - - {store.ui.mediaQuery.isDesktop && ( -
{ - // let pageNumber = page.current; - // store.membership.pageSize = page.pageSize; - // store.membership.page = pageNumber - 1; - // // store.membership.isLoading = true; - // await store.membership.getData(); - // // store.membership.isLoading = false; - // }} - /> - )} - - {store.ui.mediaQuery.isMobile && ( - { - // store.membership.pageSize = page.pageSize; - // store.membership.page = page.current; - // store.membership.getData(); - // }, - // pageSize: store.membership.pageSize, - // total: store.membership.total_data, - // current: store.membership.page, - // style: {marginBottom: "1rem", marginRight: "1rem"}, - // }} - dataSource={dummyData} - style={{padding: 0}} - renderItem={(item) => { - return ( -
- - - -
- } - /> -
-

- {item.amount} -

-
- - - - ); - }} - /> - )} - - - - { - await onSubmit(data); + return ( +
+ + +
+ +
+ + + + { + /> + {store.authentication.userData.role !== "Admin" && ( + + )} + + + {store.ui.mediaQuery.isDesktop && ( +
{ + // let pageNumber = page.current; + // store.membership.pageSize = page.pageSize; + // store.membership.page = pageNumber - 1; + // // store.membership.isLoading = true; + // await store.membership.getData(); + // // store.membership.isLoading = false; + // }} /> + )} + + {store.ui.mediaQuery.isMobile && ( + { + // store.membership.pageSize = page.pageSize; + // store.membership.page = page.current; + // store.membership.getData(); + // }, + // pageSize: store.membership.pageSize, + // total: store.membership.total_data, + // current: store.membership.page, + // style: {marginBottom: "1rem", marginRight: "1rem"}, + // }} + dataSource={dummyData} + style={{ padding: 0 }} + renderItem={(item) => { + return ( +
+ + + +
+ } + /> +
+

+ {item.amount} +

+
+ + + + ); + }} + /> + )} - ); + + + { + await onSubmit(data); + }} + onCancel={() => { + setInitialData({}); + setVisibleModal(false); + }} + /> + + ); }); diff --git a/src/pages/Profile/Profile.js b/src/pages/Profile/Profile.js index f4f366a..27ec245 100644 --- a/src/pages/Profile/Profile.js +++ b/src/pages/Profile/Profile.js @@ -50,13 +50,23 @@ export const Profile = observer(() => { }, ] + const styleSaldoTitle = store.ui.mediaQuery.isDesktop ? { + display: "flex", + justifyContent: "center" + } : {fontSize: "0.75rem"}; + const styleSaldoContent = store.ui.mediaQuery.isDesktop ? { + fontSize: '1.25rem', + display: "flex", + justifyContent: "center" + } : null; + return (
Profile -
+ Name @@ -90,11 +100,15 @@ export const Profile = observer(() => { - -
- Saldo - {store.authentication.profileData?.wallet} -
+ + + + Saldo + + + {store.authentication.profileData?.wallet} + + diff --git a/src/store/transaction.js b/src/store/transaction.js index 63b8c31..916dc21 100644 --- a/src/store/transaction.js +++ b/src/store/transaction.js @@ -76,6 +76,16 @@ export class Transaction { await this.getData(); return response; } + + async distribute(data) { + const response = await http.post('/transaction/distribute').send(data); + return response; + } + + async distributeAdmin(data) { + const response = await http.post('/transaction/distribute-admin').send(data); + return response; + } }