Skip to content

Commit

Permalink
Merge pull request #265 from chrishiguto/feature/add-table-content-an…
Browse files Browse the repository at this point in the history
…d-fix-table-drawer

feat: add additional table content and fix table drawer
  • Loading branch information
andreneto97 authored Oct 29, 2024
2 parents 7893226 + f106829 commit 3480279
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export interface TableSubmoduleProps {
addButtonEndIcon?: ReactNode;
addButtonContent?: ReactNode;
additionalFilterRowContent?: ReactNode;
additionalTableContent?: ReactNode;
}

const TableSubmodule = (props: TableSubmoduleProps) => {
Expand Down Expand Up @@ -315,6 +316,8 @@ const TableSubmodule = (props: TableSubmoduleProps) => {
)}
</Box>

{props.additionalTableContent && props.additionalTableContent}

<TableContainer sx={tableTheme.tableContainer}>
<Table.Table
stickyHeader
Expand Down
5 changes: 4 additions & 1 deletion packages/react-material-ui/src/modules/crud/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type FormProps = Pick<
| 'onDeleteSuccess'
| 'onDeleteError'
| 'sx'
| 'transformErrors'
>;

interface Title {
Expand All @@ -87,6 +88,7 @@ export interface ModuleProps {
resource: string;
tableProps: TableProps;
formContainerVariation?: 'drawer' | 'modal';
additionalTableContent?: ReactNode;
detailsFormProps?: PropsWithChildren<FormProps>;
createFormProps?: PropsWithChildren<FormProps>;
editFormProps?: PropsWithChildren<FormProps>;
Expand All @@ -110,7 +112,7 @@ export interface ModuleProps {
const CrudModule = (props: ModuleProps) => {
const [drawerViewMode, setDrawerViewMode] = useState<Action>(null);
const [selectedRow, setSelectedRow] = useState<SelectedRow>(null);
const [currentViewIndex, setCurrentViewIndex] = useState<number>(0);
const [currentViewIndex, setCurrentViewIndex] = useState<number | null>(null);
const [isFormVisible, setFormVisible] = useState<boolean>(false);

const useTableReturn = useTable(props.resource, {
Expand Down Expand Up @@ -303,6 +305,7 @@ const CrudModule = (props: ModuleProps) => {
setDrawerViewMode('creation');
setFormVisible(true);
}}
additionalTableContent={props.additionalTableContent}
hideAddButton={!props.createFormProps}
hideEditButton={!props.editFormProps || props.hideEditButton}
hideDeleteButton={props.hideDeleteButton}
Expand Down

0 comments on commit 3480279

Please sign in to comment.