Hit Api Buy Stagging
This commit is contained in:
		@@ -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>,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user