* optional chaining wip * resolve property of undefined error * remove error toast when there is no error * revert makeMutation * apply suggestions from code review * revert newline * code review suggestions * remove unnecessary optional chaining * fix orderRefund undefined errors
This commit is contained in:
parent
a466676858
commit
d0a6e10cec
2 changed files with 10 additions and 5 deletions
|
@ -108,7 +108,7 @@ const OrderRefund: React.FC<OrderRefundProps> = ({ orderId }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return response.errors || [];
|
return response?.errors || [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitProductsRefund = async (
|
const handleSubmitProductsRefund = async (
|
||||||
|
@ -127,7 +127,7 @@ const OrderRefund: React.FC<OrderRefundProps> = ({ orderId }) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return response.errors || [];
|
return response?.errors || [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (formData: OrderRefundSubmitData) =>
|
const handleSubmit = async (formData: OrderRefundSubmitData) =>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import OrderReturnPage from "@saleor/orders/components/OrderReturnPage";
|
||||||
import { OrderReturnFormData } from "@saleor/orders/components/OrderReturnPage/form";
|
import { OrderReturnFormData } from "@saleor/orders/components/OrderReturnPage/form";
|
||||||
import { useOrderReturnCreateMutation } from "@saleor/orders/mutations";
|
import { useOrderReturnCreateMutation } from "@saleor/orders/mutations";
|
||||||
import { useOrderQuery } from "@saleor/orders/queries";
|
import { useOrderQuery } from "@saleor/orders/queries";
|
||||||
|
import { FulfillmentReturnProducts_orderFulfillmentReturnProducts } from "@saleor/orders/types/FulfillmentReturnProducts";
|
||||||
import { orderUrl } from "@saleor/orders/urls";
|
import { orderUrl } from "@saleor/orders/urls";
|
||||||
import { OrderErrorCode } from "@saleor/types/globalTypes";
|
import { OrderErrorCode } from "@saleor/types/globalTypes";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -56,9 +57,11 @@ const OrderReturn: React.FC<OrderReturnProps> = ({ orderId }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
navigateToOrder(replaceOrder?.id);
|
navigateToOrder(replaceOrder?.id);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors[0].code === OrderErrorCode.CANNOT_REFUND) {
|
if (errors.some(err => err.code === OrderErrorCode.CANNOT_REFUND)) {
|
||||||
notify({
|
notify({
|
||||||
autohide: 5000,
|
autohide: 5000,
|
||||||
status: "error",
|
status: "error",
|
||||||
|
@ -90,8 +93,10 @@ const OrderReturn: React.FC<OrderReturnProps> = ({ orderId }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { orderFulfillmentReturnProducts }
|
data: {
|
||||||
} = result;
|
orderFulfillmentReturnProducts = {} as FulfillmentReturnProducts_orderFulfillmentReturnProducts
|
||||||
|
} = {}
|
||||||
|
} = result || {};
|
||||||
|
|
||||||
return orderFulfillmentReturnProducts.errors;
|
return orderFulfillmentReturnProducts.errors;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue