Merge branch 'devops-staging' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend
This commit is contained in:
commit
3b7ccd8214
|
@ -380,11 +380,11 @@ export const DetailUser = observer(() => {
|
||||||
const handleSubmitFilter = async () => {
|
const handleSubmitFilter = async () => {
|
||||||
const data = form.getFieldsValue();
|
const data = form.getFieldsValue();
|
||||||
store.transaction.filterStart = moment(data.start_date).format(
|
store.transaction.filterStart = moment(data.start_date).format(
|
||||||
"YYYY-MM-DD HH:mm:ss"
|
"YYYY-MM-DD"
|
||||||
);
|
) + " 00:00:00";
|
||||||
store.transaction.filterEnd = moment(data.end_date).format(
|
store.transaction.filterEnd = moment(data.end_date).format(
|
||||||
"YYYY-MM-DD HH:mm:ss"
|
"YYYY-MM-DD"
|
||||||
);
|
) + " 23:59:59";
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
actionFilter === true
|
actionFilter === true
|
||||||
? await store.transaction.getDataHistoryTopUp(id)
|
? await store.transaction.getDataHistoryTopUp(id)
|
||||||
|
|
|
@ -108,11 +108,11 @@ export const Profile = observer(() => {
|
||||||
const handleSubmitFilter = async () => {
|
const handleSubmitFilter = async () => {
|
||||||
const data = form.getFieldsValue();
|
const data = form.getFieldsValue();
|
||||||
store.transaction.filterStart = moment(data.start_date).format(
|
store.transaction.filterStart = moment(data.start_date).format(
|
||||||
"YYYY-MM-DD HH:mm:ss"
|
"YYYY-MM-DD"
|
||||||
);
|
) + " 00:00:00";
|
||||||
store.transaction.filterEnd = moment(data.end_date).format(
|
store.transaction.filterEnd = moment(data.end_date).format(
|
||||||
"YYYY-MM-DD HH:mm:ss"
|
"YYYY-MM-DD"
|
||||||
);
|
) + " 23:59:59";
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
// actionFilter === true
|
// actionFilter === true
|
||||||
// ? await store.transaction.getDataHistoryTopUpProfile(
|
// ? await store.transaction.getDataHistoryTopUpProfile(
|
||||||
|
@ -337,14 +337,14 @@ export const Profile = observer(() => {
|
||||||
color={
|
color={
|
||||||
record.status === "SUCCESS"
|
record.status === "SUCCESS"
|
||||||
? "success"
|
? "success"
|
||||||
: record.status === 0
|
: record.status === "PENDING"
|
||||||
? "warning"
|
? "warning"
|
||||||
: "processing"
|
: "processing"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{record.status === "SUCCESS"
|
{record.status === "SUCCESS"
|
||||||
? "Sukses"
|
? "Sukses"
|
||||||
: record.status === 0
|
: record.status === "PENDING"
|
||||||
? "Dalam Proses"
|
? "Dalam Proses"
|
||||||
: "Gagal"}
|
: "Gagal"}
|
||||||
</Tag>
|
</Tag>
|
||||||
|
|
|
@ -21,7 +21,11 @@ export const Product = observer(() => {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const modalLoader = useContext(ModalLoaderContext);
|
const modalLoader = useContext(ModalLoaderContext);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const [formBuyPostPaid] = Form.useForm();
|
||||||
|
const [formBill] = Form.useForm();
|
||||||
const [visibleModalBuy, setVisibleModalBuy] = useState(false);
|
const [visibleModalBuy, setVisibleModalBuy] = useState(false);
|
||||||
|
const [visibleModalBill, setVisibleModalBill] = useState(false);
|
||||||
|
const [visibleModalBuyPostpaid, setVisibleModalBuyPostpaid] = useState(false);
|
||||||
const [barang, setBarang] = useState({});
|
const [barang, setBarang] = useState({});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -53,19 +57,80 @@ export const Product = observer(() => {
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBuyProduct = async (data, productCode, productId) => {
|
const handleBuyProduct = async (data, productCode, productId, productType, billTrxId) => {
|
||||||
|
modalLoader.setLoading(true);
|
||||||
|
if (productType == "prepaid") {
|
||||||
|
try {
|
||||||
|
const response = await store.transaction.buyProd({
|
||||||
|
...data,
|
||||||
|
productCode: productCode,
|
||||||
|
productId: productId
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 201) {
|
||||||
|
message.success(response?.body?.message || "Berhasil Beli Produk");
|
||||||
|
} else {
|
||||||
|
message.error(response?.body?.error || "Gagal Beli Produk", 3);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("testingan");
|
||||||
|
console.log(e.response, "testingan");
|
||||||
|
console.log(e.result, "testingan1");
|
||||||
|
if (e.response?.body?.error) {
|
||||||
|
message.error(e.response.body.error);
|
||||||
|
setVisibleModalBuy(false);
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(e, "apa errornya");
|
||||||
|
message.error("Gagal Beli Product");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const response = await store.transaction.buyProd({
|
||||||
|
...data,
|
||||||
|
productCode: productCode,
|
||||||
|
productId: productId,
|
||||||
|
billTrxId: billTrxId
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 201) {
|
||||||
|
message.success(response?.body?.message || "Berhasil Bayar Produk");
|
||||||
|
} else {
|
||||||
|
message.error(response?.body?.error || "Gagal Bayar Produk", 3);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("testingan");
|
||||||
|
console.log(e.response, "testingan");
|
||||||
|
console.log(e.result, "testingan1");
|
||||||
|
if (e.response?.body?.error) {
|
||||||
|
message.error(e.response.body.error);
|
||||||
|
setVisibleModalBuy(false);
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(e, "apa errornya");
|
||||||
|
message.error("Gagal Bayar Product");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setVisibleModalBuyPostpaid(false)
|
||||||
|
setVisibleModalBuy(false);
|
||||||
|
modalLoader.setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCheckBill = async (data, productCode, productId) => {
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await store.transaction.buyProd({
|
const response = await store.transaction.checkBill({
|
||||||
...data,
|
...data,
|
||||||
productCode: productCode,
|
productCode: productCode,
|
||||||
productId: productId
|
productId: productId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.status === 201) {
|
if (response.status === 201) {
|
||||||
message.success(response?.body?.message || "Berhasil Beli Produk");
|
message.success(response?.body?.message || "Berhasil Cek Produk");
|
||||||
} else {
|
} else {
|
||||||
message.error(response?.body?.error || "Gagal Beli Produk", 3);
|
message.error(response?.body?.error || "Gagal Cek Produk", 3);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("testingan");
|
console.log("testingan");
|
||||||
|
@ -78,9 +143,9 @@ export const Product = observer(() => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(e, "apa errornya");
|
console.log(e, "apa errornya");
|
||||||
message.error("Gagal Beli Product");
|
message.error("Gagal Cek Product");
|
||||||
}
|
}
|
||||||
setVisibleModalBuy(false);
|
setVisibleModalBill(false);
|
||||||
modalLoader.setLoading(false);
|
modalLoader.setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -164,7 +229,11 @@ export const Product = observer(() => {
|
||||||
<Col key={index} xs={24} md={16} lg={8}>
|
<Col key={index} xs={24} md={16} lg={8}>
|
||||||
<Card
|
<Card
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setVisibleModalBuy(true);
|
if (item.product_type == "prepaid") {
|
||||||
|
setVisibleModalBuy(true);
|
||||||
|
} else {
|
||||||
|
setVisibleModalBuyPostpaid(true)
|
||||||
|
}
|
||||||
setBarang(item);
|
setBarang(item);
|
||||||
}}
|
}}
|
||||||
hoverable
|
hoverable
|
||||||
|
@ -220,16 +289,16 @@ export const Product = observer(() => {
|
||||||
marginRight:10
|
marginRight:10
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
form
|
form
|
||||||
.validateFields()
|
.validateFields()
|
||||||
.then((values) => {
|
.then((values) => {
|
||||||
console.log(values, "isi form");
|
console.log(values, "isi form");
|
||||||
handleBuyProduct(values, barang.product_code, barang.product_id);
|
handleBuyProduct(values, barang.product_code, barang.product_id, barang.product_type, "");
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
})
|
})
|
||||||
.catch((info) => {
|
.catch((info) => {
|
||||||
console.error("Validate Failed:", info);
|
console.error("Validate Failed:", info);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Beli
|
Beli
|
||||||
|
@ -254,6 +323,7 @@ export const Product = observer(() => {
|
||||||
// </Button>,
|
// </Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Form form={form} layout="vertical">
|
<Form form={form} layout="vertical">
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="destination"
|
name="destination"
|
||||||
|
@ -277,6 +347,202 @@ export const Product = observer(() => {
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
visible={visibleModalBuyPostpaid}
|
||||||
|
title={`Apakah anda yakin membeli ${barang?.product_name}?`}
|
||||||
|
okText={"Confirm"}
|
||||||
|
onCancel={() => {
|
||||||
|
formBuyPostPaid.resetFields();
|
||||||
|
setVisibleModalBuyPostpaid(false);
|
||||||
|
}}
|
||||||
|
// footer={footerLayoutFilter}
|
||||||
|
footer={[
|
||||||
|
<Button
|
||||||
|
key="back"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#e74e5e",
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
formBuyPostPaid.resetFields();
|
||||||
|
setVisibleModalBuyPostpaid(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>,
|
||||||
|
<Button
|
||||||
|
key="Beli"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#4e79e7",
|
||||||
|
color: "#fff",
|
||||||
|
marginRight:10
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
formBuyPostPaid
|
||||||
|
.validateFields()
|
||||||
|
.then((destination, billTrxId) => {
|
||||||
|
console.log(destination, "isi form");
|
||||||
|
handleBuyProduct(destination, barang.product_code, barang.product_id, barang.product_type, billTrxId);
|
||||||
|
formBuyPostPaid.resetFields();
|
||||||
|
setVisibleModalBuyPostpaid(false);
|
||||||
|
})
|
||||||
|
.catch((info) => {
|
||||||
|
console.error("Validate Failed:", info);
|
||||||
|
});
|
||||||
|
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Beli
|
||||||
|
</Button>,
|
||||||
|
// <Button
|
||||||
|
// key="Beli Stag"
|
||||||
|
// type="primary"
|
||||||
|
// onClick={() => {
|
||||||
|
// form
|
||||||
|
// .validateFields()
|
||||||
|
// .then((values) => {
|
||||||
|
// console.log(values, "isi form");
|
||||||
|
// handleBuyStag(values, barang.product_code);
|
||||||
|
// form.resetFields();
|
||||||
|
// })
|
||||||
|
// .catch((info) => {
|
||||||
|
// console.error("Validate Failed:", info);
|
||||||
|
// });
|
||||||
|
// }}
|
||||||
|
// >
|
||||||
|
// Beli Staging
|
||||||
|
// </Button>,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Row
|
||||||
|
justify={"end"}
|
||||||
|
align={"end"}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setVisibleModalBill(true);
|
||||||
|
setVisibleModalBuyPostpaid(false)
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#4e79e7",
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cek Bill Postpaid
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
<Form form={formBuyPostPaid} layout="vertical">
|
||||||
|
<Form.Item
|
||||||
|
name="destination"
|
||||||
|
label="Nomor Tujuan"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "Tolong masukan nomor tujuan!",
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// pattern: /^(?:\d*)$/,
|
||||||
|
// message: "Value should contain just number",
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// pattern: /^[\d]{1,12}$/,
|
||||||
|
// message: "Value should be 1 - 12 character",
|
||||||
|
// },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
name="bill_trx_id"
|
||||||
|
label="Id Transaksi"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "Tolong masukan Id Transaksi!",
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
visible={visibleModalBill}
|
||||||
|
title={`Cek Bill ${barang?.product_name}`}
|
||||||
|
okText={"Confirm"}
|
||||||
|
onCancel={() => {
|
||||||
|
formBill.resetFields();
|
||||||
|
setVisibleModalBill(false);
|
||||||
|
}}
|
||||||
|
// footer={footerLayoutFilter}
|
||||||
|
footer={[
|
||||||
|
<Button
|
||||||
|
key="back"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#e74e5e",
|
||||||
|
color: "#fff",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
formBill.resetFields();
|
||||||
|
setVisibleModalBill(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>,
|
||||||
|
<Button
|
||||||
|
key="Cek"
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#4e79e7",
|
||||||
|
color: "#fff",
|
||||||
|
marginRight:10
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
formBill
|
||||||
|
.validateFields()
|
||||||
|
.then((values) => {
|
||||||
|
console.log(values, "isi form");
|
||||||
|
handleCheckBill(values, barang.product_code, barang.product_id)
|
||||||
|
formBill.resetFields();
|
||||||
|
setVisibleModalBill(false);
|
||||||
|
})
|
||||||
|
.catch((info) => {
|
||||||
|
console.error("Validate Failed:", info);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cek Bill
|
||||||
|
</Button>
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Form form={formBill} layout="vertical">
|
||||||
|
<Form.Item
|
||||||
|
name="destination"
|
||||||
|
label="Nomor Tujuan"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: "Tolong masukan nomor tujuan!",
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// pattern: /^(?:\d*)$/,
|
||||||
|
// message: "Value should contain just number",
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// pattern: /^[\d]{1,12}$/,
|
||||||
|
// message: "Value should be 1 - 12 character",
|
||||||
|
// },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -222,6 +222,12 @@ export class Transaction {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async checkBill(data) {
|
||||||
|
const response = await http.post("/transaction/check-bill").send(data);
|
||||||
|
console.log(response)
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
async update(id, data) {
|
async update(id, data) {
|
||||||
try {
|
try {
|
||||||
const response = await http.put(`/product/${id}`).send(data);
|
const response = await http.put(`/product/${id}`).send(data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user