Merge branch 'develop' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend into devops-staging
This commit is contained in:
commit
425caac5bf
|
@ -10,7 +10,6 @@ import {
|
|||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
InputNumber,
|
||||
} from "antd";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
||||
|
@ -38,13 +37,13 @@ export const SupplierComponent = observer((props) => {
|
|||
setIdData(data.id);
|
||||
};
|
||||
|
||||
const handleTopup = async (data) => {
|
||||
store.supplier.code = data.code;
|
||||
console.log(data.code, "isi data");
|
||||
const handleTopup = (data) => {
|
||||
console.log(data, "isi data");
|
||||
form.setFieldsValue({
|
||||
code: data.code,
|
||||
});
|
||||
store.supplier.visibleModalTransaction = true;
|
||||
store.supplier.code = data.code;
|
||||
};
|
||||
|
||||
const changeStatus = async (id, isActive) => {
|
||||
|
@ -55,8 +54,8 @@ export const SupplierComponent = observer((props) => {
|
|||
const response = await store.supplier.changeStatus(id, status);
|
||||
modalLoader.setLoading(false);
|
||||
response?.body?.statusCode === 201
|
||||
? message.success(`Success ${status2} Supplier`)
|
||||
: message.error(`Failed ${status2} Supplier`);
|
||||
? message.success(`Success ${status2} Supplier`)
|
||||
: message.error(`Failed ${status2} Supplier`);
|
||||
} catch (err) {
|
||||
modalLoader.setLoading(false);
|
||||
console.log("error", err);
|
||||
|
@ -82,10 +81,10 @@ export const SupplierComponent = observer((props) => {
|
|||
key: ["coa", "amount"],
|
||||
width: "20%",
|
||||
render: (text, record) =>
|
||||
new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
}).format(text),
|
||||
new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
}).format(text),
|
||||
},
|
||||
{
|
||||
title: "Saldo di System",
|
||||
|
@ -93,10 +92,10 @@ export const SupplierComponent = observer((props) => {
|
|||
key: ["coa_undistribute", "amount"],
|
||||
width: "20%",
|
||||
render: (text, record) =>
|
||||
new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
}).format(text),
|
||||
new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
}).format(text),
|
||||
},
|
||||
{
|
||||
title: "Status",
|
||||
|
@ -104,12 +103,12 @@ export const SupplierComponent = observer((props) => {
|
|||
key: "status",
|
||||
width: "5%",
|
||||
render: (text, record) => (
|
||||
<Tag
|
||||
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||
style={{ color: "#4F566B" }}
|
||||
>
|
||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||
</Tag>
|
||||
<Tag
|
||||
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||
style={{ color: "#4F566B" }}
|
||||
>
|
||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -117,16 +116,16 @@ export const SupplierComponent = observer((props) => {
|
|||
key: "action",
|
||||
width: "20%",
|
||||
render: (text, record) => (
|
||||
<Space size="middle">
|
||||
<Button
|
||||
type={record?.status === true ? "danger" : "primary"}
|
||||
onClick={() => changeStatus(record?.id, record?.status)}
|
||||
>
|
||||
{record?.status === true ? "INACTIVE" : "ACTIVE"}
|
||||
</Button>
|
||||
<Button onClick={() => handleTopup(record)}> Top Up Saldo</Button>
|
||||
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
||||
</Space>
|
||||
<Space size="middle">
|
||||
<Button
|
||||
type={record?.status === true ? "danger" : "primary"}
|
||||
onClick={() => changeStatus(record?.id, record?.status)}
|
||||
>
|
||||
{record?.status === true ? "INACTIVE" : "ACTIVE"}
|
||||
</Button>
|
||||
<Button onClick={() => handleTopup(record)}> Top Up Saldo</Button>
|
||||
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
@ -164,27 +163,7 @@ export const SupplierComponent = observer((props) => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleCancelTransaction = () => {
|
||||
store.supplier.visibleModalTransaction = false;
|
||||
};
|
||||
|
||||
const handleSubmitTransaction = async (data) => {
|
||||
try {
|
||||
modalLoader.setLoading(true);
|
||||
const response = await store.supplier.createTransaction(data);
|
||||
message.success(response?.body?.message || "Success Top Up");
|
||||
} catch (e) {
|
||||
console.log(e, "apa errornya");
|
||||
message.error(e.response?.body?.message || "Failed Top Up");
|
||||
}
|
||||
|
||||
modalLoader.setLoading(false);
|
||||
store.supplier.visibleModalTransaction = false;
|
||||
form.resetFields();
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
form.resetFields();
|
||||
setIdData("");
|
||||
store.supplier.visibleModalSupplier = false;
|
||||
};
|
||||
|
@ -196,12 +175,12 @@ export const SupplierComponent = observer((props) => {
|
|||
modalLoader.setLoading(true);
|
||||
const response = await store.supplier.update(idData, data);
|
||||
response?.body?.statusCode === 201 || response?.body?.statusCode === 200
|
||||
? message.success(
|
||||
response?.body?.message || "Berhasil Ubah Data Supplier"
|
||||
)
|
||||
: message.error(
|
||||
response?.body?.message || "Gagal Ubah Data Supplier"
|
||||
);
|
||||
? message.success(
|
||||
response?.body?.message || "Berhasil Ubah Data Supplier"
|
||||
)
|
||||
: message.error(
|
||||
response?.body?.message || "Gagal Ubah Data Supplier"
|
||||
);
|
||||
} catch (e) {
|
||||
modalLoader.setLoading(false);
|
||||
message.error(e.response?.body?.message || "Gagal Ubah Data Supplier");
|
||||
|
@ -216,7 +195,7 @@ export const SupplierComponent = observer((props) => {
|
|||
const response = await store.supplier.create(data);
|
||||
if (response.status === 201) {
|
||||
message.success(
|
||||
response?.body?.message || "Berhasil Tambah Supplier"
|
||||
response?.body?.message || "Berhasil Tambah Supplier"
|
||||
);
|
||||
await store.supplier.getData();
|
||||
} else {
|
||||
|
@ -228,9 +207,9 @@ export const SupplierComponent = observer((props) => {
|
|||
console.log(e.result, "testingan1");
|
||||
if (e.response?.body?.error) {
|
||||
message.error(
|
||||
e.response.body.error
|
||||
? "Supplier Tersebut Sudah Terdaftar"
|
||||
: e.response.body.error
|
||||
e.response.body.error
|
||||
? "Supplier Tersebut Sudah Terdaftar"
|
||||
: e.response.body.error
|
||||
);
|
||||
modalLoader.setLoading(false);
|
||||
store.supplier.visibleModalSupplier = false;
|
||||
|
@ -249,245 +228,199 @@ export const SupplierComponent = observer((props) => {
|
|||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{store.ui.mediaQuery.isDesktop && (
|
||||
<Table
|
||||
style={{ textAlign: "center" }}
|
||||
columns={columns}
|
||||
dataSource={store.supplier.data}
|
||||
bordered
|
||||
pagination={{
|
||||
pageSize: store.supplier.pageSize,
|
||||
total: store.supplier.total_data,
|
||||
current: store.supplier.page + 1,
|
||||
showSizeChanger: true,
|
||||
simple: false,
|
||||
}}
|
||||
onChange={async (page) => {
|
||||
let pageNumber = page.current;
|
||||
store.supplier.pageSize = page.pageSize;
|
||||
store.supplier.page = pageNumber - 1;
|
||||
modalLoader.setLoading(true);
|
||||
await store.supplier.getData();
|
||||
modalLoader.setLoading(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{store.ui.mediaQuery.isMobile && (
|
||||
<List
|
||||
itemLayout="horizontal"
|
||||
position={"top"}
|
||||
pagination={{
|
||||
onChange: async (page, pageSize) => {
|
||||
store.supplier.pageSize = pageSize;
|
||||
store.supplier.page = page - 1;
|
||||
modalLoader.setLoading(true);
|
||||
await store.supplier.getData();
|
||||
modalLoader.setLoading(false);
|
||||
},
|
||||
pageSize: store.supplier.pageSize,
|
||||
total: store.supplier.total_data,
|
||||
current: store.supplier.page + 1,
|
||||
style: { marginBottom: "1rem", marginRight: "1rem" },
|
||||
}}
|
||||
dataSource={store.supplier.data}
|
||||
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={[""].join(" ")}
|
||||
title={item.code}
|
||||
description={
|
||||
<div style={{}}>
|
||||
<p>
|
||||
<small>Name : {item.name}</small> <br />
|
||||
<small>Saldo Supplier : {item.coa.amount}</small>
|
||||
<br />
|
||||
<small>
|
||||
Saldo System : {item.coa_undistribute.amount}
|
||||
</small>
|
||||
<br />
|
||||
<Button
|
||||
<div>
|
||||
{store.ui.mediaQuery.isDesktop && (
|
||||
<Table
|
||||
style={{ textAlign: "center" }}
|
||||
columns={columns}
|
||||
dataSource={store.supplier.data}
|
||||
bordered
|
||||
pagination={{
|
||||
pageSize: store.supplier.pageSize,
|
||||
total: store.supplier.total_data,
|
||||
current: store.supplier.page + 1,
|
||||
showSizeChanger: true,
|
||||
simple: false,
|
||||
}}
|
||||
onChange={async (page) => {
|
||||
let pageNumber = page.current;
|
||||
store.supplier.pageSize = page.pageSize;
|
||||
store.supplier.page = pageNumber - 1;
|
||||
modalLoader.setLoading(true);
|
||||
await store.supplier.getData();
|
||||
modalLoader.setLoading(false);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{store.ui.mediaQuery.isMobile && (
|
||||
<List
|
||||
itemLayout="horizontal"
|
||||
position={"top"}
|
||||
pagination={{
|
||||
onChange: async (page, pageSize) => {
|
||||
store.supplier.pageSize = pageSize;
|
||||
store.supplier.page = page - 1;
|
||||
modalLoader.setLoading(true);
|
||||
await store.supplier.getData();
|
||||
modalLoader.setLoading(false);
|
||||
},
|
||||
pageSize: store.supplier.pageSize,
|
||||
total: store.supplier.total_data,
|
||||
current: store.supplier.page + 1,
|
||||
style: { marginBottom: "1rem", marginRight: "1rem" },
|
||||
}}
|
||||
dataSource={store.supplier.data}
|
||||
style={{ padding: 0 }}
|
||||
renderItem={(item) => {
|
||||
return (
|
||||
<div>
|
||||
<List.Item
|
||||
key={item.id}
|
||||
style={{
|
||||
marginRight: 10,
|
||||
backgroundColor: "#ffffff",
|
||||
paddingTop: 0,
|
||||
paddingBottom: 0,
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
type={item?.status === true ? "danger" : "primary"}
|
||||
onClick={() => changeStatus(item?.id, item?.status)}
|
||||
>
|
||||
{item?.status === true ? "INACTIVE" : "ACTIVE"}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleTopup(item)}
|
||||
style={{
|
||||
marginRight: 10,
|
||||
}}
|
||||
>
|
||||
Top Up Saldo
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleEditButton(item)}
|
||||
style={{
|
||||
marginBottom: 5,
|
||||
}}
|
||||
>
|
||||
Edit
|
||||
</Button>
|
||||
<Tag
|
||||
color={
|
||||
item?.status === true ? "processing" : "#E3E8EE"
|
||||
}
|
||||
style={{ color: "#4F566B" }}
|
||||
>
|
||||
{item?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||
</Tag>
|
||||
</p>
|
||||
<p></p>
|
||||
>
|
||||
<List.Item.Meta
|
||||
className={[""].join(" ")}
|
||||
title={item.code}
|
||||
description={
|
||||
<div style={{}}>
|
||||
<p>
|
||||
<small>Name : {item.name}</small> <br />
|
||||
<small>Saldo Supplier : {item.coa.amount}</small>
|
||||
<br />
|
||||
<small>
|
||||
Saldo System : {item.coa_undistribute.amount}
|
||||
</small>
|
||||
<br />
|
||||
<Button
|
||||
style={{
|
||||
marginRight: 10,
|
||||
}}
|
||||
type={item?.status === true ? "danger" : "primary"}
|
||||
onClick={() => changeStatus(item?.id, item?.status)}
|
||||
>
|
||||
{item?.status === true ? "INACTIVE" : "ACTIVE"}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleTopup(item)}
|
||||
style={{
|
||||
marginRight: 10,
|
||||
}}
|
||||
>
|
||||
Top Up Saldo
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => handleEditButton(item)}
|
||||
style={{
|
||||
marginBottom: 5,
|
||||
}}
|
||||
>
|
||||
Edit
|
||||
</Button>
|
||||
<Tag
|
||||
color={
|
||||
item?.status === true ? "processing" : "#E3E8EE"
|
||||
}
|
||||
style={{ color: "#4F566B" }}
|
||||
>
|
||||
{item?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||
</Tag>
|
||||
</p>
|
||||
<p></p>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
<Divider plain style={{ margin: 0 }} />
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</List.Item>
|
||||
<Divider plain style={{ margin: 0 }} />
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Modal
|
||||
visible={store.supplier.visibleModalSupplier}
|
||||
title={idData ? "Edit Supplier" : "Buat Supplier Baru"}
|
||||
okText={idData ? "Edit" : "Buat"}
|
||||
cancelText="Batal"
|
||||
onCancel={() => {
|
||||
handleCancel();
|
||||
}}
|
||||
onOk={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then((values) => {
|
||||
console.log(values, "isi form");
|
||||
handleSubmit(values);
|
||||
);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Modal
|
||||
visible={store.supplier.visibleModalSupplier}
|
||||
title={idData ? "Edit Supplier" : "Buat Supplier Baru"}
|
||||
okText={idData ? "Edit" : "Buat"}
|
||||
cancelText="Batal"
|
||||
onCancel={() => {
|
||||
form.resetFields();
|
||||
})
|
||||
.catch((info) => {
|
||||
console.error("Validate Failed:", info);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<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 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>
|
||||
{!idData && (
|
||||
handleCancel();
|
||||
}}
|
||||
onOk={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then((values) => {
|
||||
console.log(values, "isi form");
|
||||
handleSubmit(values);
|
||||
form.resetFields();
|
||||
})
|
||||
.catch((info) => {
|
||||
console.error("Validate Failed:", info);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item
|
||||
name="code"
|
||||
label="Kode"
|
||||
rules={[{ required: true, message: "Please input kode!" }]}
|
||||
name="irs_id"
|
||||
label="Id"
|
||||
rules={[{ required: true, message: "Please input name!" }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
<Modal
|
||||
visible={store.supplier.visibleModalTransaction}
|
||||
title="Top Up Saldo"
|
||||
okText="Top Up"
|
||||
cancelText="Batal"
|
||||
onCancel={() => {
|
||||
form.resetFields();
|
||||
handleCancelTransaction();
|
||||
}}
|
||||
onOk={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then((values) => {
|
||||
console.log(values, "isi form");
|
||||
handleSubmitTransaction(values);
|
||||
form.resetFields();
|
||||
})
|
||||
.catch((info) => {
|
||||
console.error("Validate Failed:", info);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
>
|
||||
<Form.Item
|
||||
name="code"
|
||||
label="Supplier"
|
||||
rules={[{ required: true, message: "Please input supplier!" }]}
|
||||
>
|
||||
<Input disabled={true} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="amount"
|
||||
label="Nominal"
|
||||
rules={[{ required: true, message: "Please input amount!" }]}
|
||||
>
|
||||
<InputNumber
|
||||
style={{ width: "100%" }}
|
||||
formatter={(value) =>
|
||||
`Rp. ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
|
||||
}
|
||||
parser={(value) => value.replace(/\Rp.\s?|(,*)/g, "")}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="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>
|
||||
{!idData && (
|
||||
<Form.Item
|
||||
name="code"
|
||||
label="Kode"
|
||||
rules={[{ required: true, message: "Please input kode!" }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
<TopupsaldoModal code={store.supplier.code} />
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user