Merge branch 'develop' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend into develop
This commit is contained in:
@@ -1,135 +0,0 @@
|
||||
import React, {useEffect, useState} from "react";
|
||||
import {Form, Input, Modal, Select} from "antd";
|
||||
import {useStore} from "../../utils/useStore";
|
||||
import {observer} from "mobx-react-lite";
|
||||
|
||||
export const PulsaModal = observer(({visible, onCreate, onCancel, initialData}) => {
|
||||
const [form] = Form.useForm();
|
||||
const {Option} = Select;
|
||||
const store = useStore();
|
||||
const [visibleModal, setVisibleModal] = useState(false);
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
await store.product.getDataSubCategories();
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
}, []);
|
||||
|
||||
|
||||
const subCategoriesOption = [
|
||||
<Option key={123} value={123}>
|
||||
{123}
|
||||
</Option>,
|
||||
<Option key={431} value={123}>
|
||||
{123}
|
||||
</Option>
|
||||
];
|
||||
|
||||
const subCategoriesOption2 = store.product.dataSubCategories.slice().map(subCategory => {
|
||||
return (
|
||||
<Option key={subCategory.id} value={subCategory.id}>
|
||||
{subCategory.name}
|
||||
</Option>
|
||||
)
|
||||
});
|
||||
|
||||
console.log(store.product.dataSubCategories, 'subCategoriesOption2');
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
title={initialData.id ? "Edit Product" : "Create a new Product"}
|
||||
okText={initialData.id ? "Edit" : "Create"}
|
||||
cancelText="Cancel"
|
||||
onCancel={() => {
|
||||
form.resetFields();
|
||||
onCancel();
|
||||
}}
|
||||
onOk={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then((values) => {
|
||||
onCreate(values);
|
||||
form.resetFields();
|
||||
})
|
||||
.catch((info) => {
|
||||
console.log("Validate Failed:", info);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
name="form_in_modal"
|
||||
initialValues={initialData}
|
||||
>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="Name"
|
||||
rules={[{required: true, message: "Please input name!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="price"
|
||||
label="Price"
|
||||
rules={[{required: true, message: "Please input price!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="base_price"
|
||||
label="Mark Up Price"
|
||||
rules={[{required: true, message: "Please input mark up price!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="code"
|
||||
label="Code"
|
||||
rules={[{required: true, message: "Please input code!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="status"
|
||||
label="Status"
|
||||
rules={[{required: true, message: "Please select Status!"}]}
|
||||
>
|
||||
<Select placeholder="Select Sub Category" allowClear>
|
||||
<Option value="ACTIVE">ACTIVE</Option>
|
||||
<Option value="INACTIVE">INACTIVE</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="sub_category"
|
||||
label="Sub categories"
|
||||
rules={[{required: true, message: "Please select sub categories!"}]}
|
||||
>
|
||||
<Select placeholder="Select Sub Category" allowClear>
|
||||
{subCategoriesOption2}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
{/*<Form.Item*/}
|
||||
{/* name="subCategories"*/}
|
||||
{/* label="Sub Categories"*/}
|
||||
{/* rules={[{required: true, message: "Please select Sub Category!"}]}*/}
|
||||
{/*>*/}
|
||||
{/* <Select placeholder="Select Sub Category" allowClear>*/}
|
||||
{/* {subCategoriesOption2}*/}
|
||||
{/* </Select>*/}
|
||||
{/*</Form.Item>*/}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
});
|
Reference in New Issue
Block a user