From 8a2bde5ba83b184c2c8c2f280ec0ccf37871158d Mon Sep 17 00:00:00 2001 From: "ajat91.sudrajat" Date: Mon, 27 Dec 2021 15:55:34 +0700 Subject: [PATCH] Perbaikan Project PPOB --- src/component/PartnerComponent.js | 37 +-- src/component/ProductComponent.js | 38 +-- src/component/SupplierComponent.js | 8 +- src/config/app.js | 4 +- src/pages/App/DesktopLayout.js | 363 ++++++++++++++------------- src/pages/App/MenuList.js | 136 +++++----- src/pages/Config/Commission.js | 2 +- src/pages/Config/Partner.js | 2 +- src/pages/Config/Supplier.js | 2 +- src/pages/Home/Home.js | 136 ++++++++-- src/pages/Membership/Membership.js | 2 +- src/pages/Payback/Payback.js | 32 ++- src/pages/Payback/PaybackCreated.js | 2 +- src/pages/Product/Category.js | 2 +- src/pages/Product/Product.js | 3 +- src/pages/Product/ProductDetail.js | 2 +- src/pages/Product/Subcategory.js | 2 +- src/pages/Profile/Profile.js | 4 +- src/pages/Transaction/Transaction.js | 2 +- src/store/partner.js | 13 +- src/store/product.js | 12 + 21 files changed, 482 insertions(+), 322 deletions(-) diff --git a/src/component/PartnerComponent.js b/src/component/PartnerComponent.js index 99bdbb4..d75496b 100644 --- a/src/component/PartnerComponent.js +++ b/src/component/PartnerComponent.js @@ -65,6 +65,7 @@ export const PartnerComponent = observer((props) => { setIsChangePassword(true); store.partner.visibleModalPartner = true; setIdData(data.id); + console.log(data.id); }; const columns = [ @@ -161,20 +162,22 @@ export const PartnerComponent = observer((props) => { if (idData !== "") { modalLoader.setLoading(true); try { - await store.partner.update(idData, data); + isChangePassword + ? await store.partner.updatePassword(idData, data) + : await store.partner.update(idData, data); modalLoader.setLoading(false); message.success( isChangePassword - ? "Failed Change Partner Password" + ? "Success Change Password" : "Success Update Data Partner" ); //await store.partner.getData() } catch (e) { - modalLoader.setLoading(true); + modalLoader.setLoading(false); message.error( isChangePassword - ? "Failed Change Partner Password" + ? "Failed Change Password" : "Failed Update Data Partner" ); } @@ -280,7 +283,9 @@ export const PartnerComponent = observer((props) => { > {item?.status === true ? "Inactive" : "Active"} - {/* */} @@ -358,17 +363,17 @@ export const PartnerComponent = observer((props) => { )} {!idData && ( - - - + + + )} {!idData && ( { const store = useStore(); const [form] = Form.useForm(); - const {Option} = Select; + const { Option } = Select; const history = useHistory(); const [idData, setIdData] = useState(""); const [filterSupplier, setFilterSupplier] = useState([]); @@ -107,12 +107,14 @@ export const ProductComponent = observer((props) => { key: "action", render: (text, record) => ( + onClick={async () => { + history.push( + LINKS.PRODUCT_DETAIL.replace(":id", record.product_id) + ); + }} + > + Detail + ), }, ]; @@ -258,7 +260,11 @@ export const ProductComponent = observer((props) => { width: store.ui.mediaQuery.isMobile ? 250 : "", }} columns={columns} - dataSource={store.product.data} + dataSource={ + store.authentication.userData.role === "Admin Partner" + ? store.product.dataProductPartner + : store.product.data + } bordered pagination={{ pageSize: store.product.pageSize, diff --git a/src/component/SupplierComponent.js b/src/component/SupplierComponent.js index b7f3d3e..b5542c1 100644 --- a/src/component/SupplierComponent.js +++ b/src/component/SupplierComponent.js @@ -192,14 +192,18 @@ export const SupplierComponent = observer((props) => { try { modalLoader.setLoading(true); const response = await store.supplier.create(data); - response?.body?.statusCode === 201 || response?.body?.statusCode === 200 + console.log(response) + response?.body?.statusCode === 201 && response?.body?.statusCode === 200 ? message.success( response?.body?.message || "Berhasil Tambah Supplier Baru" ) : message.error( - response?.body?.statusCode === 406 + response?.body?.error ? response?.body?.error || "Supplier Sudah Ada" : response?.body?.message || "Gagal Tambah Supplier Baru" + // response?.body?.statusCode === 406 + // ? response?.body?.error || "Supplier Sudah Ada" + // : response?.body?.message || "Gagal Tambah Supplier Baru" //response?.body?.message || "Gagal Tambah Supplier Baru" ); } catch (e) { diff --git a/src/config/app.js b/src/config/app.js index de2c9a2..b6c3d6a 100644 --- a/src/config/app.js +++ b/src/config/app.js @@ -1,6 +1,6 @@ export const appConfig = { - // apiUrl: 'https://ppob-backend.k3s.bangun-kreatif.com/v1' - apiUrl: 'http://localhost:3222/v1' + apiUrl: 'https://ppob-backend.k3s.bangun-kreatif.com/v1' + //apiUrl: 'http://localhost:3222/v1' // apiUrl: 'http://localhost:3222/v1' }; diff --git a/src/pages/App/DesktopLayout.js b/src/pages/App/DesktopLayout.js index 23c2b32..cc46bbf 100644 --- a/src/pages/App/DesktopLayout.js +++ b/src/pages/App/DesktopLayout.js @@ -1,65 +1,65 @@ -import React, {useState} from "react"; -import {Button, Drawer, Layout, Menu, Popover, Typography} from "antd"; -import {MenuList} from "./MenuList"; -import {Link, useHistory} from "react-router-dom"; +import React, { useState } from "react"; +import { Button, Drawer, Layout, Menu, Popover, Typography } from "antd"; +import { MenuList } from "./MenuList"; +import { Link, useHistory } from "react-router-dom"; import { - AlipayOutlined, - DatabaseOutlined, - FileAddOutlined, - FileProtectOutlined, - FileSyncOutlined, - HomeOutlined, - LogoutOutlined, - MenuOutlined, - PayCircleOutlined, - ProfileOutlined, - ShoppingCartOutlined, - UserOutlined + AlipayOutlined, + DatabaseOutlined, + FileAddOutlined, + FileProtectOutlined, + FileSyncOutlined, + HomeOutlined, + LogoutOutlined, + MenuOutlined, + PayCircleOutlined, + ProfileOutlined, + ShoppingCartOutlined, + UserOutlined, } from "@ant-design/icons"; -import {AppRoute, LINKS} from "../../routes/app"; -import {useStore} from "../../utils/useStore"; -import {observer} from "mobx-react-lite"; -import {useMediaQuery} from "react-responsive"; +import { AppRoute, LINKS } from "../../routes/app"; +import { useStore } from "../../utils/useStore"; +import { observer } from "mobx-react-lite"; +import { useMediaQuery } from "react-responsive"; -const {Text, Paragraph} = Typography; -const {Header, Content, Sider} = Layout; -const {SubMenu} = Menu; +const { Text, Paragraph } = Typography; +const { Header, Content, Sider } = Layout; +const { SubMenu } = Menu; export const DesktopLayout = observer(() => { - let history = useHistory(); - const xl = useMediaQuery({minWidth: 1024}); - const store = useStore(); - const [clicked, setClicked] = useState(false); + let history = useHistory(); + const xl = useMediaQuery({ minWidth: 1024 }); + const store = useStore(); + const [clicked, setClicked] = useState(false); - return ( - + {store.ui.mediaQuery.isDesktop && ( + - {store.ui.mediaQuery.isDesktop && ( -
{ }} > - - - + {store.authentication.userData.role !== "Admin Partner" && ( + + + Beranda - - - {store.authentication.userData.role !== "Retail" && ( - - - - Keanggotaan )} + {store.authentication.userData.role !== "Retail" || + (store.authentication.userData.role !== "Admin Partner" && ( + + + + Keanggotaan + + + ))} {store.authentication.userData.role === "Admin" && ( { > - - Rekanan + + Rekanan - - Komisi + + Komisi @@ -167,23 +170,23 @@ export const DesktopLayout = observer(() => { > - - Produk + + Produk {store.authentication.userData.role === "Admin" && ( - - Kategori + + Kategori )} {store.authentication.userData.role === "Admin" && ( - - Sub Kategori + + Sub Kategori )} @@ -192,46 +195,49 @@ export const DesktopLayout = observer(() => { {store.authentication.userData.role !== "Admin" && ( - - Produk + + Produk )} - {store.authentication.userData.role === "Retail" && ( - - - + {store.authentication.userData.role === "Retail" || + (store.authentication.userData.role === "Admin Partner" && ( + + + Transaksi - - - )} - } - title="Pembayaran" - > - {store.authentication.userData.role !== "Retail" && ( - - - - Konfirmasi - - - )} - {store.authentication.userData.role !== "Admin" && ( - - - - Dibuat oleh Saya - - )} - + + ))} + {store.authentication.userData.role !== "Admin Partner" && ( + } + title="Pembayaran" + > + {store.authentication.userData.role !== "Retail" && ( + + + + Konfirmasi + + + )} + {store.authentication.userData.role !== "Admin" && ( + + + + Dibuat oleh Saya + + + )} + + )} {store.authentication.userData.role !== "Admin" && ( - - Profil + + Profil )} @@ -354,45 +360,46 @@ export const DesktopLayout = observer(() => { autoAdjustOverflow={true} placement="bottomRight" content={ - + {store.authentication.userData.role !== "Admin" && ( + + + + Profile + + + )} + { + store.authentication.logout(); + history.push("/login"); + }} > - {store.authentication.userData.role !== "Admin" && - - - Profile - - - } - { - store.authentication.logout(); - history.push("/login"); - }} - > - - Sign out - - + + Sign out + + } title={ - - {store.user.data.username} - - {store.authentication.userData.username} - - + + {store.user.data.username} + + {store.authentication.userData.username} + + } trigger="click" visible={clicked} @@ -455,45 +462,45 @@ export const DesktopLayout = observer(() => { autoAdjustOverflow={true} placement="bottomRight" content={ - + {store.authentication.userData.role !== "Admin" && ( + + + + Profile + + + )} + { + store.authentication.logout(); + history.push("/login"); + }} > - {store.authentication.userData.role !== "Admin" && ( - - - - Profile - - - )} - { - store.authentication.logout(); - history.push("/login"); - }} - > - - Sign out - - + + Sign out + + } title={ - - {store.authentication.userData.username} - + + {store.authentication.userData.username} + } trigger="click" diff --git a/src/pages/App/MenuList.js b/src/pages/App/MenuList.js index db26d51..b0aac5b 100644 --- a/src/pages/App/MenuList.js +++ b/src/pages/App/MenuList.js @@ -1,34 +1,33 @@ -import React, {useEffect, useState} from "react"; -import {Menu} from "antd"; -import {Link} from "react-router-dom"; +import React, { useEffect, useState } from "react"; +import { Menu } from "antd"; +import { Link } from "react-router-dom"; import { - AppstoreOutlined, - DatabaseOutlined, - FileAddOutlined, - FileProtectOutlined, - FileSyncOutlined, - HomeOutlined, - MenuUnfoldOutlined, - MoneyCollectOutlined, - ProfileOutlined, - ProjectOutlined, - ShoppingCartOutlined, - UserOutlined, + AppstoreOutlined, + DatabaseOutlined, + FileAddOutlined, + FileProtectOutlined, + FileSyncOutlined, + HomeOutlined, + MenuUnfoldOutlined, + MoneyCollectOutlined, + ProfileOutlined, + ProjectOutlined, + ShoppingCartOutlined, + UserOutlined, } from "@ant-design/icons"; -import {observer} from "mobx-react-lite"; -import {useStore} from "../../utils/useStore"; -import {LINKS} from "../../routes/app"; +import { observer } from "mobx-react-lite"; +import { useStore } from "../../utils/useStore"; +import { LINKS } from "../../routes/app"; -const {SubMenu} = Menu; +const { SubMenu } = Menu; export const MenuList = observer((props) => { - const store = useStore(); - useEffect(() => { - }, []); + const store = useStore(); + useEffect(() => {}, []); - const [setKeys, setSetKeys] = useState(["dashboard"]); + const [setKeys, setSetKeys] = useState(["dashboard"]); - return ( + return ( { overflowedIndicator={0} forceSubMenuRender={true} > - - - - Beranda - - - {store.authentication.userData.role !== "Retail" && ( - - - - Keanggotaan + {store.authentication.userData.role === "Admin" && ( + + + + Beranda )} + {store.authentication.userData.role !== "Retail" && + store.authentication.userData.role !== "Admin Partner" && ( + + + + Keanggotaan + + + )} {store.authentication.userData.role === "Admin" && ( } title="Config"> @@ -109,6 +111,14 @@ export const MenuList = observer((props) => { )} )} + {store.authentication.userData.role === "Admin Partner" && ( + + + + Produk + + + )} {store.authentication.userData.role === "Supervisor" && ( @@ -117,37 +127,45 @@ export const MenuList = observer((props) => { )} - {store.authentication.userData.role === "Retail" && ( - - - - Transaksi - - - )} - } title="Pembayaran"> - {store.authentication.userData.role !== "Retail" && ( - - - - Konfirmasi + {store.authentication.userData.role === "Retail" || + (store.authentication.userData.role === "Admin Partner" && ( + + + + Transaksi - )} - {store.authentication.userData.role !== "Admin" && ( - - - + ))} + {store.authentication.userData.role !== "Retail" && + store.authentication.userData.role !== "Admin Partner" && ( + } + title="Pembayaran" + > + {store.authentication.userData.role !== "Retail" && ( + + + + Konfirmasi + + + )} + {store.authentication.userData.role !== "Admin" && ( + + + Dibuat oleh Saya - - + + + )} + )} - {store.authentication.userData.role !== "Admin" && ( - - Profil + + Profil )} diff --git a/src/pages/Config/Commission.js b/src/pages/Config/Commission.js index baa91c9..ea51153 100644 --- a/src/pages/Config/Commission.js +++ b/src/pages/Config/Commission.js @@ -38,7 +38,7 @@ export const Commission = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.COMMISSION, diff --git a/src/pages/Config/Partner.js b/src/pages/Config/Partner.js index c43e6b6..9e85a1d 100644 --- a/src/pages/Config/Partner.js +++ b/src/pages/Config/Partner.js @@ -36,7 +36,7 @@ export const Partner = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.PARTNER, diff --git a/src/pages/Config/Supplier.js b/src/pages/Config/Supplier.js index e009362..3cd403b 100644 --- a/src/pages/Config/Supplier.js +++ b/src/pages/Config/Supplier.js @@ -51,7 +51,7 @@ export const Supplier = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.SUPPLIER, diff --git a/src/pages/Home/Home.js b/src/pages/Home/Home.js index 5a96c09..c8f2718 100644 --- a/src/pages/Home/Home.js +++ b/src/pages/Home/Home.js @@ -1,25 +1,123 @@ import React from "react"; -import {Button, PageHeader} from "antd"; -import {store} from "../../utils/useStore"; -import {observer} from "mobx-react-lite"; +import { Button, PageHeader, Card, Row, Col, List } from "antd"; +import { store } from "../../utils/useStore"; +import { observer } from "mobx-react-lite"; +import { FilterOutlined, TransactionOutlined } from "@ant-design/icons"; export const Home = observer(() => { - return
- + {store.ui.mediaQuery.isDesktop && ( + - - - Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus aut recusandae velit! Consequatur corporis, - eum fuga, harum incidunt laboriosam minus necessitatibus neque non nostrum pariatur tempore. Dignissimos impedit - rem tempora! + + Total Transaksi}> + Total Transaksi : 25 Transaksi + + + + Total Keuntungan}> + Rp.30.000.000 + + + + Saldo}> + Rp.200.000.000 + + + + )} + {store.ui.mediaQuery.isMobile && ( +
+ + Total Transaksi}> + Total Transaksi : + + + + Total Keuntungan}> + Rp.30.000.000 + + + + Saldo}> + Rp.200.000.000 + + +
+ )}
+ ); + // return
+ // + // + // + // Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus aut recusandae velit! Consequatur corporis, + // eum fuga, harum incidunt laboriosam minus necessitatibus neque non nostrum pariatur tempore. Dignissimos impedit + // rem tempora! + //
}); diff --git a/src/pages/Membership/Membership.js b/src/pages/Membership/Membership.js index 2e3ea61..5c0ad17 100644 --- a/src/pages/Membership/Membership.js +++ b/src/pages/Membership/Membership.js @@ -174,7 +174,7 @@ export const Membership = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.MEMBERSHIP, diff --git a/src/pages/Payback/Payback.js b/src/pages/Payback/Payback.js index e7b716d..cffe75b 100644 --- a/src/pages/Payback/Payback.js +++ b/src/pages/Payback/Payback.js @@ -163,7 +163,7 @@ export const Payback = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.PAYBACK, @@ -175,15 +175,23 @@ export const Payback = observer(() => { modalLoader.setLoading(true); try { const response = await store.payback.confirmPayback(id, type); - if (response.body.status !== 201) { - message.error( - response?.body?.message || `Failed ${capitalize(type)} Payback` - ); - } else { - message.success( - response?.body?.message || `Success ${capitalize(type)} Payback` - ); - } + console.log(response) + response.body.statusCode !== 201 && response.body.statusCode !== 200 + ? message.error( + response?.body?.message || `Failed ${capitalize(type)} Payback` + ) + : message.success( + response?.body?.message || `Success ${capitalize(type)} Payback` + ); + // if (response.body.status !== 201 ) { + // message.error( + // response?.body?.message || `Failed ${capitalize(type)} Payback` + // ); + // } else { + // message.success( + // response?.body?.message || `Success ${capitalize(type)} Payback` + // ); + // } } catch (e) { console.error(e, "apa errornya"); message.error( @@ -200,10 +208,10 @@ export const Payback = observer(() => {
- + */} {/* { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.PAYBACK_CREATED, diff --git a/src/pages/Product/Category.js b/src/pages/Product/Category.js index c2dd230..ca64fd7 100644 --- a/src/pages/Product/Category.js +++ b/src/pages/Product/Category.js @@ -37,7 +37,7 @@ export const Category = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.CATEGORY, diff --git a/src/pages/Product/Product.js b/src/pages/Product/Product.js index 7cdd86e..d9bb8d5 100644 --- a/src/pages/Product/Product.js +++ b/src/pages/Product/Product.js @@ -30,6 +30,7 @@ export const Product = observer(() => { store.supplier.getData(), store.category.getData(), store.product.getDataSubCategories(), + store.product.getProductPartner() ]); await store.product.getData(); modalLoader.setLoading(false); @@ -53,7 +54,7 @@ export const Product = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.PRODUCT, diff --git a/src/pages/Product/ProductDetail.js b/src/pages/Product/ProductDetail.js index e30aa91..0d6e884 100644 --- a/src/pages/Product/ProductDetail.js +++ b/src/pages/Product/ProductDetail.js @@ -18,7 +18,7 @@ export const ProductDetail = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.PRODUCT, diff --git a/src/pages/Product/Subcategory.js b/src/pages/Product/Subcategory.js index 08e26cb..0594a68 100644 --- a/src/pages/Product/Subcategory.js +++ b/src/pages/Product/Subcategory.js @@ -41,7 +41,7 @@ export const Subcategory = observer(() => { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.SUBCATEGORY, diff --git a/src/pages/Profile/Profile.js b/src/pages/Profile/Profile.js index c346341..7bbab08 100644 --- a/src/pages/Profile/Profile.js +++ b/src/pages/Profile/Profile.js @@ -138,12 +138,12 @@ export const Profile = observer(() => {
History User Transaction - + */} { const routeData = [ { route: LINKS.HOME, - name: "Home", + name: "Beranda", }, { route: LINKS.TRANSACTION, diff --git a/src/store/partner.js b/src/store/partner.js index f804b6e..95ddcda 100644 --- a/src/store/partner.js +++ b/src/store/partner.js @@ -27,7 +27,7 @@ export class Partner { async getData() { try { const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`); - + //console.log(response) this.data = response.body.data.map((item, idx) => { item.key = idx; return item @@ -59,11 +59,12 @@ export class Partner { } } - // async updateStatus(id, data) { - // const response = await http.put(`/users/partner/${id}`).send(data); - // await this.getData(); - // return response; - // } + async updatePassword(id, data) { + const response = await http.put(`/users/change-password-partner/${id}`).send(data); + console.log(response) + await this.getData(); + return response; + } async delete(id) { try { diff --git a/src/store/product.js b/src/store/product.js index 5697d10..b7d6e7c 100644 --- a/src/store/product.js +++ b/src/store/product.js @@ -26,9 +26,11 @@ export class Product { dataPriceHistory = []; totalDataPriceHistory = 0; pagePriceHistory = 0; + pageProductPartner = 0; pageSizePriceHistory = 10 dataDetailProduct = {}; + dataProductPartner=[] constructor(ctx) { this.ctx = ctx; @@ -94,6 +96,16 @@ export class Product { } } + async getProductPartner(id) { + try { + const response = await http.get(`/product/by-categories?page=${this.pageProductPartner}&sub-category=${id}`); + console.log(response) + this.dataProductPartner = response.body.data + } catch (e) { + console.error(e); + } + } + async create(data) { try { const response = await http.post('/product').send(data);