Perbaikan Project PPOB
This commit is contained in:
@@ -104,15 +104,15 @@ export const Membership = observer(() => {
|
||||
: (response = await store.transaction.distribute(data));
|
||||
|
||||
response?.body?.statusCode === 201
|
||||
? message.success("Success Top Up")
|
||||
: message.error("Failed Top Up");
|
||||
? message.success("Sukses Top Up")
|
||||
: message.error("Saldo Tidak Mencukupi");
|
||||
|
||||
modalLoader.setLoading(false);
|
||||
await getData();
|
||||
} catch (e) {
|
||||
console.log(e, "apa errornya");
|
||||
modalLoader.setLoading(false);
|
||||
message.error("Failed Top Up");
|
||||
message.error("Gagal Top Up");
|
||||
}
|
||||
setConfirmLoading(false);
|
||||
setIsVisibleTopUpModal(false);
|
||||
|
||||
@@ -1,107 +1,122 @@
|
||||
import React from "react";
|
||||
import {Form, Input, Modal, Select} from "antd";
|
||||
import {useStore} from "../../utils/useStore";
|
||||
import React, { useState } from "react";
|
||||
import { Form, Input, Modal, Select, InputNumber } from "antd";
|
||||
import { useStore } from "../../utils/useStore";
|
||||
|
||||
export const MembershipModal = ({
|
||||
visible,
|
||||
onCreate,
|
||||
onCancel,
|
||||
initialData,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const {Option} = Select;
|
||||
const store = useStore();
|
||||
visible,
|
||||
onCreate,
|
||||
onCancel,
|
||||
initialData,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const { Option } = Select;
|
||||
const store = useStore();
|
||||
const [value, setValue] = useState();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
title={
|
||||
initialData.isChangePassword
|
||||
? "Change Member Password"
|
||||
: initialData.id
|
||||
? "Edit Member"
|
||||
: "Create a new Membership"
|
||||
}
|
||||
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}
|
||||
>
|
||||
{((initialData.id && !initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="Name"
|
||||
rules={[{required: true, message: "Please input Name!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{!initialData.id && (
|
||||
<Form.Item
|
||||
name="username"
|
||||
label="Username"
|
||||
rules={[{required: true, message: "Please input Username!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{((initialData.id && initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="password"
|
||||
label="Password"
|
||||
rules={[{required: false, message: "Please input password!"}]}
|
||||
>
|
||||
<Input.Password/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{((initialData.id && !initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="phone_number"
|
||||
label="Phone Number"
|
||||
rules={[{required: true, message: "Please input Phone Number!"}]}
|
||||
>
|
||||
<Input/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{((initialData.id && !initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="roleId"
|
||||
label="Role"
|
||||
rules={[{required: true, message: "Please input role id!"}]}
|
||||
>
|
||||
<Select>
|
||||
{store.role.data.map((item) => (
|
||||
<Option key={item.id} value={item.id}>
|
||||
{item.name}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
return (
|
||||
<Modal
|
||||
visible={visible}
|
||||
title={
|
||||
initialData.isChangePassword
|
||||
? "Change Member Password"
|
||||
: initialData.id
|
||||
? "Edit Member"
|
||||
: "Create a new Membership"
|
||||
}
|
||||
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}
|
||||
>
|
||||
{((initialData.id && !initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="Name"
|
||||
rules={[{ required: true, message: "Please input Name!" }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
)}
|
||||
{!initialData.id && (
|
||||
<Form.Item
|
||||
name="username"
|
||||
label="Username"
|
||||
rules={[{ required: true, message: "Please input Username!" }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
)}
|
||||
{((initialData.id && initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="password"
|
||||
label="Password"
|
||||
rules={[{ required: false, message: "Please input password!" }]}
|
||||
>
|
||||
<Input.Password />
|
||||
</Form.Item>
|
||||
)}
|
||||
{((initialData.id && !initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="phone_number"
|
||||
label="Phone Number"
|
||||
rules={[
|
||||
{ required: true, message: "Please input Phone Number!" },
|
||||
{
|
||||
pattern: /^(?:\d*)$/,
|
||||
message: "Value should contain just number",
|
||||
},
|
||||
{
|
||||
pattern: /^[\d]{0,12}$/,
|
||||
message: "Value should be less than 12 character",
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input
|
||||
onChange={(value) => {
|
||||
setValue(value);
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
{((initialData.id && !initialData.isChangePassword) ||
|
||||
!initialData.id) && (
|
||||
<Form.Item
|
||||
name="roleId"
|
||||
label="Role"
|
||||
rules={[{ required: true, message: "Please input role id!" }]}
|
||||
>
|
||||
<Select>
|
||||
{store.role.data.map((item) => (
|
||||
<Option key={item.id} value={item.id}>
|
||||
{item.name}
|
||||
</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user