+
-
);
};
diff --git a/app/javascript/components/ProductEdit/ReceiptTab/index.tsx b/app/javascript/components/ProductEdit/ReceiptTab/index.tsx
index 6fed230922..376a068caf 100644
--- a/app/javascript/components/ProductEdit/ReceiptTab/index.tsx
+++ b/app/javascript/components/ProductEdit/ReceiptTab/index.tsx
@@ -1,7 +1,5 @@
import * as React from "react";
-import { Layout } from "$app/components/ProductEdit/Layout";
-import { ReceiptPreview } from "$app/components/ProductEdit/ReceiptPreview";
import { CustomReceiptTextInput } from "$app/components/ProductEdit/ReceiptTab/CustomReceiptTextInput";
import { CustomViewContentButtonTextInput } from "$app/components/ProductEdit/ReceiptTab/CustomViewContentButtonTextInput";
import { useProductEditContext } from "$app/components/ProductEdit/state";
@@ -10,8 +8,7 @@ export const ReceiptTab = () => {
const { product, updateProduct } = useProductEditContext();
return (
-
} previewScaleFactor={1} showBorder={false} showNavigationButton={false}>
-
+
-
);
};
diff --git a/app/javascript/components/ProductEdit/RefundPolicy.tsx b/app/javascript/components/ProductEdit/RefundPolicy.tsx
index 0be5c9dbb9..c3c1d3a6c1 100644
--- a/app/javascript/components/ProductEdit/RefundPolicy.tsx
+++ b/app/javascript/components/ProductEdit/RefundPolicy.tsx
@@ -20,6 +20,14 @@ export type RefundPolicy = {
title: string;
};
+const defaultRefundPolicy: RefundPolicy = {
+ title: "",
+ fine_print: null,
+ fine_print_enabled: false,
+ max_refund_period_in_days: 0,
+ allowed_refund_periods_in_days: [],
+};
+
export const RefundPolicySelector = ({
refundPolicy,
setRefundPolicy,
@@ -28,7 +36,7 @@ export const RefundPolicySelector = ({
setIsEnabled,
setShowPreview,
}: {
- refundPolicy: RefundPolicy;
+ refundPolicy?: RefundPolicy | null;
setRefundPolicy: (refundPolicy: RefundPolicy) => void;
refundPolicies: OtherRefundPolicy[];
isEnabled: boolean;
@@ -36,6 +44,7 @@ export const RefundPolicySelector = ({
setShowPreview: (showingPreview: boolean) => void;
}) => {
const [selectedRefundPolicyId, setSelectedRefundPolicyId] = React.useState
(null);
+ const safeRefundPolicy = refundPolicy ?? defaultRefundPolicy;
const uid = React.useId();
@@ -81,7 +90,7 @@ export const RefundPolicySelector = ({
const otherRefundPolicy = refundPolicies.find(({ id }) => id === selectedRefundPolicyId);
if (otherRefundPolicy) {
setRefundPolicy({
- ...refundPolicy,
+ ...safeRefundPolicy,
title: otherRefundPolicy.title,
fine_print: otherRefundPolicy.fine_print,
max_refund_period_in_days: otherRefundPolicy.max_refund_period_in_days,
@@ -99,20 +108,20 @@ export const RefundPolicySelector = ({