Pages Supplier
This commit is contained in:
parent
6f743301e4
commit
ac7e5714e7
|
@ -1,5 +1,14 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import {Button, Form, Input, message, Modal, Select, Space, Table, Tag} from "antd";
|
import {
|
||||||
|
Button,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
message,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Table,
|
||||||
|
} from "antd";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
@ -12,7 +21,7 @@ export const CommissionComponent = observer((props) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [idData, setIdData] = useState('');
|
const [idData, setIdData] = useState("");
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
@ -31,16 +40,13 @@ export const CommissionComponent = observer((props) => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleEditButton = (data) => {
|
const handleEditButton = (data) => {
|
||||||
console.log(data, "isi data")
|
console.log(data, "isi data");
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
name: data.name,
|
value: data.commission,
|
||||||
npwp: data.npwp,
|
|
||||||
address: data.address,
|
|
||||||
|
|
||||||
});
|
});
|
||||||
store.commission.visibleModalCommission = true;
|
store.commission.visibleModalCommission = true;
|
||||||
setIdData(data.id);
|
setIdData(data.id);
|
||||||
}
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -49,41 +55,16 @@ export const CommissionComponent = observer((props) => {
|
||||||
key: "name",
|
key: "name",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Npwp",
|
title: "Amount",
|
||||||
dataIndex: "npwp",
|
dataIndex: "commission",
|
||||||
key: "npwp",
|
key: "commission",
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Address",
|
|
||||||
dataIndex: "address",
|
|
||||||
key: "address",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Status",
|
|
||||||
dataIndex: "status",
|
|
||||||
key: "status",
|
|
||||||
render: (text, record) => (
|
|
||||||
<Tag
|
|
||||||
color={record?.status === true ? "processing" : "#E3E8EE"}
|
|
||||||
style={{ color: "#4F566B" }}
|
|
||||||
>
|
|
||||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
|
||||||
</Tag>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Action",
|
title: "Action",
|
||||||
key: "action",
|
key: "action",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Button
|
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
||||||
onClick={() => handleEditButton(record)}
|
|
||||||
>Edit</Button>
|
|
||||||
<Button
|
|
||||||
onClick={() => handleDelete(record.id)}
|
|
||||||
>
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -101,56 +82,40 @@ export const CommissionComponent = observer((props) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (id) => {
|
const handleCancel = () => {
|
||||||
Modal.confirm({
|
setIdData("");
|
||||||
title: "Are you sure delete this record?",
|
store.commission.visibleModalCommission = false;
|
||||||
icon: <ExclamationCircleOutlined/>,
|
|
||||||
okText: "Yes",
|
|
||||||
okType: "primary",
|
|
||||||
cancelText: "Cancel",
|
|
||||||
onOk() {
|
|
||||||
return deleteData(id);
|
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
console.log("Cancel");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
|
||||||
setIdData('')
|
|
||||||
store.commission.visibleModalCommission = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
console.log(data, "isi data2")
|
console.log(data, "isi data2");
|
||||||
if (idData !== '') {
|
if (idData !== "") {
|
||||||
setConfirmLoading(true);
|
setConfirmLoading(true);
|
||||||
try {
|
try {
|
||||||
await store.commission.update(idData, data)
|
await store.commission.update(idData, data);
|
||||||
message.success("Success Update Data Member")
|
message.success("Success Update Data Member");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error("Failed Update Data Member")
|
message.error("Failed Update Data Member");
|
||||||
}
|
}
|
||||||
setConfirmLoading(false);
|
setConfirmLoading(false);
|
||||||
store.commission.visibleModalCommission = false;
|
store.commission.visibleModalCommission = false;
|
||||||
setIdData('');
|
setIdData("");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
} else {
|
} else {
|
||||||
setConfirmLoading(true);
|
setConfirmLoading(true);
|
||||||
try {
|
try {
|
||||||
await store.commission.create(data)
|
await store.commission.create(data);
|
||||||
message.success("Success Add New Member")
|
message.success("Success Add New Member");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e, "apa errornya")
|
console.log(e, "apa errornya");
|
||||||
message.error("Failed Add Member")
|
message.error("Failed Add Member");
|
||||||
}
|
}
|
||||||
setConfirmLoading(false);
|
setConfirmLoading(false);
|
||||||
store.commission.visibleModalCommission = false;
|
store.commission.visibleModalCommission = false;
|
||||||
setIdData('');
|
setIdData("");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -164,7 +129,7 @@ export const CommissionComponent = observer((props) => {
|
||||||
total: store.product.total_data,
|
total: store.product.total_data,
|
||||||
current: store.product.page + 1,
|
current: store.product.page + 1,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
simple: false
|
simple: false,
|
||||||
}}
|
}}
|
||||||
onChange={async (page) => {
|
onChange={async (page) => {
|
||||||
let pageNumber = page.current;
|
let pageNumber = page.current;
|
||||||
|
@ -189,7 +154,7 @@ export const CommissionComponent = observer((props) => {
|
||||||
form
|
form
|
||||||
.validateFields()
|
.validateFields()
|
||||||
.then((values) => {
|
.then((values) => {
|
||||||
console.log(values, "isi form")
|
console.log(values, "isi form");
|
||||||
handleSubmit(values);
|
handleSubmit(values);
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
})
|
})
|
||||||
|
@ -198,42 +163,11 @@ export const CommissionComponent = observer((props) => {
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form
|
<Form form={form} layout="vertical">
|
||||||
form={form}
|
|
||||||
layout="vertical"
|
|
||||||
>
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="value"
|
||||||
label="Name"
|
label="Commission"
|
||||||
rules={[{required: true, message: 'Please input name!'}]}
|
rules={[{ required: true, message: "Please input commission!" }]}
|
||||||
>
|
|
||||||
<Input/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="owner"
|
|
||||||
label="Owner"
|
|
||||||
rules={[{required: true, message: 'Please input owner!'}]}
|
|
||||||
>
|
|
||||||
<Input/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="password_account"
|
|
||||||
label="Password Account"
|
|
||||||
rules={[{required: true, message: 'Please input password account!'}]}
|
|
||||||
>
|
|
||||||
<Input/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="npwp"
|
|
||||||
label="Npwp"
|
|
||||||
rules={[{required: true, message: 'Please input npwp!'}]}
|
|
||||||
>
|
|
||||||
<Input/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="address"
|
|
||||||
label="address"
|
|
||||||
rules={[{required: true, message: 'Please input password!'}]}
|
|
||||||
>
|
>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
|
@ -1,43 +1,23 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import {
|
import { Button, Form, Input, message, Modal, Space, Table, Tag } from "antd";
|
||||||
Button,
|
|
||||||
Form,
|
|
||||||
Input,
|
|
||||||
message,
|
|
||||||
Modal,
|
|
||||||
Select,
|
|
||||||
Space,
|
|
||||||
Table,
|
|
||||||
Tag,
|
|
||||||
} from "antd";
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
import { ExclamationCircleOutlined } from "@ant-design/icons";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
import { capitalize } from "lodash";
|
|
||||||
import { useStore } from "../utils/useStore";
|
import { useStore } from "../utils/useStore";
|
||||||
import { LINKS } from "../routes/app";
|
import { LINKS } from "../routes/app";
|
||||||
|
import { TopupsaldoModal } from "./TopupsaldoModal";
|
||||||
|
|
||||||
export const SupplierComponent = observer((props) => {
|
export const SupplierComponent = observer((props) => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
//const [formEdit] = Form.useForm();
|
|
||||||
const { Option } = Select;
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [idData, setIdData] = useState("");
|
const [idData, setIdData] = useState("");
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [code, setCode] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
try {
|
|
||||||
setIsLoading(true);
|
|
||||||
await store.supplier.getData();
|
await store.supplier.getData();
|
||||||
setIsLoading(false);
|
|
||||||
} catch (e) {
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -52,6 +32,14 @@ export const SupplierComponent = observer((props) => {
|
||||||
setIdData(data.id);
|
setIdData(data.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleTopup = (data) => {
|
||||||
|
console.log(data, "isi data");
|
||||||
|
form.setFieldsValue({
|
||||||
|
code: data.code,
|
||||||
|
});
|
||||||
|
store.supplier.visibleModalTransaction = true;
|
||||||
|
setCode(data.code);
|
||||||
|
};
|
||||||
const changeStatus = async (id, isActive) => {
|
const changeStatus = async (id, isActive) => {
|
||||||
const status = isActive ? "inactive" : "active";
|
const status = isActive ? "inactive" : "active";
|
||||||
const status2 = isActive ? "Inactivating" : "Activating";
|
const status2 = isActive ? "Inactivating" : "Activating";
|
||||||
|
@ -78,6 +66,12 @@ export const SupplierComponent = observer((props) => {
|
||||||
dataIndex: "code",
|
dataIndex: "code",
|
||||||
key: "code",
|
key: "code",
|
||||||
},
|
},
|
||||||
|
,
|
||||||
|
{
|
||||||
|
title: "Saldo",
|
||||||
|
dataIndex: "saldo",
|
||||||
|
key: "saldo",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Status",
|
title: "Status",
|
||||||
dataIndex: "status",
|
dataIndex: "status",
|
||||||
|
@ -85,8 +79,7 @@ export const SupplierComponent = observer((props) => {
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Tag
|
<Tag
|
||||||
color={record?.status === true ? "processing" : "#E3E8EE"}
|
color={record?.status === true ? "processing" : "#E3E8EE"}
|
||||||
style={{ color: "#4F566B", cursor: "pointer" }}
|
style={{ color: "#4F566B"}}
|
||||||
onClick={() => changeStatus(record?.id, record?.status)}
|
|
||||||
>
|
>
|
||||||
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
{record?.status === true ? " ACTIVE" : "INACTIVE"}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
@ -98,7 +91,13 @@ export const SupplierComponent = observer((props) => {
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
||||||
<Button onClick={() => handleDelete(record.id)}>Delete</Button>
|
<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>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -140,7 +139,6 @@ export const SupplierComponent = observer((props) => {
|
||||||
const handleSubmit = async (data) => {
|
const handleSubmit = async (data) => {
|
||||||
console.log(data, "isi data2");
|
console.log(data, "isi data2");
|
||||||
if (idData !== "") {
|
if (idData !== "") {
|
||||||
setConfirmLoading(true);
|
|
||||||
try {
|
try {
|
||||||
await store.supplier.update(idData, data);
|
await store.supplier.update(idData, data);
|
||||||
message.success("Success Update Data Member");
|
message.success("Success Update Data Member");
|
||||||
|
@ -148,21 +146,19 @@ export const SupplierComponent = observer((props) => {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error("Failed Update Data Member");
|
message.error("Failed Update Data Member");
|
||||||
}
|
}
|
||||||
setConfirmLoading(false);
|
|
||||||
store.supplier.visibleModalSupplier = false;
|
store.supplier.visibleModalSupplier = false;
|
||||||
setIdData("");
|
setIdData("");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
} else {
|
} else {
|
||||||
setConfirmLoading(true);
|
|
||||||
try {
|
try {
|
||||||
await store.supplier.create(data);
|
await store.supplier.create(data);
|
||||||
message.success("Success Add New Member");
|
message.success("Success Add New Member");
|
||||||
//await store.supplier.getData()
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e, "apa errornya");
|
console.log(e, "apa errornya");
|
||||||
message.error("Failed Add Member");
|
message.error("Failed Add Member");
|
||||||
}
|
}
|
||||||
setConfirmLoading(false);
|
|
||||||
store.supplier.visibleModalSupplier = false;
|
store.supplier.visibleModalSupplier = false;
|
||||||
setIdData("");
|
setIdData("");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
@ -187,12 +183,9 @@ export const SupplierComponent = observer((props) => {
|
||||||
let pageNumber = page.current;
|
let pageNumber = page.current;
|
||||||
store.supplier.pageSize = page.pageSize;
|
store.supplier.pageSize = page.pageSize;
|
||||||
store.supplier.page = pageNumber - 1;
|
store.supplier.page = pageNumber - 1;
|
||||||
// store.membership.isLoading = true;
|
|
||||||
await store.supplier.getData();
|
await store.supplier.getData();
|
||||||
// store.membership.isLoading = false;
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
visible={store.supplier.visibleModalSupplier}
|
visible={store.supplier.visibleModalSupplier}
|
||||||
title={idData ? "Edit Supplier" : "Create a new Supplier"}
|
title={idData ? "Edit Supplier" : "Create a new Supplier"}
|
||||||
|
@ -232,6 +225,7 @@ export const SupplierComponent = observer((props) => {
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<TopupsaldoModal code={code} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
74
src/component/TopupsaldoModal.js
Normal file
74
src/component/TopupsaldoModal.js
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
import React from "react";
|
||||||
|
import { Form, Input, message, Modal } from "antd";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { useStore } from "../utils/useStore";
|
||||||
|
|
||||||
|
export const TopupsaldoModal = observer((props) => {
|
||||||
|
const store = useStore();
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
|
const handleCancelTransaction = () => {
|
||||||
|
store.supplier.visibleModalTransaction = false;
|
||||||
|
};
|
||||||
|
const handleSubmitTransaction = async (data) => {
|
||||||
|
console.log(data, "isi data2");
|
||||||
|
|
||||||
|
try {
|
||||||
|
await store.supplier.createTransaction(data);
|
||||||
|
message.success("Success Top Up");
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e, "apa errornya");
|
||||||
|
message.error("Failed Top Up");
|
||||||
|
}
|
||||||
|
|
||||||
|
store.supplier.visibleModalTransaction = false;
|
||||||
|
form.resetFields();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<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"
|
||||||
|
initialValues={{ supplier: props.code }}
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
);
|
||||||
|
});
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Button, Card, Col, Input, Row, Tabs } from "antd";
|
import { Button, Card, Col, Input, Row, Tabs } from "antd";
|
||||||
import {FilterOutlined, PlusSquareOutlined,} from "@ant-design/icons";
|
import { FilterOutlined, PlusSquareOutlined } from "@ant-design/icons";
|
||||||
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||||
import { useStore } from "../../utils/useStore";
|
import { useStore } from "../../utils/useStore";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
@ -29,11 +29,6 @@ export const Commission = observer(() => {
|
||||||
init();
|
init();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// const handleChangeTabPane = async (key) => {
|
|
||||||
// store.product.filterCategory = key;
|
|
||||||
// console.log(key);
|
|
||||||
// };
|
|
||||||
|
|
||||||
const routeData = [
|
const routeData = [
|
||||||
{
|
{
|
||||||
route: LINKS.HOME,
|
route: LINKS.HOME,
|
||||||
|
@ -41,7 +36,7 @@ export const Commission = observer(() => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: LINKS.COMMISSION,
|
route: LINKS.COMMISSION,
|
||||||
name: <span style={{fontWeight: 'bold'}}>Commission</span>,
|
name: <span style={{ fontWeight: "bold" }}>Commission</span>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -49,14 +44,14 @@ export const Commission = observer(() => {
|
||||||
<div className={["ppob-container"].join(" ")}>
|
<div className={["ppob-container"].join(" ")}>
|
||||||
<BreadcumbComponent data={routeData} />
|
<BreadcumbComponent data={routeData} />
|
||||||
<Card>
|
<Card>
|
||||||
<Row style={{marginBottom: 20}}>
|
{/* <Row style={{ marginBottom: 20 }}> */}
|
||||||
<Col span={12}>
|
{/* <Col span={12}>
|
||||||
<Button>
|
<Button>
|
||||||
<FilterOutlined />
|
<FilterOutlined />
|
||||||
Filter
|
Filter
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col> */}
|
||||||
<Col span={12} style={{textAlign: "right"}}>
|
{/* <Col span={24} style={{ textAlign: "right" }}>
|
||||||
<Search
|
<Search
|
||||||
placeholder="input search text"
|
placeholder="input search text"
|
||||||
style={{
|
style={{
|
||||||
|
@ -65,25 +60,13 @@ export const Commission = observer(() => {
|
||||||
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 0,
|
marginBottom: store.ui.mediaQuery.isMobile ? 10 : 0,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => store.partner.visibleModalPartner = true}>
|
<Button onClick={() => (store.commission.visibleModalCommission = true)}>
|
||||||
<PlusSquareOutlined /> New
|
<PlusSquareOutlined /> New
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row> */}
|
||||||
<Tabs
|
<div style={{marginTop:20}}> <CommissionComponent/></div>
|
||||||
//onChange={handleChangeTabPane}
|
|
||||||
size="default"
|
|
||||||
tabBarGutter="50"
|
|
||||||
>
|
|
||||||
|
|
||||||
<TabPane
|
|
||||||
tab="Commision"
|
|
||||||
key="1"
|
|
||||||
>
|
|
||||||
<CommissionComponent/>
|
|
||||||
</TabPane>
|
|
||||||
))
|
|
||||||
</Tabs>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -47,28 +47,6 @@ export const Supplier = observer(() => {
|
||||||
init();
|
init();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// const handleChangeTabPane = async (key) => {
|
|
||||||
// store.product.filterCategory = key;
|
|
||||||
// console.log(key);
|
|
||||||
// };
|
|
||||||
const handleCancelTransaction = () => {
|
|
||||||
store.supplier.visibleModalTransaction = false;
|
|
||||||
};
|
|
||||||
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();
|
|
||||||
};
|
|
||||||
const routeData = [
|
const routeData = [
|
||||||
{
|
{
|
||||||
route: LINKS.HOME,
|
route: LINKS.HOME,
|
||||||
|
@ -85,13 +63,13 @@ export const Supplier = observer(() => {
|
||||||
<BreadcumbComponent data={routeData} />
|
<BreadcumbComponent data={routeData} />
|
||||||
<Card>
|
<Card>
|
||||||
<Row style={{ marginBottom: 20 }}>
|
<Row style={{ marginBottom: 20 }}>
|
||||||
<Col span={12}>
|
{/* <Col span={12}>
|
||||||
<Button>
|
<Button>
|
||||||
<FilterOutlined />
|
<FilterOutlined />
|
||||||
Filter
|
Filter
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col> */}
|
||||||
<Col span={12} style={{ textAlign: "right" }}>
|
<Col span={24} style={{ textAlign: "right" }}>
|
||||||
<Search
|
<Search
|
||||||
placeholder="input search text"
|
placeholder="input search text"
|
||||||
style={{
|
style={{
|
||||||
|
@ -102,76 +80,14 @@ export const Supplier = observer(() => {
|
||||||
onSearch={(value) => console.log(value)}
|
onSearch={(value) => console.log(value)}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
//style={{ marginLeft: "10px" }}
|
|
||||||
onClick={() => (store.supplier.visibleModalSupplier = true)}
|
onClick={() => (store.supplier.visibleModalSupplier = true)}
|
||||||
>
|
>
|
||||||
<PlusSquareOutlined /> New
|
<PlusSquareOutlined /> New
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Col span={24} style={{ textAlign: "right" }}>
|
|
||||||
<Button
|
|
||||||
onClick={() => (store.supplier.visibleModalTransaction = true)}
|
|
||||||
>
|
|
||||||
<DownloadOutlined /> Top Up Saldo
|
|
||||||
</Button>
|
|
||||||
</Col>
|
|
||||||
<Tabs
|
|
||||||
//onChange={handleChangeTabPane}
|
|
||||||
size="default"
|
|
||||||
tabBarGutter="50"
|
|
||||||
>
|
|
||||||
<TabPane tab="Supplier" key="1">
|
|
||||||
<SupplierComponent />
|
<SupplierComponent />
|
||||||
</TabPane>
|
|
||||||
))
|
|
||||||
</Tabs>
|
|
||||||
</Card>
|
</Card>
|
||||||
<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!" }]}
|
|
||||||
>
|
|
||||||
<Select placeholder="Select Code Supplier" allowClear>
|
|
||||||
{store.supplier.data.map((item) => (
|
|
||||||
<Option value={item.code} key={item.code}>
|
|
||||||
{item.code}
|
|
||||||
</Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="amount"
|
|
||||||
label="Amount"
|
|
||||||
rules={[{ required: true, message: "Please input amount!" }]}
|
|
||||||
>
|
|
||||||
<Input />
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,8 @@ import {
|
||||||
Space,
|
Space,
|
||||||
Table,
|
Table,
|
||||||
Tag,
|
Tag,
|
||||||
|
Form,
|
||||||
|
Select,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import { useStore } from "../../utils/useStore";
|
import { useStore } from "../../utils/useStore";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
@ -19,14 +21,16 @@ import {
|
||||||
ExclamationCircleOutlined,
|
ExclamationCircleOutlined,
|
||||||
FilterOutlined,
|
FilterOutlined,
|
||||||
PlusSquareOutlined,
|
PlusSquareOutlined,
|
||||||
|
DownloadOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { MembershipModal } from "./MembershipModal";
|
import { MembershipModal } from "./MembershipModal";
|
||||||
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
import { BreadcumbComponent } from "../../component/BreadcumbComponent";
|
||||||
import { LINKS } from "../../routes/app";
|
import { LINKS } from "../../routes/app";
|
||||||
|
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
|
const { Option } = Select;
|
||||||
export const Membership = observer(() => {
|
export const Membership = observer(() => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [visibleModal, setVisibleModal] = useState(false);
|
const [visibleModal, setVisibleModal] = useState(false);
|
||||||
const [initialData, setInitialData] = useState({});
|
const [initialData, setInitialData] = useState({});
|
||||||
|
@ -62,6 +66,24 @@ export const Membership = observer(() => {
|
||||||
message.error(`Failed ${status2} Membership`);
|
message.error(`Failed ${status2} Membership`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const handleCancelTransaction = () => {
|
||||||
|
store.supplier.visibleModalTransaction = false;
|
||||||
|
};
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -219,6 +241,19 @@ export const Membership = observer(() => {
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Col
|
||||||
|
span={24}
|
||||||
|
style={{
|
||||||
|
textAlign: "right",
|
||||||
|
marginBottom: store.ui.mediaQuery.isMobile ? 30 : 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={() => (store.supplier.visibleModalTransaction = true)}
|
||||||
|
>
|
||||||
|
<DownloadOutlined /> Top Up Saldo
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
{store.ui.mediaQuery.isDesktop && (
|
{store.ui.mediaQuery.isDesktop && (
|
||||||
<Table
|
<Table
|
||||||
key="1"
|
key="1"
|
||||||
|
@ -306,6 +341,51 @@ export const Membership = observer(() => {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
<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!" }]}
|
||||||
|
>
|
||||||
|
<Select placeholder="Select Code Supplier" allowClear>
|
||||||
|
{store.supplier.data.map((item) => (
|
||||||
|
<Option value={item.code} key={item.code}>
|
||||||
|
{item.code}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="amount"
|
||||||
|
label="Amount"
|
||||||
|
rules={[{ required: true, message: "Please input amount!" }]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
<MembershipModal
|
<MembershipModal
|
||||||
visible={visibleModal}
|
visible={visibleModal}
|
||||||
confirmLoading={confirmLoading}
|
confirmLoading={confirmLoading}
|
||||||
|
|
|
@ -7,7 +7,7 @@ export class Commission {
|
||||||
data = [];
|
data = [];
|
||||||
total_data = 0;
|
total_data = 0;
|
||||||
filterCategory = null;
|
filterCategory = null;
|
||||||
visibleModalSupplier = false;
|
visibleModalCommission = false;
|
||||||
|
|
||||||
pageCategories = 0;
|
pageCategories = 0;
|
||||||
pageSizeCategories = 10
|
pageSizeCategories = 10
|
||||||
|
@ -37,7 +37,7 @@ export class Commission {
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(id, data) {
|
async update(id, data) {
|
||||||
const response = await http.put(`/product/${id}`).send(data);
|
const response = await http.put(`/config/commission/${id}`).send(data);
|
||||||
await this.getData();
|
await this.getData();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user