Merge branch 'develop' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend into devops-production

This commit is contained in:
Fadli 2022-06-22 00:10:18 +07:00
commit 70b5bbb8a4
8 changed files with 429 additions and 119 deletions

View File

@ -33,6 +33,7 @@ export const ProductComponent = observer((props) => {
const [filterSupplier, setFilterSupplier] = useState([]);
const [filterSubCategories, setFilterSubCategories] = useState([]);
const modalLoader = useContext(ModalLoaderContext);
const role = store.authentication.userData.role
const handleEditButton = (data) => {
console.log(data, "isi data");
@ -61,8 +62,8 @@ export const ProductComponent = observer((props) => {
},
{
title: "Harga Beli",
dataIndex: "current_price_price",
key: "current_price_price",
dataIndex: "price",
key: "price",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
@ -89,6 +90,26 @@ export const ProductComponent = observer((props) => {
currency: "IDR",
}).format(text),
},
{
title: "Biaya Admin",
dataIndex: "admin_price",
key: "admin_price",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
},
{
title: "Fee Jual",
dataIndex: "partner_fee",
key: "partner_fee",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
},
{
title: "Supplier",
dataIndex: "supplier_name",
@ -115,6 +136,7 @@ export const ProductComponent = observer((props) => {
{
title: "Tindakan",
key: "action",
fixed: 'right',
render: (text, record) => (
<Button
onClick={async () => {
@ -128,14 +150,15 @@ export const ProductComponent = observer((props) => {
),
},
];
//if (store.authentication.userData.role !== "Admin") columns.pop();
//if (store.authentication.userData.role === "Admin Partner") delete columns[2];
if (store.authentication.userData.role === "Admin Partner") delete columns[10];
if (store.authentication.userData.role === "Admin Partner") delete columns[3];
if (store.authentication.userData.role != "Admin Partner") delete columns[4];
if (store.authentication.userData.role !== "Admin Partner") delete columns[4];
if (store.authentication.userData.role !== "Admin") delete columns[9];
if (store.authentication.userData.role !== "Admin") delete columns[6];
if (store.authentication.userData.role !== "Admin") delete columns[7];
if (store.authentication.userData.role !== "Admin") delete columns[2];
if (store.authentication.userData.role !== "Admin") delete columns[5];
if (store.authentication.userData.role === "Admin Partner") delete columns[7];
if (store.authentication.userData.role === "Admin Partner") delete columns[8];
//if (store.authentication.userData.role !== "Admin") delete columns[8];
//if (store.authentication.userData.role === "Admin Partner") delete columns[5];
@ -208,43 +231,35 @@ export const ProductComponent = observer((props) => {
};
const handleRemoveFilter = async () => {
store.product.pageProductPartner = 0
store.product.visibleModalFilterProduct = false;
store.product.filterSupplier = null;
store.product.filterSubCategory = null;
setFilterSupplier([]);
setFilterSubCategories([]);
store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner(
store.authentication.profileData.id
)
? await store.product.getProductPartner()
: await store.product.getData();
//await store.product.getData();
store.product.visibleModalFilterProduct = false;
modalLoader.setLoading(false);
};
const handleCancelFilter = async () => {
store.product.filterSubCategory = null;
store.product.filterSupplier = null;
store.product.visibleModalFilterProduct = false;
store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner(
store.authentication.profileData.id
)
: await store.product.getData();
//await store.product.getData();
};
const handleSubmitFilter = async () => {
store.product.pageProductPartner = 0
store.product.visibleModalFilterProduct = false;
store.product.filterSupplier = filterSupplier;
store.product.filterSubCategory = filterSubCategories;
modalLoader.setLoading(true);
store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner(
store.authentication.profileData.id
)
? await store.product.getProductPartner(filterSubCategories)
: await store.product.getData();
//await store.product.getData();
modalLoader.setLoading(false);
store.product.visibleModalFilterProduct = false;
//store.product.page=1
};
@ -276,7 +291,7 @@ export const ProductComponent = observer((props) => {
const handleClickRow = (record, index) => ({
onClick: (event) => {
history.push(LINKS.PRODUCT_DETAIL.replace(":id", record.product_id));
history.push(LINKS.PRODUCT_DETAIL.replace(":id", record.product_id))
},
});
return (
@ -288,29 +303,35 @@ export const ProductComponent = observer((props) => {
textAlign: "center",
width: store.ui.mediaQuery.isMobile ? 250 : "",
}}
scroll={role === "Admin Partner" ? false : { x: 1300 }}
columns={columns}
dataSource={
store.authentication.userData.role === "Admin Partner"
? store.product.dataProductPartner
: store.product.data
}
onRow={handleClickRow}
onRow={role === "Admin Partner" ? false : handleClickRow}
pagination={{
pageSize: store.product.pageSize,
pageSize: store.authentication.userData.role === "Admin" ? store.product.pageSize : store.product.pageSizeProductPartner,
total:
store.authentication.userData.role === "Admin Partner"
? store.product.total_data_partner
: store.product.total_data,
current: store.product.page + 1,
current: store.authentication.userData.role === "Admin" ? store.product.page + 1 : store.product.pageProductPartner + 1,
showSizeChanger: true,
simple: false,
}}
onChange={async (page) => {
let pageNumber = page.current;
store.product.pageSize = page.pageSize;
store.product.page = pageNumber - 1;
store.authentication.userData.role === "Admin" ? store.product.pageSize = page.pageSize : store.product.pageSizeProductPartner = page.pageSize;
store.authentication.userData.role === "Admin" ? store.product.page = pageNumber - 1 : store.product.pageProductPartner = pageNumber - 1
store.product.filterSubCategory = filterSubCategories
modalLoader.setLoading(true);
await store.product.getData();
store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner(
filterSubCategories
)
: await store.product.getData();
modalLoader.setLoading(false);
}}
/>
@ -321,23 +342,29 @@ export const ProductComponent = observer((props) => {
position={"top"}
pagination={{
onChange: async (page, pageSize) => {
store.product.pageSize = pageSize;
store.product.page = page - 1;
store.authentication.userData.role === "Admin" ? store.product.pageSize = pageSize : store.product.pageSizeProductPartner = pageSize;
store.authentication.userData.role === "Admin" ? store.product.page = page - 1 : store.product.pageProductPartner = page - 1
modalLoader.setLoading(true);
store.authentication.userData.role === "Admin Partner"
? await store.product.getProductPartner(
store.authentication.profileData.id
filterSubCategories
)
: await store.product.getData();
//await store.product.getData();
modalLoader.setLoading(false);
},
pageSize: store.product.pageSize,
total: store.product.total_data,
current: store.product.page + 1,
pageSize: store.authentication.userData.role === "Admin" ? store.product.pageSize : store.product.pageSizeProductPartner,
total: store.authentication.userData.role === "Admin Partner"
? store.product.total_data_partner
: store.product.total_data,
current: store.authentication.userData.role === "Admin" ? store.product.page + 1 : store.product.pageProductPartner + 1,
style: { marginBottom: "1rem", marginRight: "1rem" },
}}
dataSource={store.product.data}
dataSource={
store.authentication.userData.role === "Admin Partner"
? store.product.dataProductPartner
: store.product.data
}
style={{ padding: 0 }}
renderItem={(item) => {
return (

View File

@ -367,10 +367,45 @@ export const SupplierComponent = observer((props) => {
}}
>
<Form form={form} layout="vertical">
<Form.Item
name="irs_id"
label="Id"
rules={[{ required: true, message: "Please input name!" }]}
>
<Input />
</Form.Item>
<Form.Item
name="name"
label="Name"
rules={[{ required: true, message: "Please input name!" }]}
rules={[{ required: true, message: "Please input url!" }]}
>
<Input />
</Form.Item>
<Form.Item
name="url"
label="Url"
rules={[{ required: true, message: "Please input url!" }]}
>
<Input />
</Form.Item>
<Form.Item
name="irs_pin"
label="Pin"
rules={[{ required: true, message: "Please input url!" }]}
>
<Input />
</Form.Item>
<Form.Item
name="irs_user"
label="User"
rules={[{ required: true, message: "Please input url!" }]}
>
<Input />
</Form.Item>
<Form.Item
name="irs_pass"
label="Password"
rules={[{ required: true, message: "Please input url!" }]}
>
<Input />
</Form.Item>

View File

@ -445,6 +445,7 @@ export const DetailUser = observer(() => {
onClick={() => {
setInitialData({
id: store.membership.dataDetail.id,
code: store.membership.dataDetail.partner.code,
name: store.membership.dataDetail.userDetail.name,
username: store.membership.dataDetail.username,
identity_number:
@ -558,6 +559,14 @@ export const DetailUser = observer(() => {
{store.authentication.dataProfit.userDetail?.identity_number}
</Text>
</Col>
<Col span={12}>
<Text strong>Code</Text>
</Col>
<Col span={12}>
<Text>
{store.authentication.dataProfit.partner?.code}
</Text>
</Col>
<Col span={12}>
<Text strong>Status</Text>
</Col>

View File

@ -72,6 +72,25 @@ export const ProductDetail = observer(() => {
currency: "IDR",
}).format(text),
},
{
title: "Biaya Admin",
dataIndex: "admin_price",
key: "admin_price",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
}, {
title: "Partner fee",
dataIndex: "partner_fee",
key: "partner_fee",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
},
{
title: "Tanggal Berlaku",
dataIndex: "startDate",

View File

@ -66,13 +66,14 @@ export const Profile = observer(() => {
await Promise.allSettled([
store.authentication.getProfile(),
store.transaction.getDataHistoryTransaction(),
store.transaction.getDataHistoryCheckBill(),
]);
await store.transaction.getDataHistoryTopUpProfile(
store.authentication.profileData?.id
);
modalLoader.setLoading(false);
})();
}, []);
}, [store.transaction.filterStart, store.transaction.filterEnd]);
const handleRemoveFilter = async () => {
store.transaction.filterStart = null;
@ -81,11 +82,11 @@ export const Profile = observer(() => {
setFilterStart([]);
setFilterEnd([]);
//await store.transaction.getDataHistoryTransaction();
actionFilter === true
? await store.transaction.getDataHistoryTopUpProfile(
store.authentication.profileData?.id
)
: await store.transaction.getDataHistoryTransaction();
// actionFilter === true
// ? await store.transaction.getDataHistoryTopUpProfile(
// store.authentication.profileData?.id
// )
// : await store.transaction.getDataHistoryTransaction();
store.transaction.visibleModalFilterTransaction = false;
setAction(false);
};
@ -95,11 +96,11 @@ export const Profile = observer(() => {
//form.resetFields();
store.transaction.filterEnd = null;
store.transaction.visibleModalFilterTransaction = false;
actionFilter === true
? await store.transaction.getDataHistoryTopUpProfile(
store.authentication.profileData?.id
)
: await store.transaction.getDataHistoryTransaction();
// actionFilter === true
// ? await store.transaction.getDataHistoryTopUpProfile(
// store.authentication.profileData?.id
// )
// : await store.transaction.getDataHistoryTransaction();
setAction(false);
//await store.transaction.getDataHistoryTransaction();
};
@ -113,14 +114,14 @@ export const Profile = observer(() => {
"YYYY-MM-DD HH:mm:ss"
);
modalLoader.setLoading(true);
actionFilter === true
? await store.transaction.getDataHistoryTopUpProfile(
store.authentication.profileData?.id
)
: await store.transaction.getDataHistoryTransaction();
// actionFilter === true
// ? await store.transaction.getDataHistoryTopUpProfile(
// store.authentication.profileData?.id
// )
// : await store.transaction.getDataHistoryTransaction();
modalLoader.setLoading(false);
store.transaction.filterStart = null;
store.transaction.filterEnd = null;
// store.transaction.filterStart = null;
// store.transaction.filterEnd = null;
//form.resetFields();
store.transaction.visibleModalFilterTransaction = false;
setAction(false);
@ -266,6 +267,81 @@ export const Profile = observer(() => {
},
},
];
const columnBill = [
{
title: "Code Product",
dataIndex: "product_code",
key: "product_code",
},
{
title: "Admin Price",
dataIndex: "admin_price",
key: "admin_price",
render: (text) =>
new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(text),
},
{
title: "Tagihan Postpaid",
dataIndex: "amount",
key: "amount",
},
{
title: "Nomor tujuan",
dataIndex: "destination",
key: "destination",
},
{
title: "Transaction Id",
dataIndex: "trx_id",
key: "trx_id",
},
{
title: "Partner Transaction Id",
dataIndex: "partner_trx_id",
key: "partner_trx_id",
},
{
title: "Tanggal Transaksi",
dataIndex: "createdAt",
key: "createdAt",
render: (text, record) => {
return (
<Text>
{format(parseISO(record.createdAt), "dd MMMM yyyy HH:mm:ss")}
</Text>
);
},
},
{
title: "Status",
dataIndex: "status",
key: "status",
render: (text, record) => {
console.log("status", record)
return (
<Tag
color={
record.status === "SUCCESS"
? "success"
: record.status === 0
? "warning"
: "processing"
}
>
{record.status === "SUCCESS"
? "Sukses"
: record.status === 0
? "Dalam Proses"
: "Gagal"}
</Tag>
);
},
},
];
const styleSaldoTitle = store.ui.mediaQuery.isDesktop
? {
display: "flex",
@ -605,8 +681,6 @@ export const Profile = observer(() => {
dataSource={store.transaction.dataHistoryTransaction}
pagination={{
onChange: async (page, pageSize) => {
console.log(page, "Page");
console.log(pageSize, "Page size");
store.transaction.page = pageSize;
store.transaction.page = page - 1;
modalLoader.setLoading(true);
@ -704,6 +778,118 @@ export const Profile = observer(() => {
</div>
)}
</TabPane>
<TabPane tab="Riwayat Check Bill" key="3">
<Button
style={{ marginBottom: "1rem", marginLeft: 5 }}
onClick={() => {
store.transaction.visibleModalFilterTransaction = true;
store.transaction.page = 0;
setAction(true);
}}
>
<FilterOutlined />
Filter
</Button>
{store.ui.mediaQuery.isDesktop && (
<Table
key="1"
hasEmpty
columns={columnBill}
dataSource={store.transaction.dataHistorybillProfile}
bordered
pagination={{
pageSize: store.transaction.pageSize,
total: store.transaction.total_dataHistorybillProfile,
current: store.transaction.page + 1,
showSizeChanger: true,
simple: false,
}}
onChange={async (page) => {
let pageNumber = page.current;
store.transaction.pageSize = page.pageSize;
store.transaction.page = pageNumber - 1;
modalLoader.setLoading(true);
await store.transaction.getDataHistoryCheckBill();
modalLoader.setLoading(false);
}}
/>
)}
{store.ui.mediaQuery.isMobile && (
<div>
<List
itemLayout="horizontal"
position={"top"}
dataSource={store.transaction.dataHistorybillProfile}
pagination={{
onChange: async (page, pageSize) => {
console.log(page, "Page");
console.log(pageSize, "Page size");
store.transaction.pageSize = pageSize;
store.transaction.page = page - 1;
modalLoader.setLoading(true);
await store.transaction.getDataHistoryCheckBill();
modalLoader.setLoading(false);
},
pageSize: store.transaction.pageSize,
total: store.transaction.total_dataHistorybillProfile,
current: store.transaction.page + 1,
style: { marginBottom: "1rem", marginRight: "1rem" },
}}
style={{ padding: 0 }}
renderItem={(item) => {
return (
<div>
<List.Item
key={item.id}
style={{
backgroundColor: "#ffffff",
paddingTop: 0,
paddingBottom: 0,
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
}}
>
<List.Item.Meta
className={["cariparkir-container"].join(" ")}
title={item.id}
description={
<div style={{}}>
<p>
<small>
Pengirim : {item.sender_name}
</small>{" "}
<br />
<small>
Amount :{" "}
{new Intl.NumberFormat("id-ID", {
style: "currency",
currency: "IDR",
}).format(item.amount || 0)}
</small>{" "}
<br />
<small>
Transaction Date :{" "}
{format(
parseISO(item.transaction_date),
"dd-MM-yyyy"
)}
</small>{" "}
<br />
</p>
</div>
}
/>
</List.Item>
<Divider plain style={{ margin: 0 }} />
</div>
);
}}
/>
</div>
)}
</TabPane>
</Tabs>
</Col>
</Row>

View File

@ -28,6 +28,7 @@ export class Product {
totalDataPriceHistory = 0;
pagePriceHistory = 0;
pageProductPartner = 0;
pageSizeProductPartner = 10
pageSizePriceHistory = 10
dataDetailProduct = {};
@ -54,6 +55,7 @@ export class Product {
}
}
async getDataSubCategories() {
try {
const response = await http.get(`/product/sub-categories?category=${this.filterCategory}&page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
@ -99,14 +101,27 @@ export class Product {
}
async getProductPartner(id) {
console.log({ id });
if (id === undefined) {
try {
const response = await http.get(`/product/by-categories?page=${this.pageProductPartner}&pageSize=10&sub-category=${id}`);
const response = await http.get(`/product/by-categories?page=${this.pageProductPartner}&pageSize=${this.pageSizeProductPartner}&sub-category=`);
console.log(response)
this.dataProductPartner = response.body.data
this.total_data_partner = response?.body?.count ?? 0
} catch (e) {
console.error(e);
}
} else {
try {
const response = await http.get(`/product/by-categories?page=${this.pageProductPartner}&pageSize=${this.pageSizeProductPartner}&sub-category=${id}`);
console.log(response)
this.dataProductPartner = response.body.data
this.total_data_partner = response?.body?.count ?? 0
} catch (e) {
console.error(e);
}
}
}
async create(data) {

View File

@ -40,6 +40,9 @@ export class Transaction {
dataHistoryTopUp = [];
total_dataHistoryTopUp = 0;
dataHistorybillProfile = [];
total_dataHistorybillProfile = 0;
dataHistoryTopUpProfile = [];
total_dataHistoryTopUpProfile = 0;
@ -130,6 +133,23 @@ export class Transaction {
}
}
async getDataHistoryCheckBill() {
try {
const response = await http.get(
`/transaction/check-bill-history`
);
// const response = await http.get(
// `/transaction/check-bill-history?page=${this.page}&pageSize=${this.pageSize}&start=${this.filterStart}&end=${this.filterEnd}`
// );
console.log("bill", response);
this.dataHistorybillProfile = response.body.data ?? [];
this.total_dataHistorybillProfile = response?.body?.count ?? 0;
console.log(this.total_dataHistorybillProfile)
} catch (e) {
console.error(e);
}
}
async getDataHistoryTransaction() {
try {
const response = await http.get(
@ -138,7 +158,6 @@ export class Transaction {
console.log(response);
this.dataHistoryTransaction = response.body.data ?? [];
this.total_dataHistoryTransaction = response?.body?.count ?? 0;
console.log(this.total_dataHistoryTransaction)
} catch (e) {
console.error(e);
}