From 6532fe84fefe5cdd6990edfd60ab6232db648ee6 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 12 Dec 2023 14:42:25 -0500 Subject: [PATCH] fix(striker-ui): add props to control action area visibility in confirm dialog --- striker-ui/components/ConfirmDialog.tsx | 66 +++++++++++++++++-------- striker-ui/types/ConfirmDialog.d.ts | 2 + 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/striker-ui/components/ConfirmDialog.tsx b/striker-ui/components/ConfirmDialog.tsx index 38f7ea20..564e961c 100644 --- a/striker-ui/components/ConfirmDialog.tsx +++ b/striker-ui/components/ConfirmDialog.tsx @@ -39,6 +39,8 @@ const ConfirmDialog: ForwardRefExoticComponent< proceedColour = 'blue', scrollContent = false, scrollBoxProps, + showActionArea = true, + showCancel, showClose, titleText, wide, @@ -64,27 +66,9 @@ const ConfirmDialog: ForwardRefExoticComponent< [contentElement, scrollBoxProps, scrollContent], ); - useImperativeHandle( - ref, - () => ({ - setOpen: (open) => dialogRef.current?.setOpen(open), - }), - [], - ); - - return ( - - - {bodyElement} - {preActionArea} + const actionArea = useMemo( + () => + showActionArea && ( + ), + [ + actionCancelText, + actionProceedText, + closeOnProceed, + disableProceed, + loadingAction, + onActionAppend, + onCancelAppend, + onProceedAppend, + proceedButtonProps, + proceedColour, + showActionArea, + showCancel, + ], + ); + + useImperativeHandle( + ref, + () => ({ + setOpen: (open) => dialogRef.current?.setOpen(open), + }), + [], + ); + + return ( + + + {bodyElement} + {preActionArea} + {actionArea} ); diff --git a/striker-ui/types/ConfirmDialog.d.ts b/striker-ui/types/ConfirmDialog.d.ts index b064b354..937ca5e0 100644 --- a/striker-ui/types/ConfirmDialog.d.ts +++ b/striker-ui/types/ConfirmDialog.d.ts @@ -17,9 +17,11 @@ type ConfirmDialogOptionalProps = { proceedColour?: 'blue' | 'red'; scrollContent?: boolean; scrollBoxProps?: import('@mui/material').BoxProps; + showActionArea?: boolean; }; type ConfirmDialogProps = Omit & + Pick & ConfirmDialogOptionalProps & { actionProceedText: string; titleText: import('react').ReactNode;