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) => {
|
const handleBuyProduct = async (data, productCode) => {
|
||||||
//console.log(data)
|
|
||||||
modalLoader.setLoading(true);
|
modalLoader.setLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await store.transaction.buyProd({
|
const response = await store.transaction.buyProd({
|
||||||
...data,
|
...data,
|
||||||
productCode: productCode,
|
productCode: productCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.status === 201) {
|
if (response.status === 201) {
|
||||||
message.success(response?.body?.message || "Berhasil Beli Produk");
|
message.success(response?.body?.message || "Berhasil Beli Produk");
|
||||||
} else {
|
} else {
|
||||||
message.error(response?.body?.error || "Gagal Beli Produk", 3);
|
message.error(response?.body?.error || "Gagal Beli Produk", 3);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log("testingan");
|
||||||
|
console.log(e.response, "testingan");
|
||||||
|
console.log(e.result, "testingan1");
|
||||||
if (e.response?.body?.error) {
|
if (e.response?.body?.error) {
|
||||||
message.error(e.response.body.error);
|
message.error(e.response.body.error);
|
||||||
setVisibleModalBuy(false);
|
setVisibleModalBuy(false);
|
||||||
|
@ -80,6 +83,36 @@ export const Product = observer(() => {
|
||||||
modalLoader.setLoading(false);
|
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 = () => {
|
const handleCancel = () => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
setVisibleModalBuy(false);
|
setVisibleModalBuy(false);
|
||||||
|
@ -178,7 +211,7 @@ export const Product = observer(() => {
|
||||||
Cancel
|
Cancel
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button
|
<Button
|
||||||
key="submit"
|
key="Buy Prod"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "#4e79e7",
|
backgroundColor: "#4e79e7",
|
||||||
color: "#fff",
|
color: "#fff",
|
||||||
|
@ -199,11 +232,20 @@ export const Product = observer(() => {
|
||||||
Buy Prod
|
Buy Prod
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button
|
<Button
|
||||||
key="link"
|
key="Buy Stag"
|
||||||
href="https://google.com"
|
|
||||||
type="primary"
|
type="primary"
|
||||||
// loading={loading}
|
onClick={() => {
|
||||||
// onClick={this.handleOk}
|
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
|
Buy Staging
|
||||||
</Button>,
|
</Button>,
|
||||||
|
|
|
@ -175,12 +175,9 @@ export class Transaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async buyProduct(data) {
|
async buyProduct(data) {
|
||||||
try {
|
|
||||||
const response = await http.post("/transaction/order").send(data);
|
const response = await http.post("/transaction/order").send(data);
|
||||||
|
console.log(response,'dari store')
|
||||||
return response;
|
return response;
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async buyProd(data) {
|
async buyProd(data) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user