diff --git a/src/components/list/CityList.tsx b/src/components/list/CityList.tsx index 9c05b0a..ad14c8c 100644 --- a/src/components/list/CityList.tsx +++ b/src/components/list/CityList.tsx @@ -9,6 +9,8 @@ import { HeadCell } from '../../themed/table/DataTable'; import FilteredDataTable from './FilteredDataTable'; import useStateContext from '@/hooks/useStateContext'; import { IUser } from '@/schemas/auth'; +import ProtectedView from '@/layout/ProtectedView'; +import { CITIES_CREATE, CITIES_EDIT } from '@/constants/permissions'; const headCells: HeadCell[] = [ { @@ -45,14 +47,30 @@ export default function RoleList() { const actions = (row: City, loading?: boolean) => (
-
+ ); + + const create = () => ( +
+ +
); @@ -67,7 +85,7 @@ export default function RoleList() { headCells={headCells} title={t('menu.cities')} subtitle={t('menu.descriptions.cities')} - onCreate={() => setOpenDialog(true)} + create={create} actions={actions} updateControl={updateControl} /> diff --git a/src/components/list/FilteredDataTable.tsx b/src/components/list/FilteredDataTable.tsx index f36688c..afb7868 100644 --- a/src/components/list/FilteredDataTable.tsx +++ b/src/components/list/FilteredDataTable.tsx @@ -31,7 +31,7 @@ interface FilteredDataTableProps extends Omit, 'rows'> { defaultFilter?: string; updateControl?: number; actions?: (row: T, loading?: boolean) => JSX.Element; - onCreate?: () => void; + create?: () => JSX.Element; } interface FilterOptionsObject { @@ -48,7 +48,7 @@ export default function FilteredDataTable({ defaultFilter, updateControl, actions, - onCreate, + create, ...otherDataTableProps }: FilteredDataTableProps) { const { t } = useTranslation('translation'); @@ -243,17 +243,7 @@ export default function FilteredDataTable({ onClick={handleSearch} /> - {onCreate && ( - -