Menu Supplier
This commit is contained in:
@@ -20,6 +20,7 @@ import { LINKS } from "../routes/app";
|
||||
export const SupplierComponent = observer((props) => {
|
||||
const store = useStore();
|
||||
const [form] = Form.useForm();
|
||||
//const [formEdit] = Form.useForm();
|
||||
const { Option } = Select;
|
||||
const history = useHistory();
|
||||
const [idData, setIdData] = useState("");
|
||||
@@ -45,16 +46,16 @@ export const SupplierComponent = observer((props) => {
|
||||
form.setFieldsValue({
|
||||
name: data.name,
|
||||
code: data.code,
|
||||
status:data.status
|
||||
status: data.status,
|
||||
});
|
||||
store.supplier.visibleModalSupplier = true;
|
||||
setIdData(data.id);
|
||||
};
|
||||
|
||||
const changeStatus = (id, isActive) => {
|
||||
const status = isActive ? "inactive" : "active"
|
||||
store.supplier.changeStatus(id, status)
|
||||
}
|
||||
const status = isActive ? "inactive" : "active";
|
||||
store.supplier.changeStatus(id, status);
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@@ -74,7 +75,7 @@ export const SupplierComponent = observer((props) => {
|
||||
render: (text, record) => (
|
||||
<Tag
|
||||
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||
style={{ color: "#4F566B", cursor: 'pointer' }}
|
||||
style={{ color: "#4F566B", cursor: "pointer" }}
|
||||
onClick={() => changeStatus(record?.id, record?.status)}
|
||||
>
|
||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||
@@ -125,9 +126,6 @@ export const SupplierComponent = observer((props) => {
|
||||
setIdData("");
|
||||
store.supplier.visibleModalSupplier = false;
|
||||
};
|
||||
const handleCancelTransaction= () => {
|
||||
store.supplier.visibleModalTransaction = false;
|
||||
};
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
console.log(data, "isi data2");
|
||||
@@ -136,6 +134,7 @@ export const SupplierComponent = observer((props) => {
|
||||
try {
|
||||
await store.supplier.update(idData, data);
|
||||
message.success("Success Update Data Member");
|
||||
await store.supplier.getData();
|
||||
} catch (e) {
|
||||
message.error("Failed Update Data Member");
|
||||
}
|
||||
@@ -160,24 +159,6 @@ export const SupplierComponent = observer((props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmitTransaction = async (data) => {
|
||||
console.log(data, "isi data2");
|
||||
setConfirmLoading(true);
|
||||
try {
|
||||
await store.supplier.createTransaction(data);
|
||||
message.success("Success Top Up");
|
||||
//await store.supplier.getData()
|
||||
} catch (e) {
|
||||
console.log(e, "apa errornya");
|
||||
message.error("Failed Top Up");
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
store.supplier.visibleModalTransaction = false;
|
||||
form.resetFields();
|
||||
};
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Table
|
||||
@@ -241,45 +222,6 @@ export const SupplierComponent = observer((props) => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
<Modal
|
||||
visible={store.supplier.visibleModalTransaction}
|
||||
title="Top Up Saldo"
|
||||
okText="Top Up"
|
||||
cancelText="Cancel"
|
||||
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="supplier"
|
||||
label="Supplier"
|
||||
rules={[{ required: true, message: "Please input supplier!" }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="amount"
|
||||
label="Amount"
|
||||
rules={[{ required: true, message: "Please input amount!" }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user