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",
|
||||
render: (text, record) => (
|
||||
<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"}
|
||||
</Button>
|
||||
<Button onClick={() => handleEditButton(record)}>Edit</Button>
|
||||
|
@ -166,10 +169,18 @@ export const PartnerComponent = observer((props) => {
|
|||
setConfirmLoading(true);
|
||||
try {
|
||||
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()
|
||||
} 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);
|
||||
store.partner.visibleModalPartner = false;
|
||||
|
|
|
@ -33,6 +33,8 @@ export const Membership = observer(() => {
|
|||
const [form] = Form.useForm();
|
||||
const store = useStore();
|
||||
const [visibleModal, setVisibleModal] = useState(false);
|
||||
const [isVisibleTopUpModal, setIsVisibleTopUpModal] = useState(false);
|
||||
const [destination, setDestination] = useState(null);
|
||||
const [initialData, setInitialData] = useState({});
|
||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
@ -43,6 +45,7 @@ export const Membership = observer(() => {
|
|||
setIsLoading(true);
|
||||
await getData();
|
||||
store.role.getData();
|
||||
await store.supplier.getData();
|
||||
setIsLoading(false);
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
|
@ -53,10 +56,10 @@ export const Membership = observer(() => {
|
|||
}, []);
|
||||
|
||||
const getData = () => {
|
||||
(store.authentication.userData.role === "Admin")
|
||||
? store.membership.getData()
|
||||
: store.membership.getDataBySuperior();
|
||||
}
|
||||
store.authentication.userData.role === "Admin"
|
||||
? store.membership.getData()
|
||||
: store.membership.getDataBySuperior();
|
||||
};
|
||||
|
||||
const changeStatus = async (id, isActive) => {
|
||||
const status = isActive ? "inactive" : "active";
|
||||
|
@ -76,13 +79,16 @@ export const Membership = observer(() => {
|
|||
}
|
||||
};
|
||||
const handleCancelTransaction = () => {
|
||||
store.supplier.visibleModalTransaction = false;
|
||||
setIsVisibleTopUpModal(false);
|
||||
setDestination(null);
|
||||
};
|
||||
const handleSubmitTransaction = async (data) => {
|
||||
console.log(data, "isi data2");
|
||||
setConfirmLoading(true);
|
||||
try {
|
||||
await store.supplier.createTransaction(data);
|
||||
let input = data;
|
||||
data.destination = destination;
|
||||
|
||||
await store.transaction.distributeAdmin(data);
|
||||
message.success("Success Top Up");
|
||||
//await store.supplier.getData()
|
||||
} catch (e) {
|
||||
|
@ -90,8 +96,9 @@ export const Membership = observer(() => {
|
|||
message.error("Failed Top Up");
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
store.supplier.visibleModalTransaction = false;
|
||||
setIsVisibleTopUpModal(false);
|
||||
form.resetFields();
|
||||
setDestination(null);
|
||||
};
|
||||
|
||||
const columns = [
|
||||
|
@ -128,9 +135,20 @@ export const Membership = observer(() => {
|
|||
key: "action",
|
||||
render: (text, record) => (
|
||||
<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"}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setDestination(record?.user_detail?.id);
|
||||
setIsVisibleTopUpModal(true);
|
||||
}}
|
||||
>
|
||||
<DownloadOutlined /> Top Up Saldo
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
let record2 = record;
|
||||
|
@ -258,10 +276,10 @@ export const Membership = observer(() => {
|
|||
<div>
|
||||
<Row style={{ marginBottom: 20 }}>
|
||||
<Col span={12}>
|
||||
<Button>
|
||||
{/* <Button>
|
||||
<FilterOutlined />
|
||||
Filter
|
||||
</Button>
|
||||
</Button> */}
|
||||
</Col>
|
||||
<Col span={12} style={{ textAlign: "right" }}>
|
||||
<Search
|
||||
|
@ -282,19 +300,6 @@ export const Membership = observer(() => {
|
|||
</Button>
|
||||
</Col>
|
||||
</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 && (
|
||||
<Table
|
||||
key="1"
|
||||
|
@ -383,7 +388,7 @@ export const Membership = observer(() => {
|
|||
</div>
|
||||
</Card>
|
||||
<Modal
|
||||
visible={store.supplier.visibleModalTransaction}
|
||||
visible={isVisibleTopUpModal}
|
||||
title="Top Up Saldo"
|
||||
okText="Top Up"
|
||||
cancelText="Cancel"
|
||||
|
|
|
@ -76,6 +76,16 @@ export class Transaction {
|
|||
await this.getData();
|
||||
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