From 8ede0934be31311bed213baed527b1253edfc1fa Mon Sep 17 00:00:00 2001 From: Leo Unoki Date: Tue, 24 Oct 2023 10:44:00 +0100 Subject: [PATCH 1/2] Hide preview button for batch --- src/components/SendFlow/Tez/FormPage.tsx | 3 ++- src/components/SendFlow/utils.tsx | 6 ++++-- src/views/batch/BatchPage.tsx | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/SendFlow/Tez/FormPage.tsx b/src/components/SendFlow/Tez/FormPage.tsx index fb7c385d8a..ebfe0203fd 100644 --- a/src/components/SendFlow/Tez/FormPage.tsx +++ b/src/components/SendFlow/Tez/FormPage.tsx @@ -43,7 +43,7 @@ const toOperation = (formValues: FormValues): TezTransfer => ({ recipient: parsePkh(formValues.recipient), }); -const FormPage: React.FC> = props => { +const FormPage: React.FC & {showPreview? :boolean}> = ({showPreview = true, ...props}) => { const openSignPage = useOpenSignPageFormAction({ SignPage, signPageExtraData: undefined, @@ -126,6 +126,7 @@ const FormPage: React.FC> = props => { isValid={isValid} onSingleSubmit={handleSubmit(onSingleSubmit)} onAddToBatch={handleSubmit(onBatchSubmit)} + showPreview={showPreview} /> diff --git a/src/components/SendFlow/utils.tsx b/src/components/SendFlow/utils.tsx index 7b31034519..7ed426c0f5 100644 --- a/src/components/SendFlow/utils.tsx +++ b/src/components/SendFlow/utils.tsx @@ -51,16 +51,18 @@ export const FormSubmitButtons = ({ isValid, onSingleSubmit, onAddToBatch, + showPreview = true, }: { isLoading: boolean; isValid: boolean; onSingleSubmit: () => Promise; onAddToBatch: () => Promise; + showPreview? :boolean, }) => { return ( <> - + } + From 73df666fc0339216fcbd933771cdf20ff7b1730f Mon Sep 17 00:00:00 2001 From: Leo Unoki Date: Tue, 24 Oct 2023 10:44:09 +0100 Subject: [PATCH 2/2] Add test for FormSubmitButtons format --- src/components/SendFlow/Tez/FormPage.tsx | 5 ++++- src/components/SendFlow/utils.test.tsx | 27 ++++++++++++++++++++++++ src/components/SendFlow/utils.tsx | 26 ++++++++++++----------- src/views/batch/BatchPage.tsx | 4 +++- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/components/SendFlow/Tez/FormPage.tsx b/src/components/SendFlow/Tez/FormPage.tsx index ebfe0203fd..0be17e8ea6 100644 --- a/src/components/SendFlow/Tez/FormPage.tsx +++ b/src/components/SendFlow/Tez/FormPage.tsx @@ -43,7 +43,10 @@ const toOperation = (formValues: FormValues): TezTransfer => ({ recipient: parsePkh(formValues.recipient), }); -const FormPage: React.FC & {showPreview? :boolean}> = ({showPreview = true, ...props}) => { +const FormPage: React.FC & { showPreview?: boolean }> = ({ + showPreview = true, + ...props +}) => { const openSignPage = useOpenSignPageFormAction({ SignPage, signPageExtraData: undefined, diff --git a/src/components/SendFlow/utils.test.tsx b/src/components/SendFlow/utils.test.tsx index 1996a4d8db..ebe5ad602e 100644 --- a/src/components/SendFlow/utils.test.tsx +++ b/src/components/SendFlow/utils.test.tsx @@ -54,6 +54,33 @@ describe("SendFlow utils", () => { fireEvent.click(screen.getByText("Insert Into Batch")); expect(mockSingle).toHaveBeenCalled(); }); + + it("shows preview button by default", () => { + render( + {}} + onAddToBatch={async () => {}} + /> + ); + + expect(screen.getByText("Preview")).toBeInTheDocument(); + }); + + it("hides preview button", () => { + render( + {}} + onAddToBatch={async () => {}} + /> + ); + + expect(screen.queryByText("Preview")).not.toBeInTheDocument(); + }); }); describe("smallestUnit", () => { diff --git a/src/components/SendFlow/utils.tsx b/src/components/SendFlow/utils.tsx index 7ed426c0f5..522ca7e771 100644 --- a/src/components/SendFlow/utils.tsx +++ b/src/components/SendFlow/utils.tsx @@ -57,22 +57,24 @@ export const FormSubmitButtons = ({ isValid: boolean; onSingleSubmit: () => Promise; onAddToBatch: () => Promise; - showPreview? :boolean, + showPreview?: boolean; }) => { return ( <> - {showPreview && } + {showPreview && ( + + )} +