This commit is contained in:
2021-12-15 18:32:42 +07:00
7 changed files with 227 additions and 136 deletions

View File

@@ -40,6 +40,21 @@ export const PartnerComponent = observer((props) => {
init();
}, []);
const changeStatus = async (id, isActive) => {
const status = isActive ? "inactive" : "active";
const status2 = isActive ? "Inactivating" : "Activating";
try {
const response = await store.partner.changeStatus(id, status);
response?.body?.statusCode === 201
? message.success(`Success ${status2} Partner`)
: message.error(`Failed ${status2} Partner`);
} catch (err) {
console.log("error", err);
message.error(`Failed ${status2} Partner`);
}
};
const handleEditButton = (data) => {
console.log(data, "isi data");
form.setFieldsValue({
@@ -72,9 +87,13 @@ export const PartnerComponent = observer((props) => {
dataIndex: "status",
key: "status",
render: (text, record) => (
<Button size="small" type={record?.status === true ? "primary" : "danger"}>
{record?.status === true ? " ACTIVE" : "INACTIVE"}
</Button>
<Tag
color={record?.status === true ? "processing" : "#E3E8EE"}
style={{ color: "#4F566B", cursor: 'pointer' }}
onClick={() => changeStatus(record?.id, record?.status)}
>
{record?.status === true ? " ACTIVE" : "INACTIVE"}
</Tag>
),
},
{

View File

@@ -52,9 +52,19 @@ export const SupplierComponent = observer((props) => {
setIdData(data.id);
};
const changeStatus = (id, isActive) => {
const changeStatus = async (id, isActive) => {
const status = isActive ? "inactive" : "active";
store.supplier.changeStatus(id, status);
const status2 = isActive ? "Inactivating" : "Activating";
try {
const response = await store.supplier.changeStatus(id, status);
response?.body?.statusCode === 201
? message.success(`Success ${status2} Supplier`)
: message.error(`Failed ${status2} Supplier`);
} catch (err) {
console.log("error", err);
message.error(`Failed ${status2} Supplier`);
}
};
const columns = [