diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 30560596a9b..f9978c98d1a 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -7511,6 +7511,9 @@ "context": "status", "string": "Deactivated" }, + "pNP2pn": { + "string": "Shipping has been already refunded" + }, "pOUOnw": { "context": "tab name", "string": "All vouchers" diff --git a/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx b/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx index f2272431edf..7f22dec7968 100644 --- a/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx +++ b/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx @@ -90,6 +90,17 @@ const OrderGrantRefundPage: React.FC = ({ const totalSelectedPrice = calculateTotalPrice(state, order); + const hasShipingRefunded = () => { + if (initialData?.grantRefundId) { + return order?.grantedRefunds?.some( + refund => + refund.shippingCostsIncluded && + refund.id !== initialData.grantRefundId, + ); + } + + return order?.grantedRefunds?.some(refund => refund.shippingCostsIncluded); + }; const handleSubmit = (e: React.FormEvent) => { e.stopPropagation(); e.preventDefault(); @@ -202,6 +213,7 @@ const OrderGrantRefundPage: React.FC = ({ submitState={submitState} isEdit={isEdit} submitDisabled={submitDisabled} + hasShipingRefunded={hasShipingRefunded()} /> diff --git a/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx b/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx index a1ef3359da0..72fabea08dc 100644 --- a/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx +++ b/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx @@ -12,7 +12,7 @@ import useLocale from "@dashboard/hooks/useLocale"; import { buttonMessages } from "@dashboard/intl"; import { Card, CardContent, Typography } from "@material-ui/core"; import { useId } from "@reach/auto-id"; -import { Button } from "@saleor/macaw-ui-next"; +import { Button, Text } from "@saleor/macaw-ui-next"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; @@ -27,6 +27,7 @@ interface RefundCardProps { submitState: ConfirmButtonTransitionState; isEdit: boolean; submitDisabled: boolean; + hasShipingRefunded: boolean; } export const RefundCard = ({ @@ -35,6 +36,7 @@ export const RefundCard = ({ submitState, isEdit, submitDisabled, + hasShipingRefunded, }: RefundCardProps) => { const intl = useIntl(); const { locale } = useLocale(); @@ -56,30 +58,41 @@ export const RefundCard = ({ {order ? ( -
- dispatch({ type: "toggleRefundShipping" })} - data-test-id="refundShippingCheckbox" - /> - -
+ + )} + ) : (