Perbaikan Project PPOB

This commit is contained in:
ajat91.sudrajat 2021-12-27 15:55:34 +07:00
parent 668c64f193
commit 8a2bde5ba8
21 changed files with 482 additions and 322 deletions

View File

@ -65,6 +65,7 @@ export const PartnerComponent = observer((props) => {
setIsChangePassword(true); setIsChangePassword(true);
store.partner.visibleModalPartner = true; store.partner.visibleModalPartner = true;
setIdData(data.id); setIdData(data.id);
console.log(data.id);
}; };
const columns = [ const columns = [
@ -161,20 +162,22 @@ export const PartnerComponent = observer((props) => {
if (idData !== "") { if (idData !== "") {
modalLoader.setLoading(true); modalLoader.setLoading(true);
try { try {
await store.partner.update(idData, data); isChangePassword
? await store.partner.updatePassword(idData, data)
: await store.partner.update(idData, data);
modalLoader.setLoading(false); modalLoader.setLoading(false);
message.success( message.success(
isChangePassword isChangePassword
? "Failed Change Partner Password" ? "Success Change Password"
: "Success Update Data Partner" : "Success Update Data Partner"
); );
//await store.partner.getData() //await store.partner.getData()
} catch (e) { } catch (e) {
modalLoader.setLoading(true); modalLoader.setLoading(false);
message.error( message.error(
isChangePassword isChangePassword
? "Failed Change Partner Password" ? "Failed Change Password"
: "Failed Update Data Partner" : "Failed Update Data Partner"
); );
} }
@ -280,7 +283,9 @@ export const PartnerComponent = observer((props) => {
> >
{item?.status === true ? "Inactive" : "Active"} {item?.status === true ? "Inactive" : "Active"}
</Button> </Button>
<Button onClick={(owner,name) => handleEditButton(item)}> <Button
onClick={(owner, name) => handleEditButton(item)}
>
Edit Edit
</Button> </Button>
{/* <Button onClick={() => handleDelete(record.id)}>Delete</Button> */} {/* <Button onClick={() => handleDelete(record.id)}>Delete</Button> */}

View File

@ -108,7 +108,9 @@ export const ProductComponent = observer((props) => {
render: (text, record) => ( render: (text, record) => (
<Button <Button
onClick={async () => { onClick={async () => {
history.push(LINKS.PRODUCT_DETAIL.replace(":id", record.product_id)); history.push(
LINKS.PRODUCT_DETAIL.replace(":id", record.product_id)
);
}} }}
> >
Detail Detail
@ -258,7 +260,11 @@ export const ProductComponent = observer((props) => {
width: store.ui.mediaQuery.isMobile ? 250 : "", width: store.ui.mediaQuery.isMobile ? 250 : "",
}} }}
columns={columns} columns={columns}
dataSource={store.product.data} dataSource={
store.authentication.userData.role === "Admin Partner"
? store.product.dataProductPartner
: store.product.data
}
bordered bordered
pagination={{ pagination={{
pageSize: store.product.pageSize, pageSize: store.product.pageSize,

View File

@ -192,14 +192,18 @@ export const SupplierComponent = observer((props) => {
try { try {
modalLoader.setLoading(true); modalLoader.setLoading(true);
const response = await store.supplier.create(data); 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( ? message.success(
response?.body?.message || "Berhasil Tambah Supplier Baru" response?.body?.message || "Berhasil Tambah Supplier Baru"
) )
: message.error( : message.error(
response?.body?.statusCode === 406 response?.body?.error
? response?.body?.error || "Supplier Sudah Ada" ? response?.body?.error || "Supplier Sudah Ada"
: response?.body?.message || "Gagal Tambah Supplier Baru" : 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" //response?.body?.message || "Gagal Tambah Supplier Baru"
); );
} catch (e) { } catch (e) {

View File

@ -1,6 +1,6 @@
export const appConfig = { export const appConfig = {
// apiUrl: 'https://ppob-backend.k3s.bangun-kreatif.com/v1' apiUrl: 'https://ppob-backend.k3s.bangun-kreatif.com/v1'
apiUrl: 'http://localhost:3222/v1' //apiUrl: 'http://localhost:3222/v1'
// apiUrl: 'http://localhost:3222/v1' // apiUrl: 'http://localhost:3222/v1'
}; };

View File

@ -14,7 +14,7 @@ import {
PayCircleOutlined, PayCircleOutlined,
ProfileOutlined, ProfileOutlined,
ShoppingCartOutlined, ShoppingCartOutlined,
UserOutlined UserOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { AppRoute, LINKS } from "../../routes/app"; import { AppRoute, LINKS } from "../../routes/app";
import { useStore } from "../../utils/useStore"; import { useStore } from "../../utils/useStore";
@ -118,20 +118,23 @@ export const DesktopLayout = observer(() => {
}} }}
> >
<Menu> <Menu>
{store.authentication.userData.role !== "Admin Partner" && (
<Menu.Item key="home"> <Menu.Item key="home">
<Link to={LINKS.HOME}> <Link to={LINKS.HOME}>
<HomeOutlined /> <HomeOutlined />
<span>Beranda</span> <span>Beranda</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
{store.authentication.userData.role !== "Retail" && ( )}
{store.authentication.userData.role !== "Retail" ||
(store.authentication.userData.role !== "Admin Partner" && (
<Menu.Item key="membership"> <Menu.Item key="membership">
<Link to={LINKS.MEMBERSHIP}> <Link to={LINKS.MEMBERSHIP}>
<FileProtectOutlined /> <FileProtectOutlined />
<span>Keanggotaan</span> <span>Keanggotaan</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} ))}
{store.authentication.userData.role === "Admin" && ( {store.authentication.userData.role === "Admin" && (
<SubMenu <SubMenu
key="config" key="config"
@ -197,14 +200,16 @@ export const DesktopLayout = observer(() => {
</Link> </Link>
</Menu.Item> </Menu.Item>
)} )}
{store.authentication.userData.role === "Retail" && ( {store.authentication.userData.role === "Retail" ||
(store.authentication.userData.role === "Admin Partner" && (
<Menu.Item key="transaction"> <Menu.Item key="transaction">
<Link to={LINKS.TRANSACTION}> <Link to={LINKS.TRANSACTION}>
<ShoppingCartOutlined /> <ShoppingCartOutlined />
<span>Transaksi</span> <span>Transaksi</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} ))}
{store.authentication.userData.role !== "Admin Partner" && (
<SubMenu <SubMenu
key="payback-main" key="payback-main"
icon={<ProfileOutlined />} icon={<ProfileOutlined />}
@ -227,6 +232,7 @@ export const DesktopLayout = observer(() => {
</Menu.Item> </Menu.Item>
)} )}
</SubMenu> </SubMenu>
)}
{store.authentication.userData.role !== "Admin" && ( {store.authentication.userData.role !== "Admin" && (
<Menu.Item key="profile"> <Menu.Item key="profile">
<Link to={LINKS.PROFILE}> <Link to={LINKS.PROFILE}>
@ -364,13 +370,14 @@ export const DesktopLayout = observer(() => {
}} }}
mode="inline" mode="inline"
> >
{store.authentication.userData.role !== "Admin" && <Menu.Item> {store.authentication.userData.role !== "Admin" && (
<Menu.Item>
<Link to={LINKS.PROFILE}> <Link to={LINKS.PROFILE}>
<UserOutlined /> <UserOutlined />
<span>Profile</span> <span>Profile</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
} )}
<Menu.Item <Menu.Item
onClick={() => { onClick={() => {
store.authentication.logout(); store.authentication.logout();
@ -386,7 +393,7 @@ export const DesktopLayout = observer(() => {
<Text> <Text>
{store.user.data.username} {store.user.data.username}
<Paragraph <Paragraph
style={{fontWeight: 400, marginTop: '0.5rem'}} style={{ fontWeight: 400, marginTop: "0.5rem" }}
type={"secondary-dark"} type={"secondary-dark"}
strong strong
> >
@ -488,7 +495,7 @@ export const DesktopLayout = observer(() => {
title={ title={
<Text> <Text>
<Paragraph <Paragraph
style={{fontWeight: 400, marginTop: '0.5rem'}} style={{ fontWeight: 400, marginTop: "0.5rem" }}
type={"secondary-dark"} type={"secondary-dark"}
strong strong
> >

View File

@ -23,8 +23,7 @@ const {SubMenu} = Menu;
export const MenuList = observer((props) => { export const MenuList = observer((props) => {
const store = useStore(); const store = useStore();
useEffect(() => { useEffect(() => {}, []);
}, []);
const [setKeys, setSetKeys] = useState(["dashboard"]); const [setKeys, setSetKeys] = useState(["dashboard"]);
@ -47,13 +46,16 @@ export const MenuList = observer((props) => {
overflowedIndicator={0} overflowedIndicator={0}
forceSubMenuRender={true} forceSubMenuRender={true}
> >
{store.authentication.userData.role === "Admin" && (
<Menu.Item key="home"> <Menu.Item key="home">
<Link to={LINKS.HOME}> <Link to={LINKS.HOME}>
<HomeOutlined /> <HomeOutlined />
<span>Beranda</span> <span>Beranda</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
{store.authentication.userData.role !== "Retail" && ( )}
{store.authentication.userData.role !== "Retail" &&
store.authentication.userData.role !== "Admin Partner" && (
<Menu.Item key="membership"> <Menu.Item key="membership">
<Link to={LINKS.MEMBERSHIP}> <Link to={LINKS.MEMBERSHIP}>
<FileProtectOutlined /> <FileProtectOutlined />
@ -109,6 +111,14 @@ export const MenuList = observer((props) => {
)} )}
</SubMenu> </SubMenu>
)} )}
{store.authentication.userData.role === "Admin Partner" && (
<Menu.Item key="retail">
<Link to={LINKS.PRODUCT}>
<DatabaseOutlined />
<span>Produk</span>
</Link>
</Menu.Item>
)}
{store.authentication.userData.role === "Supervisor" && ( {store.authentication.userData.role === "Supervisor" && (
<Menu.Item key="retail"> <Menu.Item key="retail">
<Link to={LINKS.PRODUCT}> <Link to={LINKS.PRODUCT}>
@ -117,15 +127,22 @@ export const MenuList = observer((props) => {
</Link> </Link>
</Menu.Item> </Menu.Item>
)} )}
{store.authentication.userData.role === "Retail" && ( {store.authentication.userData.role === "Retail" ||
(store.authentication.userData.role === "Admin Partner" && (
<Menu.Item key="transaction"> <Menu.Item key="transaction">
<Link to={LINKS.TRANSACTION}> <Link to={LINKS.TRANSACTION}>
<ShoppingCartOutlined /> <ShoppingCartOutlined />
<span>Transaksi</span> <span>Transaksi</span>
</Link> </Link>
</Menu.Item> </Menu.Item>
)} ))}
<SubMenu key="payback-main" icon={<ProfileOutlined />} title="Pembayaran"> {store.authentication.userData.role !== "Retail" &&
store.authentication.userData.role !== "Admin Partner" && (
<SubMenu
key="payback-main"
icon={<ProfileOutlined />}
title="Pembayaran"
>
{store.authentication.userData.role !== "Retail" && ( {store.authentication.userData.role !== "Retail" && (
<Menu.Item key="payback-to-user"> <Menu.Item key="payback-to-user">
<Link to={LINKS.PAYBACK}> <Link to={LINKS.PAYBACK}>
@ -143,6 +160,7 @@ export const MenuList = observer((props) => {
</Menu.Item> </Menu.Item>
)} )}
</SubMenu> </SubMenu>
)}
{store.authentication.userData.role !== "Admin" && ( {store.authentication.userData.role !== "Admin" && (
<Menu.Item key="profile"> <Menu.Item key="profile">
<Link to={LINKS.PROFILE}> <Link to={LINKS.PROFILE}>

View File

@ -38,7 +38,7 @@ export const Commission = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.COMMISSION, route: LINKS.COMMISSION,

View File

@ -36,7 +36,7 @@ export const Partner = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.PARTNER, route: LINKS.PARTNER,

View File

@ -51,7 +51,7 @@ export const Supplier = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.SUPPLIER, route: LINKS.SUPPLIER,

View File

@ -1,25 +1,123 @@
import React from "react"; import React from "react";
import {Button, PageHeader} from "antd"; import { Button, PageHeader, Card, Row, Col, List } from "antd";
import { store } from "../../utils/useStore"; import { store } from "../../utils/useStore";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { FilterOutlined, TransactionOutlined } from "@ant-design/icons";
export const Home = observer(() => { export const Home = observer(() => {
return <div className={["ppob-container"].join(" ")}> return (
<PageHeader <div>
{store.ui.mediaQuery.isDesktop && (
<Row
style={{ style={{
padding: 0, marginTop: 30,
margin: 0, marginLeft: 30,
height: 40,
backgroundColor: "transparent",
}} }}
title={"Home"}
> >
<Card
className={"shadow"}
style={{
marginLeft: 20,
height: 200,
marginBottom: 10,
width: "30%",
}}
>
<PageHeader title={<span>Total Transaksi</span>}>
<span>Total Transaksi : 25 Transaksi</span>
</PageHeader> </PageHeader>
<Button onClick={() => { </Card>
store.ui.setTestValue(); <Card
}}>{store.ui.testValue}</Button> className={"shadow"}
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus aut recusandae velit! Consequatur corporis, style={{
eum fuga, harum incidunt laboriosam minus necessitatibus neque non nostrum pariatur tempore. Dignissimos impedit marginLeft: 20,
rem tempora! height: 200,
marginBottom: 10,
width: "30%",
}}
>
<PageHeader title={<span>Total Keuntungan</span>}>
<span>Rp.30.000.000</span>
</PageHeader>
</Card>
<Card
className={"shadow"}
hoverable
style={{
marginLeft: 20,
height: 200,
marginBottom: 10,
width: "30%",
}}
>
<PageHeader title={<span>Saldo</span>}>
<span>Rp.200.000.000 </span>
</PageHeader>
</Card>
</Row>
)}
{store.ui.mediaQuery.isMobile && (
<div style={{ marginTop: 10 }}>
<Card
className={"shadow"}
style={{
marginLeft: 20,
height: 200,
marginBottom: 10,
marginRight: 20,
}}
>
<PageHeader title={<span>Total Transaksi</span>}>
<span>Total Transaksi :</span>
</PageHeader>
</Card>
<Card
className={"shadow"}
style={{
marginLeft: 20,
height: 200,
marginBottom: 10,
marginRight: 20,
}}
>
<PageHeader title={<span>Total Keuntungan</span>}>
<span>Rp.30.000.000</span>
</PageHeader>
</Card>
<Card
className={"shadow"}
hoverable
style={{
marginLeft: 20,
height: 200,
marginBottom: 10,
marginRight: 20,
}}
>
<PageHeader title={<span>Saldo</span>}>
<span>Rp.200.000.000 </span>
</PageHeader>
</Card>
</div> </div>
)}
</div>
);
// return <div className={["ppob-container"].join(" ")}>
// <PageHeader
// style={{
// padding: 0,
// margin: 0,
// height: 40,
// backgroundColor: "transparent",
// }}
// title={"Home"}
// >
// </PageHeader>
// <Button onClick={() => {
// store.ui.setTestValue();
// }}>{store.ui.testValue}</Button>
// 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!
// </div>
}); });

View File

@ -174,7 +174,7 @@ export const Membership = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.MEMBERSHIP, route: LINKS.MEMBERSHIP,

View File

@ -163,7 +163,7 @@ export const Payback = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.PAYBACK, route: LINKS.PAYBACK,
@ -175,15 +175,23 @@ export const Payback = observer(() => {
modalLoader.setLoading(true); modalLoader.setLoading(true);
try { try {
const response = await store.payback.confirmPayback(id, type); const response = await store.payback.confirmPayback(id, type);
if (response.body.status !== 201) { console.log(response)
message.error( response.body.statusCode !== 201 && response.body.statusCode !== 200
? message.error(
response?.body?.message || `Failed ${capitalize(type)} Payback` response?.body?.message || `Failed ${capitalize(type)} Payback`
); )
} else { : message.success(
message.success(
response?.body?.message || `Success ${capitalize(type)} Payback` 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) { } catch (e) {
console.error(e, "apa errornya"); console.error(e, "apa errornya");
message.error( message.error(
@ -200,10 +208,10 @@ export const Payback = observer(() => {
<div> <div>
<Row style={{ marginBottom: 20 }}> <Row style={{ marginBottom: 20 }}>
<Col span={12}> <Col span={12}>
<Button> {/* <Button>
<FilterOutlined /> <FilterOutlined />
Filter Filter
</Button> </Button> */}
</Col> </Col>
<Col span={12} style={{ textAlign: "right" }}> <Col span={12} style={{ textAlign: "right" }}>
{/* <Search {/* <Search

View File

@ -80,7 +80,7 @@ export const PaybackCreated = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.PAYBACK_CREATED, route: LINKS.PAYBACK_CREATED,

View File

@ -37,7 +37,7 @@ export const Category = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.CATEGORY, route: LINKS.CATEGORY,

View File

@ -30,6 +30,7 @@ export const Product = observer(() => {
store.supplier.getData(), store.supplier.getData(),
store.category.getData(), store.category.getData(),
store.product.getDataSubCategories(), store.product.getDataSubCategories(),
store.product.getProductPartner()
]); ]);
await store.product.getData(); await store.product.getData();
modalLoader.setLoading(false); modalLoader.setLoading(false);
@ -53,7 +54,7 @@ export const Product = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.PRODUCT, route: LINKS.PRODUCT,

View File

@ -18,7 +18,7 @@ export const ProductDetail = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.PRODUCT, route: LINKS.PRODUCT,

View File

@ -41,7 +41,7 @@ export const Subcategory = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.SUBCATEGORY, route: LINKS.SUBCATEGORY,

View File

@ -138,12 +138,12 @@ export const Profile = observer(() => {
<div> <div>
<Title strong level={3}>History User Transaction</Title> <Title strong level={3}>History User Transaction</Title>
<Button style={{marginBottom: '1rem'}} onClick={() => { {/* <Button style={{marginBottom: '1rem'}} onClick={() => {
console.log('clicked filter') console.log('clicked filter')
}}> }}>
<FilterOutlined/> <FilterOutlined/>
Filter Filter
</Button> </Button> */}
<Table <Table
columns={columns} columns={columns}
bordered bordered

View File

@ -46,7 +46,7 @@ export const Transaction = observer(() => {
const routeData = [ const routeData = [
{ {
route: LINKS.HOME, route: LINKS.HOME,
name: "Home", name: "Beranda",
}, },
{ {
route: LINKS.TRANSACTION, route: LINKS.TRANSACTION,

View File

@ -27,7 +27,7 @@ export class Partner {
async getData() { async getData() {
try { try {
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`); const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
//console.log(response)
this.data = response.body.data.map((item, idx) => { this.data = response.body.data.map((item, idx) => {
item.key = idx; item.key = idx;
return item return item
@ -59,11 +59,12 @@ export class Partner {
} }
} }
// async updateStatus(id, data) { async updatePassword(id, data) {
// const response = await http.put(`/users/partner/${id}`).send(data); const response = await http.put(`/users/change-password-partner/${id}`).send(data);
// await this.getData(); console.log(response)
// return response; await this.getData();
// } return response;
}
async delete(id) { async delete(id) {
try { try {

View File

@ -26,9 +26,11 @@ export class Product {
dataPriceHistory = []; dataPriceHistory = [];
totalDataPriceHistory = 0; totalDataPriceHistory = 0;
pagePriceHistory = 0; pagePriceHistory = 0;
pageProductPartner = 0;
pageSizePriceHistory = 10 pageSizePriceHistory = 10
dataDetailProduct = {}; dataDetailProduct = {};
dataProductPartner=[]
constructor(ctx) { constructor(ctx) {
this.ctx = 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) { async create(data) {
try { try {
const response = await http.post('/product').send(data); const response = await http.post('/product').send(data);