diff --git a/packages/react-material-ui/src/components/submodules/ConfirmationModal/index.tsx b/packages/react-material-ui/src/components/submodules/ConfirmationModal/index.tsx new file mode 100644 index 00000000..817fd471 --- /dev/null +++ b/packages/react-material-ui/src/components/submodules/ConfirmationModal/index.tsx @@ -0,0 +1,62 @@ +import React from 'react'; +import { Box, Button, Dialog, DialogContent, Typography } from '@mui/material'; +import ReportProblemOutlinedIcon from '@mui/icons-material/ReportProblemOutlined'; + +type Props = { + isOpen: boolean; + onClose: () => void; + onConfirm: () => void; +}; + +const ConfirmationModal = ({ isOpen, onClose, onConfirm }: Props) => { + return ( + + + + + + + + Delete Item + + + Are you sure you want to delete this item? + + + + + + + + + ); +}; + +export default ConfirmationModal; diff --git a/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx b/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx index db862d7e..6899a284 100644 --- a/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx +++ b/packages/react-material-ui/src/components/submodules/DrawerForm/index.tsx @@ -18,7 +18,7 @@ import useDataProvider, { useQuery } from '@concepta/react-data-provider'; import validator from '@rjsf/validator-ajv6'; import { SchemaForm, SchemaFormProps } from '../../../components/SchemaForm'; - +import ConfirmationModal from '../ConfirmationModal'; import { CustomTextFieldWidget } from '../../../styles/CustomWidgets'; type Action = 'creation' | 'edit' | 'details' | null; @@ -64,6 +64,9 @@ type DrawerFormSubmoduleProps = PropsWithChildren< }; const DrawerFormSubmodule = (props: DrawerFormSubmoduleProps) => { + const [isConfirmationModalOpen, setConfirmationModalOpen] = + useState(false); + const { queryResource, viewMode, @@ -257,7 +260,7 @@ const DrawerFormSubmodule = (props: DrawerFormSubmoduleProps) => { + )} + {viewMode === 'edit' && !hideCancelButton && ( + + )} + {viewMode === 'details' && !hideCancelButton && ( + + )} + {viewMode !== 'details' && ( + + )} + + + + setConfirmationModalOpen(false)} + onConfirm={() => { + setConfirmationModalOpen(false); + deleteItem(formData); + }} + /> + + ); +}; + +export default FormModule; diff --git a/packages/react-navigation/src/components/AppBarContainer.tsx b/packages/react-navigation/src/components/AppBarContainer.tsx index 0b15e7e7..5a663492 100644 --- a/packages/react-navigation/src/components/AppBarContainer.tsx +++ b/packages/react-navigation/src/components/AppBarContainer.tsx @@ -49,7 +49,7 @@ export default function AppBarContainer({ /> ( onLogoutClick(handleClose)}> Sign Out diff --git a/packages/react-navigation/src/components/DefaultRoute.tsx b/packages/react-navigation/src/components/DefaultRoute.tsx index 92d146b7..f9a73e03 100644 --- a/packages/react-navigation/src/components/DefaultRoute.tsx +++ b/packages/react-navigation/src/components/DefaultRoute.tsx @@ -7,6 +7,7 @@ import { DrawerItemProps, DrawerProps, NavbarProps, + FormModule, } from '@concepta/react-material-ui/'; import { ModuleProps } from '@concepta/react-material-ui/dist/modules/crud'; @@ -18,6 +19,7 @@ type DefaultRouteProps = { showAppBar?: boolean; module?: ModuleProps; page?: ReactNode; + isFormPage?: boolean; items: DrawerItemProps[]; drawerProps?: DrawerProps; navbarProps?: NavbarProps; @@ -35,6 +37,7 @@ const DefaultRoute = ({ showAppBar = true, module, page, + isFormPage = false, items, drawerProps, navbarProps, @@ -48,16 +51,24 @@ const DefaultRoute = ({ onClick: () => item?.id && navigate(item.id), })); - const content = module ? ( - - ) : ( - page - ); + const content = + module && !isFormPage ? ( + + ) : isFormPage ? ( + + ) : ( + page + ); const wrappedContent = showAppBar ? ( renderAppBar ? ( diff --git a/packages/react-navigation/src/components/Resource.tsx b/packages/react-navigation/src/components/Resource.tsx index 45994ca7..edbb20f1 100644 --- a/packages/react-navigation/src/components/Resource.tsx +++ b/packages/react-navigation/src/components/Resource.tsx @@ -4,13 +4,14 @@ import { ModuleProps } from '@concepta/react-material-ui/dist/modules/crud'; type ResourceProps = { id: string; - name: string; - icon: ReactNode; + name?: string; + icon?: ReactNode; showDrawerItem?: boolean; isUnprotected?: boolean; showAppBar?: boolean; module?: Partial; page?: ReactNode; + isFormPage?: boolean; }; const Resource = ({ id }: ResourceProps) => { diff --git a/packages/react-navigation/src/components/Router.tsx b/packages/react-navigation/src/components/Router.tsx index e699b3e7..0cf29032 100644 --- a/packages/react-navigation/src/components/Router.tsx +++ b/packages/react-navigation/src/components/Router.tsx @@ -134,6 +134,7 @@ const Router = ({ name={child.props.name} showAppBar={child.props.showAppBar} module={child.props.module} + isFormPage={child.props.isFormPage} page={child.props.page} items={items} drawerProps={drawerProps}