diff --git a/src/components/pages/master-data/production-standard/ProductionStandardTable.tsx b/src/components/pages/master-data/production-standard/ProductionStandardTable.tsx index 956f9b6a..afa41295 100644 --- a/src/components/pages/master-data/production-standard/ProductionStandardTable.tsx +++ b/src/components/pages/master-data/production-standard/ProductionStandardTable.tsx @@ -17,6 +17,7 @@ import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; import toast from 'react-hot-toast'; import { cn } from '@/lib/helper'; +import RequirePermission from '@/components/helper/RequirePermission'; const RowOptionsMenu = ({ type = 'dropdown', @@ -29,40 +30,46 @@ const RowOptionsMenu = ({ }) => { return ( - - - - - + > + + Detail + + + + + + + + + + ); }; @@ -101,99 +108,108 @@ const ProductionStandardTable = () => { <>
- + + +
- - data={ - isResponseSuccess(productionStandards) - ? productionStandards.data - : [] - } - columns={[ - { - header: 'No', - accessorFn: (row, index) => index + 1, - }, - { - header: 'Nama', - accessorKey: 'name', - }, - { - header: 'Kategori', - accessorFn: (row) => row.project_category, - }, - { - header: 'Aksi', - cell: (props) => { - const currentPageSize = - props.table.getPaginationRowModel().rows.length; - const currentPageRows = - props.table.getPaginationRowModel().flatRows; - const currentRowRelativeIndex = - currentPageRows.findIndex((r) => r.id === props.row.id) + 1; - - const isLast2Rows = - currentRowRelativeIndex > currentPageSize - 2; - - const deleteClickHandler = () => { - setSelectedProductionStandard(props.row.original); - deleteModal.openModal(); - }; - - return ( - <> - {currentPageSize > 2 && ( - - - - )} - - {currentPageSize <= 2 && ( - - - - )} - - ); + + + data={ + isResponseSuccess(productionStandards) + ? productionStandards.data + : [] + } + columns={[ + { + header: 'No', + accessorFn: (row, index) => index + 1, }, - }, - ]} - className={{ - headerColumnClassName: cn( - TABLE_DEFAULT_STYLING.headerColumnClassName, - 'last:flex last:flex-row last:justify-end' - ), - bodyColumnClassName: cn( - TABLE_DEFAULT_STYLING.bodyColumnClassName, - 'last:flex last:flex-row last:justify-end' - ), + { + header: 'Nama', + accessorKey: 'name', + }, + { + header: 'Kategori', + accessorFn: (row) => row.project_category, + }, + { + header: 'Aksi', + cell: (props) => { + const currentPageSize = + props.table.getPaginationRowModel().rows.length; + const currentPageRows = + props.table.getPaginationRowModel().flatRows; + const currentRowRelativeIndex = + currentPageRows.findIndex((r) => r.id === props.row.id) + 1; + + const isLast2Rows = + currentRowRelativeIndex > currentPageSize - 2; + + const deleteClickHandler = () => { + setSelectedProductionStandard(props.row.original); + deleteModal.openModal(); + }; + + return ( + <> + {currentPageSize > 2 && ( + + + + )} + + {currentPageSize <= 2 && ( + + + + )} + + ); + }, + }, + ]} + className={{ + headerColumnClassName: cn( + TABLE_DEFAULT_STYLING.headerColumnClassName, + 'last:flex last:flex-row last:justify-end' + ), + bodyColumnClassName: cn( + TABLE_DEFAULT_STYLING.bodyColumnClassName, + 'last:flex last:flex-row last:justify-end' + ), + }} + /> + +
+ + - - + ); }; diff --git a/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx b/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx index 336f7da4..99edb852 100644 --- a/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx +++ b/src/components/pages/master-data/production-standard/form/ProductionStandardForm.tsx @@ -28,6 +28,7 @@ import { isResponseError } from '@/lib/api-helper'; import toast from 'react-hot-toast'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; import { useModal } from '@/components/Modal'; +import RequirePermission from '@/components/helper/RequirePermission'; type TableRowsType = { customRow: boolean; @@ -1146,39 +1147,45 @@ const ProductionStandardForm = ({ > {formType === 'detail' && (
+ + + + + + +
+ )} + {formType == 'edit' && ( + - - - )} - {formType == 'edit' && ( - + )}
{formType === 'detail' ? 'Detail' : 'Total'}{' '} diff --git a/src/config/route-permission.ts b/src/config/route-permission.ts index ed6d4771..a083d839 100644 --- a/src/config/route-permission.ts +++ b/src/config/route-permission.ts @@ -152,4 +152,15 @@ export const ROUTE_PERMISSIONS: Record = { '/master-data/flock/add/': ['lti.master.flocks.create'], '/master-data/flock/detail/': ['lti.master.flocks.detail'], '/master-data/flock/detail/edit/': ['lti.master.flocks.update'], + + '/master-data/production-standard/': ['lti.master.production_standards.list'], + '/master-data/production-standard/add/': [ + 'lti.master.production_standards.create', + ], + '/master-data/production-standard/detail/': [ + 'lti.master.production_standards.detail', + ], + '/master-data/production-standard/detail/edit/': [ + 'lti.master.production_standards.update', + ], };