mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
fix: Remove document on go back click on step 1 (#910)
⭐ Fixes #903 ⭐ Invoke `onBackStep` on "Go Back" click and conditionally render Go back label string.
This commit is contained in:
@ -248,6 +248,7 @@ export const SinglePlayerClient = () => {
|
|||||||
recipients={uploadedFile ? [placeholderRecipient] : []}
|
recipients={uploadedFile ? [placeholderRecipient] : []}
|
||||||
fields={fields}
|
fields={fields}
|
||||||
onSubmit={onFieldsSubmit}
|
onSubmit={onFieldsSubmit}
|
||||||
|
canGoBack={true}
|
||||||
isDocumentPdfLoaded={true}
|
isDocumentPdfLoaded={true}
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@ -53,6 +53,7 @@ export type AddFieldsFormProps = {
|
|||||||
recipients: Recipient[];
|
recipients: Recipient[];
|
||||||
fields: Field[];
|
fields: Field[];
|
||||||
onSubmit: (_data: TAddFieldsFormSchema) => void;
|
onSubmit: (_data: TAddFieldsFormSchema) => void;
|
||||||
|
canGoBack?: boolean;
|
||||||
isDocumentPdfLoaded: boolean;
|
isDocumentPdfLoaded: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,10 +63,13 @@ export const AddFieldsFormPartial = ({
|
|||||||
recipients,
|
recipients,
|
||||||
fields,
|
fields,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
|
canGoBack = false,
|
||||||
isDocumentPdfLoaded,
|
isDocumentPdfLoaded,
|
||||||
}: AddFieldsFormProps) => {
|
}: AddFieldsFormProps) => {
|
||||||
const { isWithinPageBounds, getFieldPosition, getPage } = useDocumentElement();
|
const { isWithinPageBounds, getFieldPosition, getPage } = useDocumentElement();
|
||||||
const { currentStep, totalSteps, previousStep } = useStep();
|
const { currentStep, totalSteps, previousStep } = useStep();
|
||||||
|
const canRenderBackButtonAsRemove =
|
||||||
|
currentStep === 1 && typeof documentFlow.onBackStep === 'function' && canGoBack;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
@ -595,7 +599,9 @@ export const AddFieldsFormPartial = ({
|
|||||||
onGoBackClick={() => {
|
onGoBackClick={() => {
|
||||||
previousStep();
|
previousStep();
|
||||||
remove();
|
remove();
|
||||||
|
documentFlow.onBackStep?.();
|
||||||
}}
|
}}
|
||||||
|
goBackLabel={canRenderBackButtonAsRemove ? 'Remove' : undefined}
|
||||||
onGoNextClick={() => void onFormSubmit()}
|
onGoNextClick={() => void onFormSubmit()}
|
||||||
/>
|
/>
|
||||||
</DocumentFlowFormContainerFooter>
|
</DocumentFlowFormContainerFooter>
|
||||||
|
|||||||
Reference in New Issue
Block a user