Merge branch 'develop' into 'devops-staging'
Hit Api Buy Stagging See merge request empatnusabangsa/ppob/ppob-frontend!43
This commit is contained in:
commit
7b1248fb45
|
@ -54,19 +54,22 @@ export const Product = observer(() => {
|
|||
};
|
||||
|
||||
const handleBuyProduct = async (data, productCode) => {
|
||||
//console.log(data)
|
||||
modalLoader.setLoading(true);
|
||||
try {
|
||||
const response = await store.transaction.buyProd({
|
||||
...data,
|
||||
productCode: productCode,
|
||||
});
|
||||
|
||||
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);
|
||||
|
@ -80,6 +83,36 @@ export const Product = observer(() => {
|
|||
modalLoader.setLoading(false);
|
||||
};
|
||||
|
||||
const handleBuyStag = async (data, productCode) => {
|
||||
modalLoader.setLoading(true);
|
||||
try {
|
||||
const response = await store.transaction.buyProduct({
|
||||
...data,
|
||||
productCode: productCode,
|
||||
});
|
||||
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");
|
||||
}
|
||||
// setDataProd(false);
|
||||
// setDataStag(false);
|
||||
setVisibleModalBuy(false);
|
||||
modalLoader.setLoading(false);
|
||||
};
|
||||
const handleCancel = () => {
|
||||
form.resetFields();
|
||||
setVisibleModalBuy(false);
|
||||
|
@ -178,7 +211,7 @@ export const Product = observer(() => {
|
|||
Cancel
|
||||
</Button>,
|
||||
<Button
|
||||
key="submit"
|
||||
key="Buy Prod"
|
||||
style={{
|
||||
backgroundColor: "#4e79e7",
|
||||
color: "#fff",
|
||||
|
@ -199,11 +232,20 @@ export const Product = observer(() => {
|
|||
Buy Prod
|
||||
</Button>,
|
||||
<Button
|
||||
key="link"
|
||||
href="https://google.com"
|
||||
key="Buy Stag"
|
||||
type="primary"
|
||||
// loading={loading}
|
||||
// onClick={this.handleOk}
|
||||
onClick={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then((values) => {
|
||||
console.log(values, "isi form");
|
||||
handleBuyStag(values, barang.product_code);
|
||||
form.resetFields();
|
||||
})
|
||||
.catch((info) => {
|
||||
console.error("Validate Failed:", info);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Buy Staging
|
||||
</Button>,
|
||||
|
|
|
@ -175,12 +175,9 @@ export class Transaction {
|
|||
}
|
||||
|
||||
async buyProduct(data) {
|
||||
try {
|
||||
const response = await http.post("/transaction/order").send(data);
|
||||
console.log(response,'dari store')
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async buyProd(data) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user