Menu Supplier
This commit is contained in:
@@ -22,6 +22,7 @@ export const SubcategoryComponent = observer((props) => {
|
||||
setIsLoading(true);
|
||||
//store.product.pageCategories=StrToLower(props.category)
|
||||
await store.subcategory.getData();
|
||||
await store.category.getData();
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
@@ -35,8 +36,9 @@ export const SubcategoryComponent = observer((props) => {
|
||||
console.log(data, "isi data")
|
||||
form.setFieldsValue({
|
||||
name: data.name,
|
||||
categoryId: data.categoryId,
|
||||
});
|
||||
store.category.visibleModalCategory = true;
|
||||
store.subcategory.visibleModalSubcategory = true;
|
||||
setIdData(data.id);
|
||||
}
|
||||
|
||||
@@ -46,32 +48,6 @@ export const SubcategoryComponent = observer((props) => {
|
||||
dataIndex: "name",
|
||||
key: "name",
|
||||
},
|
||||
// {
|
||||
// title: "Gangguan",
|
||||
// dataIndex: "status",
|
||||
// key: "status",
|
||||
// render: (text, record) => (
|
||||
// <Tag
|
||||
// color={record?.status === "ACTIVE" ? "blue" : "#E3E8EE"}
|
||||
// style={{color: "#4F566B"}}
|
||||
// >
|
||||
// {capitalize(record?.status)}
|
||||
// </Tag>
|
||||
// ),
|
||||
// },
|
||||
// {
|
||||
// title: "Tersedia",
|
||||
// dataIndex: "tersedia",
|
||||
// key: "tersedia",
|
||||
// render: (text, record) => (
|
||||
// <Tag
|
||||
// color={record?.status === "ACTIVE" ? "blue" : "#E3E8EE"}
|
||||
// style={{color: "#4F566B"}}
|
||||
// >
|
||||
// {record?.status === "ACTIVE" ? " Ya" : "Tidak"}
|
||||
// </Tag>
|
||||
// ),
|
||||
// },
|
||||
{
|
||||
title: "Action",
|
||||
key: "action",
|
||||
@@ -120,7 +96,7 @@ export const SubcategoryComponent = observer((props) => {
|
||||
|
||||
const handleCancel = () => {
|
||||
setIdData('')
|
||||
store.category.visibleModalCategory = false;
|
||||
store.subcategory.visibleModalSubcategory = false;
|
||||
}
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
@@ -128,31 +104,31 @@ export const SubcategoryComponent = observer((props) => {
|
||||
if (idData !== '') {
|
||||
setConfirmLoading(true);
|
||||
try {
|
||||
await store.category.update(idData, data)
|
||||
await store.subcategory.update(idData, data)
|
||||
message.success("Success Update Data Category")
|
||||
} catch (e) {
|
||||
message.error("Failed Update Data Category")
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
store.category.visibleModalCategory = false;
|
||||
store.subcategory.visibleModalSubcategory = false;
|
||||
setIdData('');
|
||||
form.resetFields();
|
||||
} else {
|
||||
setConfirmLoading(true);
|
||||
try {
|
||||
await store.category.create(data)
|
||||
await store.subcategory.create(data)
|
||||
message.success("Success Add New Category")
|
||||
} catch (e) {
|
||||
console.log(e, "apa errornya")
|
||||
message.error("Failed Add Category")
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
store.category.visibleModalCategory = false;
|
||||
store.subcategory.visibleModalSubcategory = false;
|
||||
setIdData('');
|
||||
form.resetFields();
|
||||
}
|
||||
}
|
||||
|
||||
//console.log()
|
||||
return (
|
||||
<div>
|
||||
<Table
|
||||
@@ -178,8 +154,8 @@ export const SubcategoryComponent = observer((props) => {
|
||||
/>
|
||||
|
||||
<Modal
|
||||
visible={store.category.visibleModalCategory}
|
||||
title={idData ? "Edit Category" : "Create a new Category"}
|
||||
visible={store.subcategory.visibleModalSubcategory}
|
||||
title={idData ? "Edit Sub Category" : "Create a new sub category"}
|
||||
okText={idData ? "Edit" : "Create"}
|
||||
cancelText="Cancel"
|
||||
onCancel={() => {
|
||||
@@ -210,6 +186,19 @@ export const SubcategoryComponent = observer((props) => {
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="categoryId"
|
||||
label="Categories"
|
||||
rules={[{required: true, message: "Please input category id!"}]}
|
||||
>
|
||||
<Select placeholder="Select Category" allowClear>
|
||||
{store.category.data.map((item) => (
|
||||
<Option value={item.id} key={item.id}>
|
||||
{item.name}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
|
||||
@@ -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