feat: add Top Up Distribute Admin
This commit is contained in:
parent
5ce366f638
commit
0765b6027d
|
@ -114,7 +114,10 @@ export const PartnerComponent = observer((props) => {
|
||||||
key: "action",
|
key: "action",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Button onClick={() => changeStatus(record?.id, record?.status)}>
|
<Button
|
||||||
|
type={record?.status === true ? "danger" : "primary"}
|
||||||
|
onClick={() => changeStatus(record?.id, record?.status)}
|
||||||
|
>
|
||||||
{record?.status === true ? "Inactive" : "Active"}
|
{record?.status === true ? "Inactive" : "Active"}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
||||||
|
@ -166,10 +169,18 @@ export const PartnerComponent = observer((props) => {
|
||||||
setConfirmLoading(true);
|
setConfirmLoading(true);
|
||||||
try {
|
try {
|
||||||
await store.partner.update(idData, data);
|
await store.partner.update(idData, data);
|
||||||
message.success(isChangePassword ? "Failed Change Partner Password" : "Success Update Data Partner");
|
message.success(
|
||||||
|
isChangePassword
|
||||||
|
? "Failed Change Partner Password"
|
||||||
|
: "Success Update Data Partner"
|
||||||
|
);
|
||||||
//await store.partner.getData()
|
//await store.partner.getData()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(isChangePassword ? "Failed Change Partner Password" : "Failed Update Data Partner");
|
message.error(
|
||||||
|
isChangePassword
|
||||||
|
? "Failed Change Partner Password"
|
||||||
|
: "Failed Update Data Partner"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
setConfirmLoading(false);
|
setConfirmLoading(false);
|
||||||
store.partner.visibleModalPartner = false;
|
store.partner.visibleModalPartner = false;
|
||||||
|
|
|
@ -33,6 +33,8 @@ export const Membership = observer(() => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const [visibleModal, setVisibleModal] = useState(false);
|
const [visibleModal, setVisibleModal] = useState(false);
|
||||||
|
const [isVisibleTopUpModal, setIsVisibleTopUpModal] = useState(false);
|
||||||
|
const [destination, setDestination] = useState(null);
|
||||||
const [initialData, setInitialData] = useState({});
|
const [initialData, setInitialData] = useState({});
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
@ -43,6 +45,7 @@ export const Membership = observer(() => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
await getData();
|
await getData();
|
||||||
store.role.getData();
|
store.role.getData();
|
||||||
|
await store.supplier.getData();
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
@ -53,10 +56,10 @@ export const Membership = observer(() => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getData = () => {
|
const getData = () => {
|
||||||
(store.authentication.userData.role === "Admin")
|
store.authentication.userData.role === "Admin"
|
||||||
? store.membership.getData()
|
? store.membership.getData()
|
||||||
: store.membership.getDataBySuperior();
|
: store.membership.getDataBySuperior();
|
||||||
}
|
};
|
||||||
|
|
||||||
const changeStatus = async (id, isActive) => {
|
const changeStatus = async (id, isActive) => {
|
||||||
const status = isActive ? "inactive" : "active";
|
const status = isActive ? "inactive" : "active";
|
||||||
|
@ -76,13 +79,16 @@ export const Membership = observer(() => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleCancelTransaction = () => {
|
const handleCancelTransaction = () => {
|
||||||
store.supplier.visibleModalTransaction = false;
|
setIsVisibleTopUpModal(false);
|
||||||
|
setDestination(null);
|
||||||
};
|
};
|
||||||
const handleSubmitTransaction = async (data) => {
|
const handleSubmitTransaction = async (data) => {
|
||||||
console.log(data, "isi data2");
|
|
||||||
setConfirmLoading(true);
|
setConfirmLoading(true);
|
||||||
try {
|
try {
|
||||||
await store.supplier.createTransaction(data);
|
let input = data;
|
||||||
|
data.destination = destination;
|
||||||
|
|
||||||
|
await store.transaction.distributeAdmin(data);
|
||||||
message.success("Success Top Up");
|
message.success("Success Top Up");
|
||||||
//await store.supplier.getData()
|
//await store.supplier.getData()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -90,8 +96,9 @@ export const Membership = observer(() => {
|
||||||
message.error("Failed Top Up");
|
message.error("Failed Top Up");
|
||||||
}
|
}
|
||||||
setConfirmLoading(false);
|
setConfirmLoading(false);
|
||||||
store.supplier.visibleModalTransaction = false;
|
setIsVisibleTopUpModal(false);
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
setDestination(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
|
@ -128,9 +135,20 @@ export const Membership = observer(() => {
|
||||||
key: "action",
|
key: "action",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
<Button onClick={() => changeStatus(record?.id, record?.isActive)}>
|
<Button
|
||||||
|
type={record?.status === true ? "danger" : "primary"}
|
||||||
|
onClick={() => changeStatus(record?.id, record?.isActive)}
|
||||||
|
>
|
||||||
{record?.isActive === true ? "Inactive" : "Active"}
|
{record?.isActive === true ? "Inactive" : "Active"}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setDestination(record?.user_detail?.id);
|
||||||
|
setIsVisibleTopUpModal(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DownloadOutlined /> Top Up Saldo
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
let record2 = record;
|
let record2 = record;
|
||||||
|
@ -258,10 +276,10 @@ export const Membership = observer(() => {
|
||||||
<div>
|
<div>
|
||||||
<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={12} style={{ textAlign: "right" }}>
|
||||||
<Search
|
<Search
|
||||||
|
@ -282,19 +300,6 @@ 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"
|
||||||
|
@ -383,7 +388,7 @@ export const Membership = observer(() => {
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
<Modal
|
<Modal
|
||||||
visible={store.supplier.visibleModalTransaction}
|
visible={isVisibleTopUpModal}
|
||||||
title="Top Up Saldo"
|
title="Top Up Saldo"
|
||||||
okText="Top Up"
|
okText="Top Up"
|
||||||
cancelText="Cancel"
|
cancelText="Cancel"
|
||||||
|
|
|
@ -76,6 +76,16 @@ export class Transaction {
|
||||||
await this.getData();
|
await this.getData();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async distribute(data) {
|
||||||
|
const response = await http.post('/transaction/distribute').send(data);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
async distributeAdmin(data) {
|
||||||
|
const response = await http.post('/transaction/distribute-admin').send(data);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user