Skip to content

Commit

Permalink
Merge pull request #240 from brunomous/feature/crud-edit-cancel-button
Browse files Browse the repository at this point in the history
Add Cancel button to Crud edit form
  • Loading branch information
andreneto97 authored Sep 25, 2024
2 parents fa190ea + f22705d commit fd73232
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ const DrawerFormSubmodule = (props: FormSubmoduleProps) => {
)}
<Box display="flex" flexDirection="row" alignItems="center" gap={2}>
{props.customFooterContent}
{viewMode === 'creation' && !props.hideCancelButton && (
<Button variant="outlined" onClick={onClose} sx={{ flex: 1 }}>
{cancelButtonTitle || 'Cancel'}
</Button>
)}
{viewMode === 'edit' && !props.hideCancelButton && (
{(viewMode === 'creation' || viewMode === 'edit') &&
!props.hideCancelButton && (
<Button variant="outlined" onClick={onClose} sx={{ flex: 1 }}>
{cancelButtonTitle || 'Cancel'}
</Button>
)}
{viewMode === 'edit' && props.isDeleteButtonVisible && (
<Button
variant="contained"
color="error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ const ModalFormSubmodule = (props: FormSubmoduleProps) => {
gap={2}
>
{props.customFooterContent}
{viewMode === 'creation' && !props.hideCancelButton && (
<Button variant="outlined" onClick={onClose} sx={{ flex: 1 }}>
{cancelButtonTitle || 'Cancel'}
</Button>
)}
{viewMode === 'edit' && !props.hideCancelButton && (
{(viewMode === 'creation' || viewMode === 'edit') &&
!props.hideCancelButton && (
<Button variant="outlined" onClick={onClose} sx={{ flex: 1 }}>
{cancelButtonTitle || 'Cancel'}
</Button>
)}
{viewMode === 'edit' && props.isDeleteButtonVisible && (
<Button
variant="contained"
color="error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type FormSubmoduleProps = PropsWithChildren<
submitButtonTitle?: string;
cancelButtonTitle?: string;
hideCancelButton?: boolean;
isDeleteButtonVisible?: boolean;
customFooterContent?: ReactNode;
onClose?: () => void;
customValidate?: CustomValidator;
Expand Down

0 comments on commit fd73232

Please sign in to comment.