Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page

This commit is contained in:
rstubryan
2025-12-27 16:48:00 +07:00
56 changed files with 2589 additions and 1831 deletions
+52 -24
View File
@@ -5,6 +5,8 @@ import Tooltip from '@/components/Tooltip';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import { useAuth } from '@/services/hooks/useAuth';
type FloatingActionsButtonProps = { type FloatingActionsButtonProps = {
actions: { actions: {
action: 'DETAIL' | 'EDIT' | 'DELETE'; action: 'DETAIL' | 'EDIT' | 'DELETE';
@@ -13,6 +15,7 @@ type FloatingActionsButtonProps = {
onClick?: () => void; onClick?: () => void;
hidden?: boolean; hidden?: boolean;
disabled?: boolean; disabled?: boolean;
permissions?: string | string[];
}[]; }[];
approvals: { approvals: {
action: 'APPROVED' | 'REJECTED'; action: 'APPROVED' | 'REJECTED';
@@ -20,6 +23,7 @@ type FloatingActionsButtonProps = {
label?: string; label?: string;
onClick?: () => void; onClick?: () => void;
disabled?: boolean; disabled?: boolean;
permissions?: string | string[];
}[]; }[];
selectedRowIds: number[]; selectedRowIds: number[];
onClose: () => void; onClose: () => void;
@@ -31,6 +35,7 @@ const FloatingActionsButton = ({
selectedRowIds, selectedRowIds,
onClose, onClose,
}: FloatingActionsButtonProps) => { }: FloatingActionsButtonProps) => {
const { permissionCheck } = useAuth();
// Jika tidak ada baris yang dipilih, jangan tampilkan FAB // Jika tidak ada baris yang dipilih, jangan tampilkan FAB
const positionStyles = const positionStyles =
selectedRowIds.length > 0 selectedRowIds.length > 0
@@ -71,7 +76,18 @@ const FloatingActionsButton = ({
<div className='flex gap-4 items-center'> <div className='flex gap-4 items-center'>
{/* Render Aksi dari props.actions */} {/* Render Aksi dari props.actions */}
{actions {actions
.filter((action) => !action.hidden) .filter((action) => {
if (action.hidden) return false;
if (action.permissions) {
if (typeof action.permissions === 'string') {
return permissionCheck(action.permissions);
}
return action.permissions.some((permission) =>
permissionCheck(permission)
);
}
return true;
})
.map((action, index) => { .map((action, index) => {
return ( return (
<Button <Button
@@ -111,29 +127,41 @@ const FloatingActionsButton = ({
{/* === BARIS BAWAH: Approval Buttons (Approve/Reject) === */} {/* === BARIS BAWAH: Approval Buttons (Approve/Reject) === */}
<div className={`grid grid-cols-${approvals.length} gap-3`}> <div className={`grid grid-cols-${approvals.length} gap-3`}>
{approvals.map((approval, index) => ( {approvals
<Button .filter((approval) => {
key={index} if (approval.permissions) {
onClick={approval.onClick} if (typeof approval.permissions === 'string') {
className={cn( return permissionCheck(approval.permissions);
'btn btn-lg w-full', }
'bg-white/20 border-white/30', return approval.permissions.some((permission) =>
'text-white/50 font-semibold flex items-center gap-2 rounded-lg transition-all duration-200', permissionCheck(permission)
approval.disabled );
? 'cursor-not-allowed' }
: 'hover:text-white/100 hover:bg-white/40 hover:border-white/50' return true;
)} })
disabled={approval.disabled} .map((approval, index) => (
> <Button
<Icon key={index}
icon={approval.icon} onClick={approval.onClick}
width={20} className={cn(
height={20} 'btn btn-lg w-full',
className={`text-${getApprovalColor(approval.action)}`} 'bg-white/20 border-white/30',
/> 'text-white/50 font-semibold flex items-center gap-2 rounded-lg transition-all duration-200',
{approval.label || approval.action} approval.disabled
</Button> ? 'cursor-not-allowed'
))} : 'hover:text-white/100 hover:bg-white/40 hover:border-white/50'
)}
disabled={approval.disabled}
>
<Icon
icon={approval.icon}
width={20}
height={20}
className={`text-${getApprovalColor(approval.action)}`}
/>
{approval.label || approval.action}
</Button>
))}
</div> </div>
</div> </div>
</div> </div>
+12
View File
@@ -9,10 +9,13 @@ import Drawer from '@/components/Drawer';
import Navbar from '@/components/Navbar'; import Navbar from '@/components/Navbar';
import Button from '@/components/Button'; import Button from '@/components/Button';
import SidebarMenu from '@/components/molecules/SidebarMenu'; import SidebarMenu from '@/components/molecules/SidebarMenu';
import PermissionNotFound from '@/components/helper/PermissionNotFound';
import { useUiStore } from '@/stores/ui/ui.store'; import { useUiStore } from '@/stores/ui/ui.store';
import { MAIN_DRAWER_LINKS } from '@/config/constant'; import { MAIN_DRAWER_LINKS } from '@/config/constant';
import { isPathActive } from '@/lib/helper'; import { isPathActive } from '@/lib/helper';
import { ROUTE_PERMISSIONS } from '@/config/route-permission';
import { useAuth } from '@/services/hooks/useAuth';
const MainDrawerContent = () => { const MainDrawerContent = () => {
const pathname = usePathname(); const pathname = usePathname();
@@ -62,6 +65,11 @@ const MainDrawer = ({
}>) => { }>) => {
const { mainDrawerOpen, setMainDrawerOpen } = useUiStore(); const { mainDrawerOpen, setMainDrawerOpen } = useUiStore();
const pathname = usePathname(); const pathname = usePathname();
const { permissionCheck } = useAuth();
const isPermitted = ROUTE_PERMISSIONS[pathname]?.some((permission) =>
permissionCheck(permission)
);
const getPageTitle = useCallback(() => { const getPageTitle = useCallback(() => {
let title = ''; let title = '';
@@ -101,6 +109,10 @@ const MainDrawer = ({
setMainDrawerOpen(!mainDrawerOpen); setMainDrawerOpen(!mainDrawerOpen);
}; };
if (!isPermitted) {
return <PermissionNotFound />;
}
return ( return (
<Drawer <Drawer
open={mainDrawerOpen} open={mainDrawerOpen}
@@ -0,0 +1,12 @@
const PermissionNotFound = () => {
return (
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
<h2 className='text-2xl font-bold text-error'>Permission Not Found</h2>
<p className='text-gray-600 text-center'>
You do not have permission to access this page.
</p>
</div>
);
};
export default PermissionNotFound;
@@ -0,0 +1,28 @@
'use client';
import { useAuth } from '@/services/hooks/useAuth';
interface RequirePermissionProps {
children: React.ReactNode;
permissions: string | string[];
}
const RequirePermission = ({
children,
permissions,
}: RequirePermissionProps) => {
const { permissionCheck } = useAuth();
const isPermitted =
typeof permissions === 'string'
? permissionCheck(permissions)
: permissions.some((permission) => permissionCheck(permission));
if (!isPermitted) {
return null;
}
return <>{children}</>;
};
export default RequirePermission;
+20 -7
View File
@@ -2,6 +2,7 @@ import Link from 'next/link';
import Menu from '@/components/menu/Menu'; import Menu from '@/components/menu/Menu';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import { cn, isPathActive } from '@/lib/helper'; import { cn, isPathActive } from '@/lib/helper';
import { useAuth } from '@/services/hooks/useAuth';
export interface SidebarMenuItem { export interface SidebarMenuItem {
type?: 'item' | 'title'; type?: 'item' | 'title';
@@ -9,6 +10,7 @@ export interface SidebarMenuItem {
link: string; link: string;
icon?: string; icon?: string;
submenu?: SidebarMenuItem[]; submenu?: SidebarMenuItem[];
permission?: string[];
} }
interface SidebarMenuItemProps { interface SidebarMenuItemProps {
@@ -22,8 +24,17 @@ interface SidebarMenuProps {
} }
const SidebarMenuItem = ({ item, activeLink }: SidebarMenuItemProps) => { const SidebarMenuItem = ({ item, activeLink }: SidebarMenuItemProps) => {
const { permissionCheck } = useAuth();
const isItemActive = isPathActive(activeLink, item.link); const isItemActive = isPathActive(activeLink, item.link);
const isUserPermitted = item.permission
? item.permission?.some((permissionName) => permissionCheck(permissionName))
: true;
if (!isUserPermitted) {
return null;
}
const menuItemWithoutSubmenu = ( const menuItemWithoutSubmenu = (
<li> <li>
<Link <Link
@@ -78,13 +89,15 @@ const SidebarMenuItem = ({ item, activeLink }: SidebarMenuItemProps) => {
const SidebarMenu = ({ menu, activeLink }: SidebarMenuProps) => { const SidebarMenu = ({ menu, activeLink }: SidebarMenuProps) => {
return ( return (
<Menu> <Menu>
{menu.map((menuItem, menuIdx) => ( {menu.map((menuItem, menuIdx) => {
<SidebarMenuItem return (
key={menuIdx} <SidebarMenuItem
item={menuItem} key={menuIdx}
activeLink={activeLink} item={menuItem}
/> activeLink={activeLink}
))} />
);
})}
</Menu> </Menu>
); );
}; };
+13 -10
View File
@@ -15,6 +15,8 @@ import SelectInput, {
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { cn, formatCurrency, formatDate } from '@/lib/helper'; import { cn, formatCurrency, formatDate } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter'; import { useTableFilter } from '@/services/hooks/useTableFilter';
@@ -43,17 +45,18 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
{/* TODO: apply RBAC */}
<div className='w-full max-h-40 overflow-auto flex flex-col gap-1'> <div className='w-full max-h-40 overflow-auto flex flex-col gap-1'>
<Button <RequirePermission permissions='lti.closing.detail'>
href={`/closing/detail/?closingId=${props.row.original.id}`} <Button
variant='ghost' href={`/closing/detail/?closingId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
> className='justify-start text-sm'
<Icon icon='mdi:eye-outline' width={16} height={16} /> >
Detail <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
</div> </div>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -4,6 +4,7 @@ import toast from 'react-hot-toast';
import Link from 'next/link'; import Link from 'next/link';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import Button from '@/components/Button'; import Button from '@/components/Button';
import RequirePermission from '@/components/helper/RequirePermission';
import Card from '@/components/Card'; import Card from '@/components/Card';
import DropFileInput from '@/components/input/DropFileInput'; import DropFileInput from '@/components/input/DropFileInput';
@@ -62,16 +63,17 @@ const ExpenseRealizationContent = ({
<div> <div>
<div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'> <div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'>
<div className='w-full sm:w-fit sm:ml-2 flex flex-row gap-2 items-center'> <div className='w-full sm:w-fit sm:ml-2 flex flex-row gap-2 items-center'>
{/* TODO: apply RBAC */} <RequirePermission permissions='lti.expense.update.realization'>
<Button <Button
type='button' type='button'
color='warning' color='warning'
href={`/expense/realization/edit/?expenseId=${initialValues?.id}`} href={`/expense/realization/edit/?expenseId=${initialValues?.id}`}
className='px-4 grow sm:grow-0' className='px-4 grow sm:grow-0'
> >
<Icon icon='mdi:pencil-outline' width={24} height={24} /> <Icon icon='mdi:pencil-outline' width={24} height={24} />
Edit Realisasi Edit Realisasi
</Button> </Button>
</RequirePermission>
</div> </div>
</div> </div>
@@ -124,36 +126,38 @@ const ExpenseRealizationContent = ({
)} )}
</div> </div>
<div className='flex flex-col gap-2'> <RequirePermission permissions='lti.expense.document.realization'>
<DropFileInput <div className='flex flex-col gap-2'>
name='documents' <DropFileInput
values={formik.values.documents} name='documents'
onChange={realizationDocumentsChangeHandler} values={formik.values.documents}
onDelete={realizationDocumentsDeleteHandler} onChange={realizationDocumentsChangeHandler}
accept={{ onDelete={realizationDocumentsDeleteHandler}
...ACCEPTED_FILE_TYPE.PDF, accept={{
...ACCEPTED_FILE_TYPE.IMAGE, ...ACCEPTED_FILE_TYPE.PDF,
}} ...ACCEPTED_FILE_TYPE.IMAGE,
maxFiles={10} }}
className={{ maxFiles={10}
wrapper: 'mt-2', className={{
inputWrapper: 'flex items-center', wrapper: 'mt-2',
}} inputWrapper: 'flex items-center',
/> }}
/>
{formik.values.documents && {formik.values.documents &&
formik.values.documents.length > 0 && ( formik.values.documents.length > 0 && (
<Button <Button
onClick={formik.submitForm} onClick={formik.submitForm}
disabled={formik.isSubmitting} disabled={formik.isSubmitting}
isLoading={formik.isSubmitting} isLoading={formik.isSubmitting}
className='w-fit self-end' className='w-fit self-end'
> >
<Icon icon='ic:round-plus' width={24} height={24} /> <Icon icon='ic:round-plus' width={24} height={24} />
Tambah Tambah
</Button> </Button>
)} )}
</div> </div>
</RequirePermission>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -19,6 +19,7 @@ import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes'; import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import ExpensePDFPreviewButton from '@/components/pages/expense//pdf/ExpensePDFButton'; import ExpensePDFPreviewButton from '@/components/pages/expense//pdf/ExpensePDFButton';
import RequirePermission from '@/components/helper/RequirePermission';
import { Expense } from '@/types/api/expense'; import { Expense } from '@/types/api/expense';
import { formatCurrency, formatDate } from '@/lib/helper'; import { formatCurrency, formatDate } from '@/lib/helper';
@@ -255,100 +256,119 @@ const ExpenseRequestContent = ({
<div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'> <div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'>
{isCurrentApprovalOnManager && ( {isCurrentApprovalOnManager && (
<Button <RequirePermission permissions='lti.expense.approve.manager'>
variant='outline' <Button
color='info' variant='outline'
onClick={approveClickHandler} color='info'
className='w-full sm:w-fit' onClick={approveClickHandler}
> className='w-full sm:w-fit'
<Icon icon='lucide-lab:farm' width={24} height={24} /> >
Approve Manager <Icon icon='lucide-lab:farm' width={24} height={24} />
</Button> Approve Manager
</Button>
</RequirePermission>
)} )}
{isCurrentApprovalOnFinance && ( {isCurrentApprovalOnFinance && (
<Button <RequirePermission permissions='lti.expense.approve.finance'>
variant='outline' <Button
color='success' variant='outline'
onClick={approveClickHandler} color='success'
className='w-full sm:w-fit' onClick={approveClickHandler}
> className='w-full sm:w-fit'
<Icon icon='tdesign:money' width={24} height={24} /> >
Approve Finance <Icon icon='tdesign:money' width={24} height={24} />
</Button> Approve Finance
</Button>
</RequirePermission>
)} )}
{isCurrentApprovalOnRealization && ( {isCurrentApprovalOnRealization && (
<Button <RequirePermission permissions='lti.expense.complete.expense'>
variant='outline' <Button
color='success' variant='outline'
onClick={completeExpenseClickHandler} color='success'
className='w-full sm:w-fit' onClick={completeExpenseClickHandler}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:done-all-rounded' <Icon
width={24} icon='material-symbols:done-all-rounded'
height={24} width={24}
/> height={24}
Selesai />
</Button> Selesai
</Button>
</RequirePermission>
)} )}
{showRejectButton && ( {showRejectButton && (
<Button <RequirePermission
variant='outline' permissions={[
color='error' 'lti.expense.approve.manager',
onClick={rejectClickHandler} 'lti.expense.approve.finance',
className='w-full:w-fit' ]}
> >
<Icon icon='material-symbols:close' width={24} height={24} /> <Button
Reject variant='outline'
</Button> color='error'
onClick={rejectClickHandler}
className='w-full:w-fit'
>
<Icon icon='material-symbols:close' width={24} height={24} />
Reject
</Button>
</RequirePermission>
)} )}
{isExpenseCanBeRealized && ( {isExpenseCanBeRealized && (
<Button <RequirePermission permissions='lti.expense.create.realization'>
variant='outline' <Button
color='info' variant='outline'
href={`/expense/realization/?expenseId=${initialValues?.id}`} color='info'
className='w-full sm:w-fit' href={`/expense/realization/?expenseId=${initialValues?.id}`}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:money-bag-rounded' <Icon
width={24} icon='material-symbols:money-bag-rounded'
height={24} width={24}
/> height={24}
Realisasi />
</Button> Realisasi
</Button>
</RequirePermission>
)} )}
<div className='w-full sm:w-fit sm:ml-2 flex flex-row gap-2 items-center'> <div className='w-full sm:w-fit sm:ml-2 flex flex-row gap-2 items-center'>
{showEditButton && ( {showEditButton && (
<Button <RequirePermission permissions='lti.expense.update'>
type='button' <Button
color='warning' type='button'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`} color='warning'
className='px-4 grow sm:grow-0' href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
> className='px-4 grow sm:grow-0'
<Icon icon='mdi:pencil-outline' width={24} height={24} /> >
Edit <Icon icon='mdi:pencil-outline' width={24} height={24} />
</Button> Edit
</Button>
</RequirePermission>
)} )}
<Button <RequirePermission permissions='lti.expense.delete'>
type='button' <Button
color='error' type='button'
onClick={deleteExpenseClickHandler} color='error'
className='px-4 grow sm:grow-0' onClick={deleteExpenseClickHandler}
> className='px-4 grow sm:grow-0'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={24} icon='material-symbols:delete-outline-rounded'
height={24} width={24}
className='justify-start text-sm' height={24}
/> className='justify-start text-sm'
Delete />
</Button> Delete
</Button>
</RequirePermission>
</div> </div>
</div> </div>
@@ -485,36 +505,42 @@ const ExpenseRequestContent = ({
)} )}
</div> </div>
<div className='flex flex-col gap-2'> <RequirePermission permissions='lti.expense.document'>
<DropFileInput <div className='flex flex-col gap-2'>
name='documents' <DropFileInput
values={formik.values.documents} name='documents'
onChange={requestDocumentsChangeHandler} values={formik.values.documents}
onDelete={requestDocumentsDeleteHandler} onChange={requestDocumentsChangeHandler}
accept={{ onDelete={requestDocumentsDeleteHandler}
...ACCEPTED_FILE_TYPE.PDF, accept={{
...ACCEPTED_FILE_TYPE.IMAGE, ...ACCEPTED_FILE_TYPE.PDF,
}} ...ACCEPTED_FILE_TYPE.IMAGE,
maxFiles={10} }}
className={{ maxFiles={10}
wrapper: 'mt-2', className={{
inputWrapper: 'flex items-center', wrapper: 'mt-2',
}} inputWrapper: 'flex items-center',
/> }}
/>
{formik.values.documents && {formik.values.documents &&
formik.values.documents.length > 0 && ( formik.values.documents.length > 0 && (
<Button <Button
onClick={formik.submitForm} onClick={formik.submitForm}
disabled={formik.isSubmitting} disabled={formik.isSubmitting}
isLoading={formik.isSubmitting} isLoading={formik.isSubmitting}
className='w-fit self-end' className='w-fit self-end'
> >
<Icon icon='ic:round-plus' width={24} height={24} /> <Icon
Tambah icon='ic:round-plus'
</Button> width={24}
)} height={24}
</div> />
Tambah
</Button>
)}
</div>
</RequirePermission>
</td> </td>
</tr> </tr>
</tbody> </tbody>
+113 -87
View File
@@ -28,6 +28,7 @@ import ExpenseStatusBadge from '@/components/pages/expense/ExpenseStatusBadge';
import CheckboxInput from '@/components/input/CheckboxInput'; import CheckboxInput from '@/components/input/CheckboxInput';
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes'; import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import DateInput from '@/components/input/DateInput'; import DateInput from '@/components/input/DateInput';
import RequirePermission from '@/components/helper/RequirePermission';
import { Expense } from '@/types/api/expense'; import { Expense } from '@/types/api/expense';
import { ExpenseApi } from '@/services/api/expense'; import { ExpenseApi } from '@/services/api/expense';
@@ -67,58 +68,70 @@ const RowOptionsMenu = ({
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<div className='w-full max-h-40 overflow-auto flex flex-col gap-1'> <div className='w-full max-h-40 overflow-auto flex flex-col gap-1'>
<Button <RequirePermission permissions='lti.expense.detail'>
href={`/expense/detail/?expenseId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
{showEditButton && (
<Button <Button
href={`/expense/detail/edit/?expenseId=${props.row.original.id}`} href={`/expense/detail/?expenseId=${props.row.original.id}`}
variant='ghost' variant='ghost'
color='warning' color='primary'
className='justify-start text-sm' className='justify-start text-sm'
> >
<Icon icon='material-symbols:edit-outline' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Edit Detail
</Button> </Button>
</RequirePermission>
{showEditButton && (
<RequirePermission permissions='lti.expense.update'>
<Button
href={`/expense/detail/edit/?expenseId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon
icon='material-symbols:edit-outline'
width={16}
height={16}
/>
Edit
</Button>
</RequirePermission>
)} )}
{showRealizationButton && ( {showRealizationButton && (
<Button <RequirePermission permissions='lti.expense.create.realization'>
href={`/expense/realization/?expenseId=${props.row.original.id}`} <Button
variant='ghost' href={`/expense/realization/?expenseId=${props.row.original.id}`}
color='info' variant='ghost'
className='justify-start text-sm text-info focus-visible:text-info-content hover:text-info-content' color='info'
> className='justify-start text-sm text-info focus-visible:text-info-content hover:text-info-content'
<Icon >
icon='material-symbols:money-bag-rounded' <Icon
width={16} icon='material-symbols:money-bag-rounded'
height={16} width={16}
/> height={16}
Realisasi />
</Button> Realisasi
</Button>
</RequirePermission>
)} )}
<Button <RequirePermission permissions='lti.expense.delete'>
onClick={deleteClickHandler} <Button
variant='ghost' onClick={deleteClickHandler}
color='error' variant='ghost'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content' color='error'
> className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={16} icon='material-symbols:delete-outline-rounded'
height={16} width={16}
className='justify-start text-sm' height={16}
/> className='justify-start text-sm'
Delete />
</Button> Delete
</Button>
</RequirePermission>
</div> </div>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -559,57 +572,70 @@ const ExpensesTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-4'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-4'>
<div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'> <div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'>
<Button <RequirePermission permissions='lti.expense.create'>
href='/expense/add' <Button
variant='outline' href='/expense/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
{selectedRowIds.length > 0 && ( {selectedRowIds.length > 0 && (
<> <>
<Button <RequirePermission permissions='lti.expense.approve.manager'>
variant='outline' <Button
color='info' variant='outline'
onClick={bulkApproveClickHandler} color='info'
disabled={!isAllSelectedRowLatestApprovalOnManager} onClick={bulkApproveClickHandler}
className='w-full sm:w-fit' disabled={!isAllSelectedRowLatestApprovalOnManager}
> className='w-full sm:w-fit'
<Icon icon='lucide-lab:farm' width={24} height={24} /> >
Approve Manager <Icon icon='lucide-lab:farm' width={24} height={24} />
</Button> Approve Manager
</Button>
</RequirePermission>
<Button <RequirePermission permissions='lti.expense.approve.finance'>
variant='outline' <Button
color='success' variant='outline'
onClick={bulkApproveClickHandler} color='success'
disabled={!isAllSelectedRowLatestApprovalOnFinance} onClick={bulkApproveClickHandler}
className='w-full sm:w-fit' disabled={!isAllSelectedRowLatestApprovalOnFinance}
> className='w-full sm:w-fit'
<Icon icon='tdesign:money' width={24} height={24} /> >
Approve Finance <Icon icon='tdesign:money' width={24} height={24} />
</Button> Approve Finance
</Button>
</RequirePermission>
<Button <RequirePermission
variant='outline' permissions={[
color='error' 'lti.expense.approve.manager',
onClick={bulkRejectClickHandler} 'lti.expense.approve.finance',
disabled={ ]}
!isAllSelectedRowLatestApprovalOnManager &&
!isAllSelectedRowLatestApprovalOnFinance
}
className='w-full sm:w-fit'
> >
<Icon <Button
icon='material-symbols:close' variant='outline'
width={24} color='error'
height={24} onClick={bulkRejectClickHandler}
/> disabled={
Reject !isAllSelectedRowLatestApprovalOnManager &&
</Button> !isAllSelectedRowLatestApprovalOnFinance
}
className='w-full sm:w-fit'
>
<Icon
icon='material-symbols:close'
width={24}
height={24}
/>
Reject
</Button>
</RequirePermission>
</> </>
)} )}
</div> </div>
@@ -16,6 +16,7 @@ import DateInput from '@/components/input/DateInput';
import DropFileInput from '@/components/input/DropFileInput'; import DropFileInput from '@/components/input/DropFileInput';
import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable'; import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable';
import ExpenseRealizationKandangDetailExpense from '@/components/pages/expense/form/ExpenseRealizationKandangDetailExpense'; import ExpenseRealizationKandangDetailExpense from '@/components/pages/expense/form/ExpenseRealizationKandangDetailExpense';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
CreateExpenseRealizationPayload, CreateExpenseRealizationPayload,
@@ -290,21 +291,23 @@ const ExpenseRealizationForm = ({
className={{ wrapper: 'col-span-12' }} className={{ wrapper: 'col-span-12' }}
/> />
<DropFileInput <RequirePermission permissions='lti.expense.document.realization'>
label='Dokumen Realisasi' <DropFileInput
name='documents' label='Dokumen Realisasi'
values={formik.values.documents} name='documents'
onChange={realizationDocumentsChangeHandler} values={formik.values.documents}
onDelete={realizationDocumentsDeleteHandler} onChange={realizationDocumentsChangeHandler}
accept={{ onDelete={realizationDocumentsDeleteHandler}
...ACCEPTED_FILE_TYPE.PDF, accept={{
...ACCEPTED_FILE_TYPE.IMAGE, ...ACCEPTED_FILE_TYPE.PDF,
}} ...ACCEPTED_FILE_TYPE.IMAGE,
className={{ }}
wrapper: 'col-span-12', className={{
inputWrapper: 'h-12 flex items-center', wrapper: 'col-span-12',
}} inputWrapper: 'h-12 flex items-center',
/> }}
/>
</RequirePermission>
{formik.values.existing_documents && {formik.values.existing_documents &&
formik.values.existing_documents.length > 0 && ( formik.values.existing_documents.length > 0 && (
@@ -357,20 +360,22 @@ const ExpenseRealizationForm = ({
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
{type !== 'edit' && ( {type !== 'edit' && (
<Button <RequirePermission permissions='lti.expense.update'>
type='button' <Button
color='warning' type='button'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`} color='warning'
className='px-4' href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
> className='px-4'
<Icon >
icon='material-symbols:edit-outline' <Icon
width={24} icon='material-symbols:edit-outline'
height={24} width={24}
className='justify-start text-sm' height={24}
/> className='justify-start text-sm'
Edit />
</Button> Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -18,6 +18,7 @@ import DateInput from '@/components/input/DateInput';
import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable'; import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable';
import DropFileInput from '@/components/input/DropFileInput'; import DropFileInput from '@/components/input/DropFileInput';
import ExpenseRequestKandangDetailExpense from '@/components/pages/expense/form/ExpenseRequestKandangDetailExpense'; import ExpenseRequestKandangDetailExpense from '@/components/pages/expense/form/ExpenseRequestKandangDetailExpense';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
ExpenseRequestFormSchema, ExpenseRequestFormSchema,
@@ -385,21 +386,23 @@ const ExpenseRequestForm = ({
className={{ wrapper: 'col-span-12' }} className={{ wrapper: 'col-span-12' }}
/> />
<DropFileInput <RequirePermission permissions='lti.expense.document'>
label='Dokumen Pengajuan' <DropFileInput
name='documents' label='Dokumen Pengajuan'
values={formik.values.documents} name='documents'
onChange={requestDocumentsChangeHandler} values={formik.values.documents}
onDelete={requestDocumentsDeleteHandler} onChange={requestDocumentsChangeHandler}
accept={{ onDelete={requestDocumentsDeleteHandler}
...ACCEPTED_FILE_TYPE.PDF, accept={{
...ACCEPTED_FILE_TYPE.IMAGE, ...ACCEPTED_FILE_TYPE.PDF,
}} ...ACCEPTED_FILE_TYPE.IMAGE,
className={{ }}
wrapper: 'col-span-12', className={{
inputWrapper: 'h-12 flex items-center', wrapper: 'col-span-12',
}} inputWrapper: 'h-12 flex items-center',
/> }}
/>
</RequirePermission>
{formik.values.existing_documents && {formik.values.existing_documents &&
formik.values.existing_documents.length > 0 && ( formik.values.existing_documents.length > 0 && (
@@ -461,36 +464,40 @@ const ExpenseRequestForm = ({
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.expense.delete'>
type='button'
color='error'
onClick={deleteExpenseClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`} onClick={deleteExpenseClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.expense.update'>
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -4,6 +4,7 @@ import Badge from '@/components/Badge';
import Button from '@/components/Button'; import Button from '@/components/Button';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
import Table from '@/components/Table'; import Table from '@/components/Table';
import RequirePermission from '@/components/helper/RequirePermission';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
@@ -175,15 +176,17 @@ const InventoryAdjustmentTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.inventory.create'>
href='/inventory/adjustment/add' <Button
variant='outline' href='/inventory/adjustment/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
{/* <DebouncedTextInput {/* <DebouncedTextInput
name='search' name='search'
@@ -19,6 +19,7 @@ import SelectInput from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
const RowOptionsMenu = ({ const RowOptionsMenu = ({
type = 'dropdown', type = 'dropdown',
@@ -28,15 +29,17 @@ const RowOptionsMenu = ({
props: CellContext<Movement, unknown>; props: CellContext<Movement, unknown>;
}) => ( }) => (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.inventory.transfer.detail'>
href={`/inventory/movement/detail/?movementId=${props.row.original.id}`} <Button
variant='ghost' href={`/inventory/movement/detail/?movementId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
> className='justify-start text-sm'
<Icon icon='mdi:eye-outline' width={16} height={16} /> >
Detail <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -145,15 +148,17 @@ const MovementTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row gap-2'> <div className='w-full flex flex-row gap-2'>
<Button <RequirePermission permissions='lti.inventory.transfer.create'>
href='/inventory/movement/add' <Button
variant='outline' href='/inventory/movement/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -7,6 +7,7 @@ import Table from '@/components/Table';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { cn, formatCurrency, formatNumber } from '@/lib/helper'; import { cn, formatCurrency, formatNumber } from '@/lib/helper';
@@ -31,15 +32,17 @@ const RowOptionsMenu = ({
props: CellContext<InventoryProduct, unknown>; props: CellContext<InventoryProduct, unknown>;
}) => ( }) => (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.inventory.product_stock.detail'>
href={`/inventory/product/detail?inventoryProductId=${props.row.original.id}`} <Button
variant='ghost' href={`/inventory/product/detail?inventoryProductId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
> className='justify-start text-sm'
<Icon icon='mdi:eye-outline' width={16} height={16} /> >
Detail <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -26,6 +26,8 @@ import { useRouter } from 'next/navigation';
import { useCallback, useState } from 'react'; import { useCallback, useState } from 'react';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import useSWR from 'swr'; import useSWR from 'swr';
import RequirePermission from '@/components/helper/RequirePermission';
import { useAuth } from '@/services/hooks/useAuth';
const RowsOptionsMenu = ({ const RowsOptionsMenu = ({
type = 'dropdown', type = 'dropdown',
@@ -50,57 +52,71 @@ const RowsOptionsMenu = ({
)} )}
> >
<div className='flex flex-col gap-1'> <div className='flex flex-col gap-1'>
<Button <RequirePermission permissions='lti.marketing.delivery_order.detail'>
href={`/marketing/detail?marketingId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
{props.row.original.latest_approval.step_number != 1 && (
<Button <Button
href={ href={`/marketing/detail?marketingId=${props.row.original.id}`}
props.row.original.latest_approval.step_number == 3
? `/marketing/detail/delivery-orders/edit?marketingId=${props.row.original.id}`
: props.row.original.latest_approval.step_number == 2
? `/marketing/add/delivery-orders?marketingId=${props.row.original.id}`
: undefined
}
onClick={() => {
if (props.row.original.latest_approval.step_number == 2) {
deliveryClickHandler?.();
}
}}
variant='ghost' variant='ghost'
color='success' color='primary'
className='justify-start text-sm' className='justify-start text-sm'
> >
<Icon icon='mdi:truck' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Deliver Detail
</Button> </Button>
</RequirePermission>
{props.row.original.latest_approval.step_number != 1 && (
<RequirePermission
permissions={
props.row.original.latest_approval.step_number == 3
? 'lti.marketing.delivery_order.update'
: 'lti.marketing.delivery_order.create'
}
>
<Button
href={
props.row.original.latest_approval.step_number == 3
? `/marketing/detail/delivery-orders/edit?marketingId=${props.row.original.id}`
: props.row.original.latest_approval.step_number == 2
? `/marketing/add/delivery-orders?marketingId=${props.row.original.id}`
: undefined
}
onClick={() => {
if (props.row.original.latest_approval.step_number == 2) {
deliveryClickHandler?.();
}
}}
variant='ghost'
color='success'
className='justify-start text-sm'
>
<Icon icon='mdi:truck' width={16} height={16} />
Deliver
</Button>
</RequirePermission>
)} )}
{props.row.original.latest_approval.step_number != 3 && ( {props.row.original.latest_approval.step_number != 3 && (
<Button <RequirePermission permissions='lti.marketing.sales_order.update'>
href={`/marketing/detail/sales-orders/edit?marketingId=${props.row.original.id}`} <Button
variant='ghost' href={`/marketing/detail/sales-orders/edit?marketingId=${props.row.original.id}`}
color='warning' variant='ghost'
className='justify-start text-sm' color='warning'
> className='justify-start text-sm'
<Icon icon='mdi:pencil-outline' width={16} height={16} /> >
Edit <Icon icon='mdi:pencil-outline' width={16} height={16} />
</Button> Edit
</Button>
</RequirePermission>
)} )}
<Button <RequirePermission permissions='lti.marketing.sales_order.delete'>
onClick={deleteClickHandler} <Button
variant='ghost' onClick={deleteClickHandler}
color='error' variant='ghost'
className='text-error hover:text-inherit justify-start text-sm' color='error'
> className='text-error hover:text-inherit justify-start text-sm'
<Icon icon='mdi:delete-outline' width={16} height={16} /> >
Delete <Icon icon='mdi:delete-outline' width={16} height={16} />
</Button> Delete
</Button>
</RequirePermission>
</div> </div>
</div> </div>
); );
@@ -116,6 +132,7 @@ const MarketingTable = () => {
); );
const [selectedItem, setSelectedItem] = useState<Marketing | null>(null); const [selectedItem, setSelectedItem] = useState<Marketing | null>(null);
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({}); const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
const { permissionCheck } = useAuth();
const router = useRouter(); const router = useRouter();
@@ -270,10 +287,14 @@ const MarketingTable = () => {
<div className='flex flex-col gap-4'> <div className='flex flex-col gap-4'>
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<TableToolbar <TableToolbar
addButton={{ addButton={
href: '/marketing/add/sales-orders', permissionCheck('lti.marketing.sales_order.create')
label: 'Tambah Sales Order', ? {
}} href: '/marketing/add/sales-orders',
label: 'Tambah Sales Order',
}
: undefined
}
search={{ search={{
value: search, value: search,
onChange: searchChangeHandler, onChange: searchChangeHandler,
@@ -281,25 +302,29 @@ const MarketingTable = () => {
}} }}
/> />
<div className='flex flex-row gap-2'> <div className='flex flex-row gap-2'>
<Button <RequirePermission permissions='lti.marketing.sales_order.approve'>
color='success' <Button
onClick={approveClickHandler} color='success'
className='justify-start text-sm' onClick={approveClickHandler}
disabled={disableApprove} className='justify-start text-sm'
> disabled={disableApprove}
<Icon icon='material-symbols:check' width={24} height={24} /> >
Approve <Icon icon='material-symbols:check' width={24} height={24} />
</Button> Approve
</Button>
</RequirePermission>
<Button <RequirePermission permissions='lti.marketing.sales_order.approve'>
color='error' <Button
onClick={rejectClickHandler} color='error'
className='justify-start text-sm' onClick={rejectClickHandler}
disabled={disableReject} className='justify-start text-sm'
> disabled={disableReject}
<Icon icon='material-symbols:close' width={24} height={24} /> >
Reject <Icon icon='material-symbols:close' width={24} height={24} />
</Button> Reject
</Button>
</RequirePermission>
</div> </div>
<TableRowSizeSelector <TableRowSizeSelector
value={pageSize} value={pageSize}
@@ -33,6 +33,7 @@ import { useState } from 'react';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import SalesOrderExport from '@/components/pages/marketing/pdf/SalesOrderExport'; import SalesOrderExport from '@/components/pages/marketing/pdf/SalesOrderExport';
import DeliveryOrderExport from '@/components/pages/marketing/pdf/DeliveryOrderExport'; import DeliveryOrderExport from '@/components/pages/marketing/pdf/DeliveryOrderExport';
import RequirePermission from '@/components/helper/RequirePermission';
const MarketingDetail = ({ const MarketingDetail = ({
initialValues, initialValues,
@@ -134,45 +135,58 @@ const MarketingDetail = ({
<div className='flex-row flex gap-3'> <div className='flex-row flex gap-3'>
{initialValues?.latest_approval?.step_number == 1 && ( {initialValues?.latest_approval?.step_number == 1 && (
<> <>
<Button <RequirePermission permissions='lti.marketing.sales_order.approve'>
color='success' <Button
onClick={approveClickHandler} color='success'
disabled={ onClick={approveClickHandler}
initialValues?.latest_approval?.step_number == 1 && disabled={
initialValues?.latest_approval?.action == 'REJECTED' initialValues?.latest_approval?.step_number == 1 &&
} initialValues?.latest_approval?.action == 'REJECTED'
> }
<Icon icon='mdi:check' width={24} height={24} /> >
Approve <Icon icon='mdi:check' width={24} height={24} />
</Button> Approve
<Button </Button>
color='error' </RequirePermission>
onClick={rejectClickHandler}
disabled={ <RequirePermission permissions='lti.marketing.sales_order.approve'>
initialValues?.latest_approval?.step_number == 1 && <Button
initialValues?.latest_approval?.action == 'REJECTED' color='error'
} onClick={rejectClickHandler}
> disabled={
<Icon icon='mdi:close' width={24} height={24} /> initialValues?.latest_approval?.step_number == 1 &&
Reject initialValues?.latest_approval?.action == 'REJECTED'
</Button> }
>
<Icon icon='mdi:close' width={24} height={24} />
Reject
</Button>
</RequirePermission>
</> </>
)} )}
{initialValues?.latest_approval?.step_number != 1 && ( {initialValues?.latest_approval?.step_number != 1 && (
<Button <RequirePermission
color='success' permissions={
href={
initialValues?.latest_approval?.step_number == 3 initialValues?.latest_approval?.step_number == 3
? `/marketing/detail/delivery-orders/edit?marketingId=${initialValues?.id}` ? 'lti.marketing.delivery_order.update'
: `/marketing/add/delivery-orders?marketingId=${initialValues?.id}` : 'lti.marketing.delivery_order.create'
} }
> >
<Icon icon='mdi:truck' width={24} height={24} /> <Button
{initialValues?.latest_approval?.step_number == 3 color='success'
? 'Edit ' href={
: 'Tambah '} initialValues?.latest_approval?.step_number == 3
Delivery Order ? `/marketing/detail/delivery-orders/edit?marketingId=${initialValues?.id}`
</Button> : `/marketing/add/delivery-orders?marketingId=${initialValues?.id}`
}
>
<Icon icon='mdi:truck' width={24} height={24} />
{initialValues?.latest_approval?.step_number == 3
? 'Edit '
: 'Tambah '}
Delivery Order
</Button>
</RequirePermission>
)} )}
</div> </div>
@@ -413,19 +427,23 @@ const MarketingDetail = ({
)} )}
<div className='flex flex-row gap-3'> <div className='flex flex-row gap-3'>
{initialValues?.latest_approval?.step_number != 3 && ( {initialValues?.latest_approval?.step_number != 3 && (
<Button <RequirePermission permissions='lti.marketing.sales_order.update'>
color='warning' <Button
type='button' color='warning'
href={`/marketing/detail/${initialValues?.latest_approval.step_number == 3 ? 'delivery-orders' : 'sales-orders'}/edit?marketingId=${initialValues?.id}`} type='button'
> href={`/marketing/detail/${initialValues?.latest_approval.step_number == 3 ? 'delivery-orders' : 'sales-orders'}/edit?marketingId=${initialValues?.id}`}
<Icon icon='mdi:pencil' width={24} height={24} /> >
Edit <Icon icon='mdi:pencil' width={24} height={24} />
</Button> Edit
</Button>
</RequirePermission>
)} )}
<Button color='error' onClick={deleteClickHandler}> <RequirePermission permissions='lti.marketing.sales_order.delete'>
<Icon icon='mdi:delete' width={24} height={24} /> <Button color='error' onClick={deleteClickHandler}>
Hapus <Icon icon='mdi:delete' width={24} height={24} />
</Button> Hapus
</Button>
</RequirePermission>
</div> </div>
</div> </div>
<ConfirmationModal <ConfirmationModal
@@ -47,6 +47,7 @@ import DeliveryOrderProductTable from '@/components/pages/marketing/form/table-v
import DeliveryOrderProductForm from '@/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct'; import DeliveryOrderProductForm from '@/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct';
import { SalesOrderProductFormValues } from '@/components/pages/marketing/form/repeater/sales-order/SalesOrderProduct.schema'; import { SalesOrderProductFormValues } from '@/components/pages/marketing/form/repeater/sales-order/SalesOrderProduct.schema';
import { DeliveryOrderProductFormValues } from '@/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct.schema'; import { DeliveryOrderProductFormValues } from '@/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct.schema';
import RequirePermission from '@/components/helper/RequirePermission';
const MemoizedSalesOrderProductTable = memo(SalesOrderProductTable); const MemoizedSalesOrderProductTable = memo(SalesOrderProductTable);
const MemoizedSalesOrderProductForm = memo(SalesOrderProductForm); const MemoizedSalesOrderProductForm = memo(SalesOrderProductForm);
@@ -689,15 +690,17 @@ const MarketingForm = ({
{/* Actions button */} {/* Actions button */}
{formType == 'edit' && ( {formType == 'edit' && (
<div className='flex flex-row justify-start'> <div className='flex flex-row justify-start'>
<Button <RequirePermission permissions='lti.marketing.sales_order.delete'>
type='button' <Button
color='error' type='button'
onClick={handleDelete} color='error'
isLoading={isLoading} onClick={handleDelete}
> isLoading={isLoading}
<Icon icon='mdi:trash' width={24} height={24} /> >
Hapus <Icon icon='mdi:trash' width={24} height={24} />
</Button> Hapus
</Button>
</RequirePermission>
</div> </div>
)} )}
@@ -15,6 +15,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Area } from '@/types/api/master-data/area'; import { Area } from '@/types/api/master-data/area';
import { AreaApi } from '@/services/api/master-data'; import { AreaApi } from '@/services/api/master-data';
@@ -34,40 +35,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.area.detail'>
href={`/master-data/area/detail/?areaId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/area/detail/?areaId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/area/detail/edit/?areaId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.area.update'>
<Button
href={`/master-data/area/detail/edit/?areaId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.area.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -192,15 +199,19 @@ const AreasTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <div className='w-full flex flex-row'>
href='/master-data/area/add' <RequirePermission permissions='lti.master.area.create'>
variant='outline' <Button
color='primary' href='/master-data/area/add'
className='w-full sm:w-fit' variant='outline'
> color='primary'
<Icon icon='ic:round-plus' width={24} height={24} /> className='w-full sm:w-fit'
Tambah >
</Button> <Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
</RequirePermission>
</div>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -10,6 +10,7 @@ import Button from '@/components/Button';
import TextInput from '@/components/input/TextInput'; import TextInput from '@/components/input/TextInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
AreaFormSchema, AreaFormSchema,
@@ -160,36 +161,40 @@ const AreaForm = ({ type = 'add', initialValues }: AreaFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.area.delete'>
type='button'
color='error'
onClick={deleteAreaClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/area/detail/edit/?areaId=${initialValues?.id}`} onClick={deleteAreaClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.area.update'>
<Button
type='button'
color='warning'
href={`/master-data/area/detail/edit/?areaId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -15,6 +15,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Bank } from '@/types/api/master-data/bank'; import { Bank } from '@/types/api/master-data/bank';
import { BankApi } from '@/services/api/master-data'; import { BankApi } from '@/services/api/master-data';
@@ -34,40 +35,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.banks.detail'>
href={`/master-data/bank/detail/?bankId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/bank/detail/?bankId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/bank/detail/edit/?bankId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.banks.update'>
<Button
href={`/master-data/bank/detail/edit/?bankId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.banks.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -205,15 +212,17 @@ const BanksTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.banks.create'>
href='/master-data/bank/add' <Button
variant='outline' href='/master-data/bank/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -10,6 +10,7 @@ import Button from '@/components/Button';
import TextInput from '@/components/input/TextInput'; import TextInput from '@/components/input/TextInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
BankFormSchema, BankFormSchema,
@@ -208,36 +209,40 @@ const BankForm = ({ type = 'add', initialValues }: BankFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.banks.delete'>
type='button'
color='error'
onClick={deleteBankClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/bank/detail/edit/?bankId=${initialValues?.id}`} onClick={deleteBankClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.banks.update'>
<Button
type='button'
color='warning'
href={`/master-data/bank/detail/edit/?bankId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -9,6 +9,7 @@ import Table from '@/components/Table';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
@@ -32,38 +33,44 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.customer.detail'>
href={`/master-data/customer/detail/?customerId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/customer/detail/?customerId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/customer/detail/edit/?customerId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.customer.update'>
<Button
href={`/master-data/customer/detail/edit/?customerId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.customer.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -200,15 +207,17 @@ const CustomersTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.customer.create'>
href='/master-data/customer/add' <Button
variant='outline' href='/master-data/customer/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -27,6 +27,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import useSWR from 'swr'; import useSWR from 'swr';
import { UserApi } from '@/services/api/user'; import { UserApi } from '@/services/api/user';
import { TYPE_OPTIONS } from '@/config/constant'; import { TYPE_OPTIONS } from '@/config/constant';
import RequirePermission from '@/components/helper/RequirePermission';
interface CustomerFormProps { interface CustomerFormProps {
formType?: 'add' | 'edit' | 'detail'; formType?: 'add' | 'edit' | 'detail';
@@ -319,36 +320,40 @@ const CustomerForm = ({
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{formType !== 'add' && ( {formType !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.customer.delete'>
type='button'
color='error'
onClick={deleteCustomerHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{formType !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/customer/detail/edit/?customerId=${initialValues?.id}`} onClick={deleteCustomerHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{formType !== 'edit' && (
<RequirePermission permissions='lti.master.customer.update'>
<Button
type='button'
color='warning'
href={`/master-data/customer/detail/edit/?customerId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -15,6 +15,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Fcr } from '@/types/api/master-data/fcr'; import { Fcr } from '@/types/api/master-data/fcr';
import { FcrApi } from '@/services/api/master-data'; import { FcrApi } from '@/services/api/master-data';
@@ -34,40 +35,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.fcr.detail'>
href={`/master-data/fcr/detail/?fcrId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/fcr/detail/?fcrId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/fcr/detail/edit/?fcrId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.fcr.update'>
<Button
href={`/master-data/fcr/detail/edit/?fcrId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.fcr.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -192,15 +199,17 @@ const FcrsTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.fcr.create'>
href='/master-data/fcr/add' <Button
variant='outline' href='/master-data/fcr/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -10,6 +10,7 @@ import Button from '@/components/Button';
import TextInput from '@/components/input/TextInput'; import TextInput from '@/components/input/TextInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
FcrFormSchema, FcrFormSchema,
@@ -296,36 +297,40 @@ const FcrForm = ({ type = 'add', initialValues }: FcrFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.fcr.delete'>
type='button'
color='error'
onClick={deleteFcrClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/fcr/detail/edit/?fcrId=${initialValues?.id}`} onClick={deleteFcrClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.fcr.update'>
<Button
type='button'
color='warning'
href={`/master-data/fcr/detail/edit/?fcrId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -13,6 +13,7 @@ import { useModal } from '@/components/Modal';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import DebouncedTextInput from '@/components/input/DebouncedTextInput'; import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
@@ -32,48 +33,54 @@ const RowsOptions = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.flocks.update'>
href={`/master-data/flock/detail/edit/?flockId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/flock/detail/edit/?flockId=${props.row.original.id}`}
color='warning' variant='ghost'
className='justify-start text-sm' color='warning'
>
<Icon
icon='material-symbols:edit-outline'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Edit <Icon
</Button> icon='material-symbols:edit-outline'
<Button width={16}
href={`/master-data/flock/detail/?flockId=${props.row.original.id}`} height={16}
variant='ghost' className='justify-start text-sm'
color='primary' />
className='justify-start text-sm' Edit
> </Button>
<Icon </RequirePermission>
icon='mdi:eye-outline' <RequirePermission permissions='lti.master.flocks.detail'>
width={16} <Button
height={16} href={`/master-data/flock/detail/?flockId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm' className='justify-start text-sm'
/> >
Detail <Icon
</Button> icon='mdi:eye-outline'
<Button width={16}
onClick={deleteClickHandler} height={16}
variant='ghost' className='justify-start text-sm'
color='error' />
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content' Detail
> </Button>
<Icon </RequirePermission>
icon='material-symbols:delete-outline-rounded' <RequirePermission permissions='lti.master.flocks.delete'>
width={16} <Button
height={16} onClick={deleteClickHandler}
className='justify-start text-sm' variant='ghost'
/> color='error'
Delete className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
</Button> >
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -196,15 +203,17 @@ const FlockTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.flocks.create'>
href='/master-data/flock/add' <Button
variant='outline' href='/master-data/flock/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -16,6 +16,7 @@ import { Icon } from '@iconify/react';
import TextInput from '@/components/input/TextInput'; import TextInput from '@/components/input/TextInput';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
interface FlockCustomProps { interface FlockCustomProps {
formType?: 'add' | 'edit' | 'detail'; formType?: 'add' | 'edit' | 'detail';
@@ -130,35 +131,39 @@ const FlockForm = ({ formType = 'add', initialValues }: FlockCustomProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{formType !== 'add' && ( {formType !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.flocks.delete'>
type='button'
color='error'
onClick={() => deleteModal.openModal()}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{formType !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/flock/detail/edit/?flockId=${initialValues?.id}`} onClick={() => deleteModal.openModal()}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{formType !== 'edit' && (
<RequirePermission permissions='lti.master.flocks.update'>
<Button
type='button'
color='warning'
href={`/master-data/flock/detail/edit/?flockId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -20,6 +20,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Kandang } from '@/types/api/master-data/kandang'; import { Kandang } from '@/types/api/master-data/kandang';
import { KandangApi } from '@/services/api/master-data'; import { KandangApi } from '@/services/api/master-data';
@@ -39,40 +40,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.kandangs.detail'>
href={`/master-data/kandang/detail/?kandangId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/kandang/detail/?kandangId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/kandang/detail/edit/?kandangId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.kandangs.update'>
<Button
href={`/master-data/kandang/detail/edit/?kandangId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.kandangs.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -243,15 +250,19 @@ const KandangsTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <div className='w-full flex flex-row'>
href='/master-data/kandang/add' <RequirePermission permissions='lti.master.kandangs.create'>
variant='outline' <Button
color='primary' href='/master-data/kandang/add'
className='w-full sm:w-fit' variant='outline'
> color='primary'
<Icon icon='ic:round-plus' width={24} height={24} /> className='w-full sm:w-fit'
Tambah >
</Button> <Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
</RequirePermission>
</div>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -12,6 +12,7 @@ import TextInput from '@/components/input/TextInput';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
KandangFormSchema, KandangFormSchema,
@@ -285,36 +286,40 @@ const KandangForm = ({ type = 'add', initialValues }: KandangFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.kandangs.delete'>
type='button'
color='error'
onClick={deleteKandangClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/kandang/detail/edit/?kandangId=${initialValues?.id}`} onClick={deleteKandangClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.kandangs.update'>
<Button
type='button'
color='warning'
href={`/master-data/kandang/detail/edit/?kandangId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -20,6 +20,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Location } from '@/types/api/master-data/location'; import { Location } from '@/types/api/master-data/location';
import { LocationApi } from '@/services/api/master-data'; import { LocationApi } from '@/services/api/master-data';
@@ -39,40 +40,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.locations.detail'>
href={`/master-data/location/detail/?locationId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/location/detail/?locationId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/location/detail/edit/?locationId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.locations.update'>
<Button
href={`/master-data/location/detail/edit/?locationId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.locations.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -230,15 +237,19 @@ const LocationsTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <div className='w-full flex flex-row'>
href='/master-data/location/add' <RequirePermission permissions='lti.master.locations.create'>
variant='outline' <Button
color='primary' href='/master-data/location/add'
className='w-full sm:w-fit' variant='outline'
> color='primary'
<Icon icon='ic:round-plus' width={24} height={24} /> className='w-full sm:w-fit'
Tambah >
</Button> <Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
</RequirePermission>
</div>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -12,6 +12,7 @@ import TextInput from '@/components/input/TextInput';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
LocationFormSchema, LocationFormSchema,
@@ -229,36 +230,40 @@ const LocationForm = ({ type = 'add', initialValues }: LocationFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.locations.delete'>
type='button'
color='error'
onClick={deleteLocationClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/location/detail/edit/?locationId=${initialValues?.id}`} onClick={deleteLocationClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.locations.update'>
<Button
type='button'
color='warning'
href={`/master-data/location/detail/edit/?locationId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -20,6 +20,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Nonstock } from '@/types/api/master-data/nonstock'; import { Nonstock } from '@/types/api/master-data/nonstock';
import { NonstockApi } from '@/services/api/master-data'; import { NonstockApi } from '@/services/api/master-data';
@@ -39,40 +40,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.nonstocks.detail'>
href={`/master-data/nonstock/detail/?nonstockId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/nonstock/detail/?nonstockId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/nonstock/detail/edit/?nonstockId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.nonstocks.update'>
<Button
href={`/master-data/nonstock/detail/edit/?nonstockId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.nonstocks.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -242,15 +249,17 @@ const NonstocksTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.nonstocks.create'>
href='/master-data/nonstock/add' <Button
variant='outline' href='/master-data/nonstock/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -12,6 +12,7 @@ import TextInput from '@/components/input/TextInput';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
NonstockFormSchema, NonstockFormSchema,
@@ -298,36 +299,40 @@ const NonstockForm = ({ type = 'add', initialValues }: NonstockFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.nonstocks.delete'>
type='button'
color='error'
onClick={deleteNonstockClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/nonstock/detail/edit/?nonstockId=${initialValues?.id}`} onClick={deleteNonstockClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.nonstocks.update'>
<Button
type='button'
color='warning'
href={`/master-data/nonstock/detail/edit/?nonstockId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -15,6 +15,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { ProductCategory } from '@/types/api/master-data/product-category'; import { ProductCategory } from '@/types/api/master-data/product-category';
import { ProductCategoryApi } from '@/services/api/master-data'; import { ProductCategoryApi } from '@/services/api/master-data';
@@ -34,38 +35,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.product_categories.detail'>
href={`/master-data/product-category/detail/?productCategoryId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/product-category/detail/?productCategoryId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/product-category/detail/edit/?productCategoryId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='mdi:pencil-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='mdi:delete-outline'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.product_categories.update'>
<Button
href={`/master-data/product-category/detail/edit/?productCategoryId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='mdi:pencil-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.product_categories.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='mdi:delete-outline'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -193,15 +202,17 @@ const ProductCategoryTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.product_categories.create'>
href='/master-data/product-category/add' <Button
variant='outline' href='/master-data/product-category/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
name='search' name='search'
@@ -10,6 +10,7 @@ import Button from '@/components/Button';
import TextInput from '@/components/input/TextInput'; import TextInput from '@/components/input/TextInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
ProductCategoryFormSchema, ProductCategoryFormSchema,
@@ -183,36 +184,40 @@ const ProductCategoryForm = ({
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.product_categories.delete'>
type='button'
color='error'
onClick={deleteProductCategoryClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/product-category/detail/edit/?productCategoryId=${initialValues?.id}`} onClick={deleteProductCategoryClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.product_categories.update'>
<Button
type='button'
color='warning'
href={`/master-data/product-category/detail/edit/?productCategoryId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -20,6 +20,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Product } from '@/types/api/master-data/product'; import { Product } from '@/types/api/master-data/product';
import { ProductApi } from '@/services/api/master-data'; import { ProductApi } from '@/services/api/master-data';
@@ -38,38 +39,44 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void; deleteClickHandler: () => void;
}) => ( }) => (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.products.detail'>
href={`/master-data/product/detail/?productId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/product/detail/?productId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/product/detail/edit/?productId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.products.update'>
<Button
href={`/master-data/product/detail/edit/?productId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.products.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -273,15 +280,17 @@ const ProductsTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.products.create'>
href='/master-data/product/add' <Button
variant='outline' href='/master-data/product/add'
className='w-full sm:w-fit' variant='outline'
color='primary' className='w-full sm:w-fit'
> color='primary'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
name='search' name='search'
@@ -16,6 +16,7 @@ import SelectInput, {
} from '@/components/input/SelectInput'; } from '@/components/input/SelectInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
ProductFormSchema, ProductFormSchema,
@@ -413,35 +414,39 @@ const ProductForm = ({ type = 'add', initialValues }: ProductFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.products.delete'>
type='button'
color='error'
onClick={deleteProductClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/product/detail/edit/?productId=${initialValues?.id}`} onClick={deleteProductClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.products.update'>
<Button
type='button'
color='warning'
href={`/master-data/product/detail/edit/?productId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -9,6 +9,7 @@ import Table from '@/components/Table';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { ROWS_OPTIONS } from '@/config/constant'; import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
@@ -32,48 +33,54 @@ const RowOptions = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.suppliers.detail'>
href={`/master-data/supplier/detail/?supplierId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/supplier/detail/?supplierId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon
icon='mdi:eye-outline'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Detail <Icon
</Button> icon='mdi:eye-outline'
<Button width={16}
href={`/master-data/supplier/detail/edit/?supplierId=${props.row.original.id}`} height={16}
variant='ghost' className='justify-start text-sm'
color='warning' />
className='justify-start text-sm' Detail
> </Button>
<Icon </RequirePermission>
icon='material-symbols:edit-outline' <RequirePermission permissions='lti.master.suppliers.update'>
width={16} <Button
height={16} href={`/master-data/supplier/detail/edit/?supplierId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm' className='justify-start text-sm'
/> >
Edit <Icon
</Button> icon='material-symbols:edit-outline'
<Button width={16}
onClick={deleteClickHandler} height={16}
variant='ghost' className='justify-start text-sm'
color='error' />
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content' Edit
> </Button>
<Icon </RequirePermission>
icon='material-symbols:delete-outline-rounded' <RequirePermission permissions='lti.master.suppliers.delete'>
width={16} <Button
height={16} onClick={deleteClickHandler}
className='justify-start text-sm' variant='ghost'
/> color='error'
Delete className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
</Button> >
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -219,15 +226,17 @@ const SuppliersTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.suppliers.create'>
href='/master-data/supplier/add' <Button
variant='outline' href='/master-data/supplier/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -24,6 +24,7 @@ import TextInput from '@/components/input/TextInput';
import TextArea from '@/components/input/TextArea'; import TextArea from '@/components/input/TextArea';
import { cn } from '@/lib/helper'; import { cn } from '@/lib/helper';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
interface SupplierCustomProps { interface SupplierCustomProps {
formType?: 'add' | 'edit' | 'detail'; formType?: 'add' | 'edit' | 'detail';
@@ -406,36 +407,40 @@ const SupplierForm = ({
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{formType !== 'add' && ( {formType !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.suppliers.delete'>
type='button'
color='error'
onClick={deleteSupplierHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{formType !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/supplier/detail/edit/?supplierId=${initialValues?.id}`} onClick={deleteSupplierHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{formType !== 'edit' && (
<RequirePermission permissions='lti.master.suppliers.update'>
<Button
type='button'
color='warning'
href={`/master-data/supplier/detail/edit/?supplierId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -15,6 +15,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Uom } from '@/types/api/master-data/uom'; import { Uom } from '@/types/api/master-data/uom';
import { UomApi } from '@/services/api/master-data'; import { UomApi } from '@/services/api/master-data';
@@ -34,40 +35,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.uoms.detail'>
href={`/master-data/uom/detail/?uomId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/uom/detail/?uomId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/uom/detail/edit/?uomId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.uoms.update'>
<Button
href={`/master-data/uom/detail/edit/?uomId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.uoms.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -192,15 +199,17 @@ const UomsTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.uoms.create'>
href='/master-data/uom/add' <Button
variant='outline' href='/master-data/uom/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -10,6 +10,7 @@ import Button from '@/components/Button';
import TextInput from '@/components/input/TextInput'; import TextInput from '@/components/input/TextInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
UomFormSchema, UomFormSchema,
@@ -160,36 +161,40 @@ const UomForm = ({ type = 'add', initialValues }: UomFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.uoms.delete'>
type='button'
color='error'
onClick={deleteUomClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/uom/detail/edit/?uomId=${initialValues?.id}`} onClick={deleteUomClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.uoms.update'>
<Button
type='button'
color='warning'
href={`/master-data/uom/detail/edit/?uomId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -20,6 +20,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Warehouse } from '@/types/api/master-data/warehouse'; import { Warehouse } from '@/types/api/master-data/warehouse';
import { WarehouseApi } from '@/services/api/master-data'; import { WarehouseApi } from '@/services/api/master-data';
@@ -39,40 +40,46 @@ const RowOptionsMenu = ({
}) => { }) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.master.warehouses.detail'>
href={`/master-data/warehouse/detail/?warehouseId=${props.row.original.id}`} <Button
variant='ghost' href={`/master-data/warehouse/detail/?warehouseId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/master-data/warehouse/detail/edit/?warehouseId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm' className='justify-start text-sm'
/> >
Delete <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.warehouses.update'>
<Button
href={`/master-data/warehouse/detail/edit/?warehouseId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
<RequirePermission permissions='lti.master.warehouses.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -270,15 +277,17 @@ const WarehousesTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'> <div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'> <div className='w-full flex flex-row'>
<Button <RequirePermission permissions='lti.master.warehouses.create'>
href='/master-data/warehouse/add' <Button
variant='outline' href='/master-data/warehouse/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -12,6 +12,7 @@ import TextInput from '@/components/input/TextInput';
import SelectInput, { OptionType } from '@/components/input/SelectInput'; import SelectInput, { OptionType } from '@/components/input/SelectInput';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModal from '@/components/modal/ConfirmationModal';
import RequirePermission from '@/components/helper/RequirePermission';
import { import {
WarehouseFormSchema, WarehouseFormSchema,
@@ -435,36 +436,40 @@ const WarehouseForm = ({ type = 'add', initialValues }: WarehouseFormProps) => {
<div className='flex flex-row justify-between gap-2 flex-wrap'> <div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
<Button <RequirePermission permissions='lti.master.warehouses.delete'>
type='button'
color='error'
onClick={deleteWarehouseClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<Button <Button
type='button' type='button'
color='warning' color='error'
href={`/master-data/warehouse/detail/edit/?warehouseId=${initialValues?.id}`} onClick={deleteWarehouseClickHandler}
className='px-4' className='px-4'
> >
<Icon <Icon
icon='material-symbols:edit-outline' icon='material-symbols:delete-outline-rounded'
width={24} width={24}
height={24} height={24}
className='justify-start text-sm' className='justify-start text-sm'
/> />
Edit Delete
</Button> </Button>
</RequirePermission>
{type !== 'edit' && (
<RequirePermission permissions='lti.master.warehouses.update'>
<Button
type='button'
color='warning'
href={`/master-data/warehouse/detail/edit/?warehouseId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -25,6 +25,8 @@ import { ChangeEventHandler, useEffect, useMemo, useState } from 'react';
import toast from 'react-hot-toast'; import toast from 'react-hot-toast';
import useSWR from 'swr'; import useSWR from 'swr';
import RequirePermission from '@/components/helper/RequirePermission';
const RowOptionsMenu = ({ const RowOptionsMenu = ({
type = 'dropdown', type = 'dropdown',
props, props,
@@ -46,50 +48,58 @@ const RowOptionsMenu = ({
)} )}
> >
<div className='flex flex-col gap-1'> <div className='flex flex-col gap-1'>
<Button <RequirePermission permissions='lti.production.project_flocks.detail'>
href={`/production/project-flock/detail?projectFlockId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
{props.row.original.approval.step_name === 'Aktif' && (
<Button <Button
href={`/production/project-flock/chickin/add?projectFlockId=${props.row.original.id}`} href={`/production/project-flock/detail?projectFlockId=${props.row.original.id}`}
variant='ghost' variant='ghost'
color='success' color='primary'
className='justify-start text-sm' className='justify-start text-sm'
> >
<Icon icon='mdi:home-import-outline' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Chickin Detail
</Button> </Button>
</RequirePermission>
{props.row.original.approval.step_name === 'Aktif' && (
<RequirePermission permissions='lti.production.chickins.create'>
<Button
href={`/production/project-flock/chickin/add?projectFlockId=${props.row.original.id}`}
variant='ghost'
color='success'
className='justify-start text-sm'
>
<Icon icon='mdi:home-import-outline' width={16} height={16} />
Chickin
</Button>
</RequirePermission>
)} )}
{props.row.original.approval.step_name === 'Pengajuan' && ( {props.row.original.approval.step_name === 'Pengajuan' && (
<Button <RequirePermission permissions='lti.production.project_flocks.update'>
href={`/production/project-flock/detail/edit?projectFlockId=${props.row.original.id}`} <Button
variant='ghost' href={`/production/project-flock/detail/edit?projectFlockId=${props.row.original.id}`}
color='warning' variant='ghost'
className='justify-start text-sm' color='warning'
> className='justify-start text-sm'
<Icon icon='mdi:pencil-outline' width={16} height={16} /> >
Edit <Icon icon='mdi:pencil-outline' width={16} height={16} />
</Button> Edit
</Button>
</RequirePermission>
)} )}
<Button <RequirePermission permissions='lti.production.project_flocks.delete'>
onClick={deleteClickHandler} <Button
variant='ghost' onClick={deleteClickHandler}
color='error' variant='ghost'
className='text-error hover:text-inherit justify-start text-sm' color='error'
> className='text-error hover:text-inherit justify-start text-sm'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={16} icon='material-symbols:delete-outline-rounded'
height={16} width={16}
/> height={16}
Delete />
</Button> Delete
</Button>
</RequirePermission>
</div> </div>
</div> </div>
); );
@@ -287,14 +297,16 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col justify-between items-end gap-2'> <div className='w-full flex flex-col justify-between items-end gap-2'>
<div className='flex flex-col sm:flex-row gap-3 w-full'> <div className='flex flex-col sm:flex-row gap-3 w-full'>
<Button <RequirePermission permissions='lti.production.project_flocks.create'>
color='primary' <Button
className='w-full sm:w-fit' color='primary'
href='/production/project-flock/add' className='w-full sm:w-fit'
> href='/production/project-flock/add'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
{/* <Button {/* <Button
variant='outline' variant='outline'
color='success' color='success'
@@ -630,6 +642,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
); );
setRowSelection({}); setRowSelection({});
}, },
permissions: 'lti.production.project_flocks.detail',
}, },
{ {
action: 'DELETE', action: 'DELETE',
@@ -639,6 +652,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
onClick: () => { onClick: () => {
deleteModal.openModal(); deleteModal.openModal();
}, },
permissions: 'lti.production.project_flocks.delete',
}, },
]} ]}
approvals={[ approvals={[
@@ -651,6 +665,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
confirmModal.openModal(); confirmModal.openModal();
}, },
disabled: !canApprove, disabled: !canApprove,
permissions: 'lti.production.project_flocks.approve',
}, },
{ {
icon: 'mdi:times', icon: 'mdi:times',
@@ -660,6 +675,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
setApprovalAction('REJECTED'); setApprovalAction('REJECTED');
confirmModal.openModal(); confirmModal.openModal();
}, },
permissions: 'lti.production.project_flocks.approve',
}, },
]} ]}
selectedRowIds={selectedRowIds} selectedRowIds={selectedRowIds}
@@ -22,6 +22,7 @@ import { useEffect, useState } from 'react';
import useSWR from 'swr'; import useSWR from 'swr';
import { FormHeader } from '@/components/helper/form/FormHeader'; import { FormHeader } from '@/components/helper/form/FormHeader';
import Link from 'next/link'; import Link from 'next/link';
import RequirePermission from '@/components/helper/RequirePermission';
const ProjectFlockChickinDetail = ({ const ProjectFlockChickinDetail = ({
projectFlockId, projectFlockId,
@@ -484,21 +485,23 @@ const ProjectFlockChickinDetail = ({
{kandang.kandang.name} {kandang.kandang.name}
</span> </span>
</div> </div>
<Button <RequirePermission permissions='lti.production.chickins.create'>
variant='outline' <Button
className='py-1 text-sm' variant='outline'
onClick={() => { className='py-1 text-sm'
handleChickinClick(kandang); onClick={() => {
}} handleChickinClick(kandang);
disabled={projectFlock?.approval?.step_number === 1} }}
> disabled={projectFlock?.approval?.step_number === 1}
Chick In{' '} >
<Icon Chick In{' '}
icon='mdi:arrow-top-right-thin' <Icon
width={11} icon='mdi:arrow-top-right-thin'
height={11} width={11}
/> height={11}
</Button> />
</Button>
</RequirePermission>
</div> </div>
))} ))}
</div> </div>
@@ -29,6 +29,7 @@ import {
} from '@/config/approval-line'; } from '@/config/approval-line';
import useSWR from 'swr'; import useSWR from 'swr';
import { ProjectFlockKandangApi } from '@/services/api/production'; import { ProjectFlockKandangApi } from '@/services/api/production';
import RequirePermission from '@/components/helper/RequirePermission';
const ProjectFlockDetail = ({ const ProjectFlockDetail = ({
projectFlock, projectFlock,
@@ -110,27 +111,31 @@ const ProjectFlockDetail = ({
leftIconHref='/production/project-flock' leftIconHref='/production/project-flock'
subtitle={`Created On ${formatDate(projectFlock.created_at, 'MMM DD, YYYY')}`} subtitle={`Created On ${formatDate(projectFlock.created_at, 'MMM DD, YYYY')}`}
> >
<Link <RequirePermission permissions='lti.production.project_flocks.update'>
href={`/production/project-flock/detail/edit?projectFlockId=${projectFlock.id}`} <Link
className='p-0' href={`/production/project-flock/detail/edit?projectFlockId=${projectFlock.id}`}
> className='p-0'
<Tooltip content='Edit' position='bottom'> >
<Button variant='link' className='p-0 text-neutral'> <Tooltip content='Edit' position='bottom'>
<Icon icon='mdi:square-edit-outline' width={20} height={20} /> <Button variant='link' className='p-0 text-neutral'>
</Button> <Icon icon='mdi:square-edit-outline' width={20} height={20} />
</Tooltip> </Button>
</Link> </Tooltip>
<Button </Link>
variant='link' </RequirePermission>
className='p-0 text-error' <RequirePermission permissions='lti.production.project_flocks.delete'>
onClick={() => { <Button
deleteModal.openModal(); variant='link'
}} className='p-0 text-error'
> onClick={() => {
<Tooltip content='Hapus' position='bottom'> deleteModal.openModal();
<Icon icon='mdi:trash-can-outline' width={20} height={20} /> }}
</Tooltip> >
</Button> <Tooltip content='Hapus' position='bottom'>
<Icon icon='mdi:trash-can-outline' width={20} height={20} />
</Tooltip>
</Button>
</RequirePermission>
</DrawerHeader> </DrawerHeader>
{/* Informasi Umum */} {/* Informasi Umum */}
@@ -418,38 +423,42 @@ const ProjectFlockDetail = ({
</RadioGroup> </RadioGroup>
</Card> </Card>
<div className='grid grid-cols-4 gap-3'> <div className='grid grid-cols-4 gap-3'>
<Link <RequirePermission permissions='lti.production.chickins.create'>
href={`/production/project-flock/chickin/add/kandang?projectFlockKandangId=${selectedKandang?.project_flock_kandang_id}&projectFlockId=${projectFlock.id}`} <Link
className='m-0 p-0' href={`/production/project-flock/chickin/add/kandang?projectFlockKandangId=${selectedKandang?.project_flock_kandang_id}&projectFlockId=${projectFlock.id}`}
> className='m-0 p-0'
<Button
className='w-full px-2 py-1 text-sm'
variant='outline'
color='success'
disabled={
!selectedKandangId ||
projectFlock?.approval?.step_number == 1
}
> >
Chickin <Icon icon='mdi:checkbox-marked-outline' /> <Button
</Button> className='w-full px-2 py-1 text-sm'
</Link> variant='outline'
<Link color='success'
href={`/production/project-flock/closing?projectFlockId=${projectFlock.id}&projectFlockKandangId=${selectedKandang?.project_flock_kandang_id}`} disabled={
className='m-0 p-0' !selectedKandangId ||
> projectFlock?.approval?.step_number == 1
<Button }
className='w-full px-2 py-1 text-sm' >
variant='outline' Chickin <Icon icon='mdi:checkbox-marked-outline' />
color='error' </Button>
disabled={ </Link>
!selectedKandangId || </RequirePermission>
projectFlock?.approval?.step_number == 1 <RequirePermission permissions='lti.production.project_flock_kandangs.closing'>
} <Link
href={`/production/project-flock/closing?projectFlockId=${projectFlock.id}&projectFlockKandangId=${selectedKandang?.project_flock_kandang_id}`}
className='m-0 p-0'
> >
Close <Icon icon='mdi:checkbox-marked-circle-outline' /> <Button
</Button> className='w-full px-2 py-1 text-sm'
</Link> variant='outline'
color='error'
disabled={
!selectedKandangId ||
projectFlock?.approval?.step_number == 1
}
>
Close <Icon icon='mdi:checkbox-marked-circle-outline' />
</Button>
</Link>
</RequirePermission>
</div> </div>
</div> </div>
</div> </div>
@@ -47,6 +47,7 @@ import Card from '@/components/Card';
import ProjectFlockKandangTable from '@/components/pages/production/project-flock/form/ProjectFlockKandangTable'; import ProjectFlockKandangTable from '@/components/pages/production/project-flock/form/ProjectFlockKandangTable';
import { Nonstock } from '@/types/api/master-data/nonstock'; import { Nonstock } from '@/types/api/master-data/nonstock';
import { useUiStore } from '@/stores/ui/ui.store'; import { useUiStore } from '@/stores/ui/ui.store';
import RequirePermission from '@/components/helper/RequirePermission';
import DrawerHeader from '@/components/helper/drawer/DrawerHeader'; import DrawerHeader from '@/components/helper/drawer/DrawerHeader';
interface ProjectFlockFormProps { interface ProjectFlockFormProps {
@@ -734,36 +735,40 @@ const ProjectFlockForm = ({
)} )}
{formType == 'detail' && ( {formType == 'detail' && (
<div className='w-full flex flex-col sm:flex-row gap-2 py-4'> <div className='w-full flex flex-col sm:flex-row gap-2 py-4'>
<Button <RequirePermission permissions='lti.production.project_flocks.approve'>
variant='outline' <Button
color='success' variant='outline'
onClick={() => { color='success'
if (initialValues?.id) { onClick={() => {
setApprovalAction('APPROVED'); if (initialValues?.id) {
confirmModal.openModal(); setApprovalAction('APPROVED');
} confirmModal.openModal();
}} }
disabled={!initialValues?.id || isApprovedDisabled} }}
className='w-full sm:w-fit' disabled={!initialValues?.id || isApprovedDisabled}
> className='w-full sm:w-fit'
<Icon icon='material-symbols:check' width={24} height={24} /> >
Approve <Icon icon='material-symbols:check' width={24} height={24} />
</Button> Approve
<Button </Button>
variant='outline' </RequirePermission>
color='error' <RequirePermission permissions='lti.production.project_flocks.approve'>
onClick={() => { <Button
if (initialValues?.id) { variant='outline'
setApprovalAction('REJECTED'); color='error'
confirmModal.openModal(); onClick={() => {
} if (initialValues?.id) {
}} setApprovalAction('REJECTED');
disabled={!initialValues?.id || isRejectedDisabled} confirmModal.openModal();
className='w-full sm:w-fit' }
> }}
<Icon icon='mdi:times' width={24} height={24} /> disabled={!initialValues?.id || isRejectedDisabled}
Reject className='w-full sm:w-fit'
</Button> >
<Icon icon='mdi:times' width={24} height={24} />
Reject
</Button>
</RequirePermission>
</div> </div>
)} )}
<form <form
@@ -1127,16 +1132,24 @@ const ProjectFlockForm = ({
</div> </div>
</div> */} </div> */}
{formType !== 'detail' && ( {formType !== 'detail' && (
<Button <RequirePermission
type='submit' permissions={
color='primary' formType == 'add'
isLoading={formik.isSubmitting} ? 'lti.production.project_flocks.create'
disabled={!formik.isValid || formik.isSubmitting} : 'lti.production.project_flocks.update'
className='px-4 w-full' }
> >
<Icon icon='mdi:plus' width={24} height={24} /> <Button
{formType == 'add' ? 'Add Flock' : 'Update Flock'} type='submit'
</Button> color='primary'
isLoading={formik.isSubmitting}
disabled={!formik.isValid || formik.isSubmitting}
className='px-4 w-full'
>
<Icon icon='mdi:plus' width={24} height={24} />
{formType == 'add' ? 'Add Flock' : 'Update Flock'}
</Button>
</RequirePermission>
)} )}
</div> </div>
</form> </form>
@@ -6,6 +6,7 @@ import useSWR from 'swr';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import { SortingState, CellContext } from '@tanstack/react-table'; import { SortingState, CellContext } from '@tanstack/react-table';
import { cn, formatDate } from '@/lib/helper'; import { cn, formatDate } from '@/lib/helper';
import RequirePermission from '@/components/helper/RequirePermission';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import Modal from '@/components/Modal'; import Modal from '@/components/Modal';
import Button from '@/components/Button'; import Button from '@/components/Button';
@@ -59,60 +60,70 @@ const RowOptionsMenu = ({
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.production.recording.detail'>
href={`/production/recording/detail/?recordingId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<Button
href={`/production/recording/detail/edit/?recordingId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='mdi:pencil-outline' width={16} height={16} />
Edit
</Button>
{!isApproved && !isRejected && (
<Button <Button
onClick={approveClickHandler} href={`/production/recording/detail/?recordingId=${props.row.original.id}`}
variant='ghost' variant='ghost'
color='success' color='primary'
className='justify-start text-sm' className='justify-start text-sm'
> >
<Icon icon='material-symbols:check' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Approve Detail
</Button> </Button>
</RequirePermission>
<RequirePermission permissions='lti.production.recording.update'>
<Button
href={`/production/recording/detail/edit/?recordingId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='mdi:pencil-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
{!isApproved && !isRejected && (
<RequirePermission permissions='lti.production.recording.approve'>
<Button
onClick={approveClickHandler}
variant='ghost'
color='success'
className='justify-start text-sm'
>
<Icon icon='material-symbols:check' width={16} height={16} />
Approve
</Button>
</RequirePermission>
)} )}
{!isApproved && !isRejected && ( {!isApproved && !isRejected && (
<RequirePermission permissions='lti.production.recording.approve'>
<Button
onClick={rejectClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm'
>
<Icon icon='material-symbols:close' width={16} height={16} />
Reject
</Button>
</RequirePermission>
)}
<RequirePermission permissions='lti.production.recording.delete'>
<Button <Button
onClick={rejectClickHandler} onClick={deleteClickHandler}
variant='ghost' variant='ghost'
color='error' color='error'
className='justify-start text-sm' className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
> >
<Icon icon='material-symbols:close' width={16} height={16} /> <Icon
Reject icon='mdi:delete-outline'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button> </Button>
)} </RequirePermission>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='mdi:delete-outline'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -514,49 +525,63 @@ const RecordingTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col xl:flex-row justify-between items-end xl:items-center gap-2'> <div className='w-full flex flex-col xl:flex-row justify-between items-end xl:items-center gap-2'>
<div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'> <div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'>
<Button <RequirePermission permissions='lti.production.recording.create'>
href='/production/recording/add' <Button
variant='outline' href='/production/recording/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
{selectedRowIds.length > 0 && ( {selectedRowIds.length > 0 && (
<> <>
<Button <RequirePermission permissions='lti.production.recording.approve'>
variant='outline' <Button
color='success' variant='outline'
onClick={() => { color='success'
setApprovalNotes(''); onClick={() => {
approveModal.openModal(); setApprovalNotes('');
}} approveModal.openModal();
disabled={ }}
selectedRowIds.length === 0 || eligibleRowIds.length === 0 disabled={
} selectedRowIds.length === 0 || eligibleRowIds.length === 0
className='w-full sm:w-fit' }
> className='w-full sm:w-fit'
<Icon icon='material-symbols:check' width={24} height={24} /> >
Approve <Icon
</Button> icon='material-symbols:check'
width={24}
height={24}
/>
Approve
</Button>
</RequirePermission>
<Button <RequirePermission permissions='lti.production.recording.approve'>
variant='outline' <Button
color='error' variant='outline'
onClick={() => { color='error'
setApprovalNotes(''); onClick={() => {
rejectModal.openModal(); setApprovalNotes('');
}} rejectModal.openModal();
disabled={ }}
selectedRowIds.length === 0 || eligibleRowIds.length === 0 disabled={
} selectedRowIds.length === 0 || eligibleRowIds.length === 0
className='w-full sm:w-fit' }
> className='w-full sm:w-fit'
<Icon icon='material-symbols:close' width={24} height={24} /> >
Reject <Icon
</Button> icon='material-symbols:close'
width={24}
height={24}
/>
Reject
</Button>
</RequirePermission>
</> </>
)} )}
</div> </div>
@@ -8,6 +8,7 @@ import useSWR from 'swr';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import Button from '@/components/Button'; import Button from '@/components/Button';
import RequirePermission from '@/components/helper/RequirePermission';
import Card from '@/components/Card'; import Card from '@/components/Card';
import Badge from '@/components/Badge'; import Badge from '@/components/Badge';
import NumberInput from '@/components/input/NumberInput'; import NumberInput from '@/components/input/NumberInput';
@@ -1492,41 +1493,45 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
!isRecordingApproved(initialValues) && !isRecordingApproved(initialValues) &&
!isRecordingRejected(initialValues) && ( !isRecordingRejected(initialValues) && (
<div className='flex flex-row gap-2'> <div className='flex flex-row gap-2'>
<Button <RequirePermission permissions='lti.production.recording.approve'>
variant='outline' <Button
color='success' variant='outline'
onClick={() => { color='success'
setApprovalNotes(''); onClick={() => {
approveModal.openModal(); setApprovalNotes('');
}} approveModal.openModal();
isLoading={isApproveLoading} }}
className='w-full sm:w-fit' isLoading={isApproveLoading}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:check' <Icon
width={24} icon='material-symbols:check'
height={24} width={24}
/> height={24}
Approve />
</Button> Approve
</Button>
</RequirePermission>
<Button <RequirePermission permissions='lti.production.recording.approve'>
variant='outline' <Button
color='error' variant='outline'
onClick={() => { color='error'
setApprovalNotes(''); onClick={() => {
rejectModal.openModal(); setApprovalNotes('');
}} rejectModal.openModal();
isLoading={isRejectLoading} }}
className='w-full sm:w-fit' isLoading={isRejectLoading}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:close' <Icon
width={24} icon='material-symbols:close'
height={24} width={24}
/> height={24}
Reject />
</Button> Reject
</Button>
</RequirePermission>
</div> </div>
)} )}
</div> </div>
@@ -2696,36 +2701,40 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
{/* Left side - Detail & Edit actions */} {/* Left side - Detail & Edit actions */}
<div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'> <div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'>
{type === 'detail' && deleteRecordingClickHandler && ( {type === 'detail' && deleteRecordingClickHandler && (
<Button <RequirePermission permissions='lti.production.recording.delete'>
type='button' <Button
color='error' type='button'
onClick={deleteRecordingClickHandler} color='error'
className='px-4' onClick={deleteRecordingClickHandler}
> className='px-4'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={24} icon='material-symbols:delete-outline-rounded'
height={24} width={24}
className='justify-start text-sm' height={24}
/> className='justify-start text-sm'
Delete />
</Button> Delete
</Button>
</RequirePermission>
)} )}
{type === 'detail' && initialValues && ( {type === 'detail' && initialValues && (
<Button <RequirePermission permissions='lti.production.recording.update'>
type='button' <Button
color='warning' type='button'
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`} color='warning'
className='px-4' href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
> className='px-4'
<Icon >
icon='material-symbols:edit-outline' <Icon
width={24} icon='material-symbols:edit-outline'
height={24} width={24}
className='justify-start text-sm' height={24}
/> className='justify-start text-sm'
Edit />
</Button> Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
{/* Right side actions */} {/* Right side actions */}
@@ -26,6 +26,7 @@ import TextInput from '@/components/input/TextInput';
import CheckboxInput from '@/components/input/CheckboxInput'; import CheckboxInput from '@/components/input/CheckboxInput';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes'; import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import RequirePermission from '@/components/helper/RequirePermission';
import { TransferToLaying } from '@/types/api/production/transfer-to-laying'; import { TransferToLaying } from '@/types/api/production/transfer-to-laying';
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying'; import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
@@ -56,72 +57,81 @@ const RowOptionsMenu = ({
const showDeleteButton = showEditButton; const showDeleteButton = showEditButton;
// TODO: apply RBAC
const showApproveButton = showEditButton; const showApproveButton = showEditButton;
const showRejectButton = showEditButton; const showRejectButton = showEditButton;
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.production.transfer_to_laying.detail'>
href={`/production/transfer-to-laying/detail/?transferToLayingId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
{showEditButton && (
<Button <Button
href={`/production/transfer-to-laying/detail/edit/?transferToLayingId=${props.row.original.id}`} href={`/production/transfer-to-laying/detail/?transferToLayingId=${props.row.original.id}`}
variant='ghost' variant='ghost'
color='warning' color='primary'
className='justify-start text-sm' className='justify-start text-sm'
> >
<Icon icon='material-symbols:edit-outline' width={16} height={16} /> <Icon icon='mdi:eye-outline' width={16} height={16} />
Edit Detail
</Button> </Button>
</RequirePermission>
{showEditButton && (
<RequirePermission permissions='lti.production.transfer_to_laying.update'>
<Button
href={`/production/transfer-to-laying/detail/edit/?transferToLayingId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
)} )}
{/* TODO: apply RBAC */} {/* TODO: apply RBAC */}
{showApproveButton && ( {showApproveButton && (
<Button <RequirePermission permissions='lti.production.transfer_to_laying.approve'>
variant='ghost' <Button
color='success' variant='ghost'
onClick={approveClickHandler} color='success'
className='justify-start text-sm' onClick={approveClickHandler}
> className='justify-start text-sm'
<Icon icon='material-symbols:check' width={24} height={24} /> >
Approve <Icon icon='material-symbols:check' width={24} height={24} />
</Button> Approve
</Button>
</RequirePermission>
)} )}
{showRejectButton && ( {showRejectButton && (
<Button <RequirePermission permissions='lti.production.transfer_to_laying.approve'>
variant='ghost' <Button
color='error' variant='ghost'
onClick={rejectClickHandler} color='error'
className='justify-start text-sm' onClick={rejectClickHandler}
> className='justify-start text-sm'
<Icon icon='material-symbols:close' width={24} height={24} /> >
Reject <Icon icon='material-symbols:close' width={24} height={24} />
</Button> Reject
</Button>
</RequirePermission>
)} )}
{showDeleteButton && ( {showDeleteButton && (
<Button <RequirePermission permissions='lti.production.transfer_to_laying.delete'>
onClick={deleteClickHandler} <Button
variant='ghost' onClick={deleteClickHandler}
color='error' variant='ghost'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content' color='error'
> className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={16} icon='material-symbols:delete-outline-rounded'
height={16} width={16}
className='justify-start text-sm' height={16}
/> className='justify-start text-sm'
Delete />
</Button> Delete
</Button>
</RequirePermission>
)} )}
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
@@ -502,47 +512,53 @@ const TransferToLayingsTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col xl:flex-row justify-between items-end xl:items-center gap-2'> <div className='w-full flex flex-col xl:flex-row justify-between items-end xl:items-center gap-2'>
<div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'> <div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'>
<Button <RequirePermission permissions='lti.production.transfer_to_laying.create'>
href='/production/transfer-to-laying/add' <Button
variant='outline' href='/production/transfer-to-laying/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
{selectedRowIds.length > 0 && ( {selectedRowIds.length > 0 && (
<> <>
<Button <RequirePermission permissions='lti.production.transfer_to_laying.approve'>
variant='outline' <Button
color='success' variant='outline'
onClick={bulkApproveClickHandler} color='success'
disabled={selectedRowIds.length === 0} onClick={bulkApproveClickHandler}
className='w-full sm:w-fit' disabled={selectedRowIds.length === 0}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:check' <Icon
width={24} icon='material-symbols:check'
height={24} width={24}
/> height={24}
Approve />
</Button> Approve
</Button>
</RequirePermission>
<Button <RequirePermission permissions='lti.production.transfer_to_laying.approve'>
variant='outline' <Button
color='error' variant='outline'
onClick={bulkRejectClickHandler} color='error'
disabled={selectedRowIds.length === 0} onClick={bulkRejectClickHandler}
className='w-full sm:w-fit' disabled={selectedRowIds.length === 0}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:close' <Icon
width={24} icon='material-symbols:close'
height={24} width={24}
/> height={24}
Reject />
</Button> Reject
</Button>
</RequirePermission>
</> </>
)} )}
</div> </div>
@@ -8,6 +8,7 @@ import useSWR from 'swr';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import Button from '@/components/Button'; import Button from '@/components/Button';
import RequirePermission from '@/components/helper/RequirePermission';
import SelectInput, { import SelectInput, {
OptionType, OptionType,
useSelect, useSelect,
@@ -500,34 +501,37 @@ const TransferToLayingForm = ({
<> <>
{isShowApproveRejectButton && ( {isShowApproveRejectButton && (
<div className='w-full flex flex-row justify-end gap-2'> <div className='w-full flex flex-row justify-end gap-2'>
{/* TODO: apply RBAC */} <RequirePermission permissions='lti.production.transfer_to_laying.approve'>
<Button <Button
variant='outline' variant='outline'
color='success' color='success'
onClick={approveClickHandler} onClick={approveClickHandler}
className='w-full sm:w-fit' className='w-full sm:w-fit'
> >
<Icon <Icon
icon='material-symbols:check' icon='material-symbols:check'
width={24} width={24}
height={24} height={24}
/> />
Approve Approve
</Button> </Button>
</RequirePermission>
<Button <RequirePermission permissions='lti.production.transfer_to_laying.approve'>
variant='outline' <Button
color='error' variant='outline'
onClick={rejectClickHandler} color='error'
className='w-full sm:w-fit' onClick={rejectClickHandler}
> className='w-full sm:w-fit'
<Icon >
icon='material-symbols:close' <Icon
width={24} icon='material-symbols:close'
height={24} width={24}
/> height={24}
Reject />
</Button> Reject
</Button>
</RequirePermission>
</div> </div>
)} )}
</> </>
@@ -788,37 +792,41 @@ const TransferToLayingForm = ({
{type !== 'add' && ( {type !== 'add' && (
<div className='flex flex-row justify-start gap-2'> <div className='flex flex-row justify-start gap-2'>
{isShowDeleteButton && ( {isShowDeleteButton && (
<Button <RequirePermission permissions='lti.production.transfer_to_laying.delete'>
type='button' <Button
color='error' type='button'
onClick={deleteTransferToLayingClickHandler} color='error'
className='px-4' onClick={deleteTransferToLayingClickHandler}
> className='px-4'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={24} icon='material-symbols:delete-outline-rounded'
height={24} width={24}
className='justify-start text-sm' height={24}
/> className='justify-start text-sm'
Delete />
</Button> Delete
</Button>
</RequirePermission>
)} )}
{type !== 'edit' && isShowEditButton && ( {type !== 'edit' && isShowEditButton && (
<Button <RequirePermission permissions='lti.production.transfer_to_laying.update'>
type='button' <Button
color='warning' type='button'
href={`/production/transfer-to-laying/detail/edit/?transferToLayingId=${initialValues?.id}`} color='warning'
className='px-4' href={`/production/transfer-to-laying/detail/edit/?transferToLayingId=${initialValues?.id}`}
> className='px-4'
<Icon >
icon='material-symbols:edit-outline' <Icon
width={24} icon='material-symbols:edit-outline'
height={24} width={24}
className='justify-start text-sm' height={24}
/> className='justify-start text-sm'
Edit />
</Button> Edit
</Button>
</RequirePermission>
)} )}
</div> </div>
)} )}
@@ -833,15 +841,23 @@ const TransferToLayingForm = ({
Reset Reset
</Button> </Button>
<Button <RequirePermission
type='submit' permissions={
color='primary' type === 'add'
isLoading={formik.isSubmitting} ? 'lti.production.transfer_to_laying.create'
disabled={!formik.isValid || formik.isSubmitting} : 'lti.production.transfer_to_laying.update'
className='px-4' }
> >
Submit <Button
</Button> type='submit'
color='primary'
isLoading={formik.isSubmitting}
disabled={!formik.isValid || formik.isSubmitting}
className='px-4'
>
Submit
</Button>
</RequirePermission>
</div> </div>
)} )}
</div> </div>
+39 -32
View File
@@ -15,6 +15,7 @@ import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions'; import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions'; import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper'; import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { cn, formatDate } from '@/lib/helper'; import { cn, formatDate } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper'; import { isResponseSuccess } from '@/lib/api-helper';
@@ -38,15 +39,17 @@ const RowOptionsMenu = ({
}: RowOptionsMenuProps) => { }: RowOptionsMenuProps) => {
return ( return (
<RowOptionsMenuWrapper type={type}> <RowOptionsMenuWrapper type={type}>
<Button <RequirePermission permissions='lti.purchase.detail'>
href={`/purchase/detail/?purchaseId=${props.row.original.id}`} <Button
variant='ghost' href={`/purchase/detail/?purchaseId=${props.row.original.id}`}
color='primary' variant='ghost'
className='justify-start text-sm' color='primary'
> className='justify-start text-sm'
<Icon icon='mdi:eye-outline' width={16} height={16} /> >
Detail <Icon icon='mdi:eye-outline' width={16} height={16} />
</Button> Detail
</Button>
</RequirePermission>
{/*<Button*/} {/*<Button*/}
{/* href={`/purchase/detail/edit/?purchaseId=${props.row.original.id}`}*/} {/* href={`/purchase/detail/edit/?purchaseId=${props.row.original.id}`}*/}
@@ -58,20 +61,22 @@ const RowOptionsMenu = ({
{/* Edit*/} {/* Edit*/}
{/*</Button>*/} {/*</Button>*/}
<Button <RequirePermission permissions='lti.purchase.delete'>
onClick={deleteClickHandler} <Button
variant='ghost' onClick={deleteClickHandler}
color='error' variant='ghost'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content' color='error'
> className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
<Icon >
icon='material-symbols:delete-outline-rounded' <Icon
width={16} icon='material-symbols:delete-outline-rounded'
height={16} width={16}
className='justify-start text-sm' height={16}
/> className='justify-start text-sm'
Delete />
</Button> Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -227,15 +232,17 @@ const PurchaseTable = () => {
<div className='flex flex-col gap-2 mb-4'> <div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col xl:flex-row justify-between items-end xl:items-center gap-2'> <div className='w-full flex flex-col xl:flex-row justify-between items-end xl:items-center gap-2'>
<div className='w-full flex flex-row gap-2'> <div className='w-full flex flex-row gap-2'>
<Button <RequirePermission permissions='lti.purchase.create'>
href='/purchase/add' <Button
variant='outline' href='/purchase/add'
color='primary' variant='outline'
className='w-full sm:w-fit' color='primary'
> className='w-full sm:w-fit'
<Icon icon='ic:round-plus' width={24} height={24} /> >
Tambah <Icon icon='ic:round-plus' width={24} height={24} />
</Button> Tambah
</Button>
</RequirePermission>
</div> </div>
<DebouncedTextInput <DebouncedTextInput
@@ -32,6 +32,7 @@ import {
} from '@/types/api/purchase/purchase'; } from '@/types/api/purchase/purchase';
import { BaseApproval, BaseGroupedApproval } from '@/types/api/api-general'; import { BaseApproval, BaseGroupedApproval } from '@/types/api/api-general';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import RequirePermission from '@/components/helper/RequirePermission';
interface PurchaseOrderStaffApprovalFormProps { interface PurchaseOrderStaffApprovalFormProps {
type?: 'add' | 'edit'; type?: 'add' | 'edit';
@@ -897,20 +898,25 @@ const PurchaseOrderStaffApprovalForm = ({
<div className='flex justify-center'> <div className='flex justify-center'>
{canUpdatePurchaseItems && {canUpdatePurchaseItems &&
canShowDeleteAddButtons && ( canShowDeleteAddButtons && (
<Button <RequirePermission permissions='lti.purchase.delete.item'>
type='button' <Button
color='error' type='button'
onClick={() => color='error'
removePurchaseItem(formItemIndex) className='text-sm w-fit'
} onClick={() =>
title='Hapus item' removePurchaseItem(
> formItemIndex
<Icon )
icon='mdi:trash-can' }
width={16} title='Hapus item'
height={16} >
/> <Icon
</Button> icon='mdi:trash-can'
width={16}
height={16}
/>
</Button>
</RequirePermission>
)} )}
</div> </div>
</td> </td>
@@ -39,19 +39,22 @@ import { toast } from 'react-hot-toast';
import { useSearchParams } from 'next/navigation'; import { useSearchParams } from 'next/navigation';
import { formatCurrency, formatNumber, formatDate } from '@/lib/helper'; import { formatCurrency, formatNumber, formatDate } from '@/lib/helper';
import { PURCHASE_ORDER_APPROVAL_LINE } from '@/config/approval-line'; import { PURCHASE_ORDER_APPROVAL_LINE } from '@/config/approval-line';
import RequirePermission from '@/components/helper/RequirePermission';
const ItemPembelianDropdown = ({ onEdit }: { onEdit: () => void }) => { const ItemPembelianDropdown = ({ onEdit }: { onEdit: () => void }) => {
return ( return (
<RowOptionsMenuWrapper type='dropdown'> <RowOptionsMenuWrapper type='dropdown'>
<Button <RequirePermission permissions='lti.purchase.update'>
onClick={onEdit} <Button
variant='ghost' onClick={onEdit}
color='warning' variant='ghost'
className='justify-start text-sm' color='warning'
> className='justify-start text-sm'
<Icon icon='material-symbols:edit-outline' width={16} height={16} /> >
Edit <Icon icon='material-symbols:edit-outline' width={16} height={16} />
</Button> Edit
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -59,15 +62,17 @@ const ItemPembelianDropdown = ({ onEdit }: { onEdit: () => void }) => {
const PenerimaanBarangDropdown = ({ onEdit }: { onEdit: () => void }) => { const PenerimaanBarangDropdown = ({ onEdit }: { onEdit: () => void }) => {
return ( return (
<RowOptionsMenuWrapper type='dropdown'> <RowOptionsMenuWrapper type='dropdown'>
<Button <RequirePermission permissions='lti.purchase.receive'>
onClick={onEdit} <Button
variant='ghost' onClick={onEdit}
color='warning' variant='ghost'
className='justify-start text-sm' color='warning'
> className='justify-start text-sm'
<Icon icon='material-symbols:edit-outline' width={16} height={16} /> >
Edit <Icon icon='material-symbols:edit-outline' width={16} height={16} />
</Button> Edit
</Button>
</RequirePermission>
</RowOptionsMenuWrapper> </RowOptionsMenuWrapper>
); );
}; };
@@ -496,14 +501,16 @@ const PurchaseOrderDetail = ({
}; };
return ( return (
<Button <RequirePermission permissions='lti.purchase.delete.item'>
type='button' <Button
color='error' type='button'
className='text-sm' color='error'
onClick={deleteClickHandler} className='text-sm'
> onClick={deleteClickHandler}
<Icon icon='mdi:trash-can' width={16} height={16} /> >
</Button> <Icon icon='mdi:trash-can' width={16} height={16} />
</Button>
</RequirePermission>
); );
}, },
}, },
@@ -632,25 +639,45 @@ const PurchaseOrderDetail = ({
{showApprovalButton && ( {showApprovalButton && (
<div className='flex flex-row gap-2'> <div className='flex flex-row gap-2'>
<Button <RequirePermission
onClick={handleApprovalClick} permissions={
variant='outline' approvalStep === 1
color='success' ? 'lti.purchase.approve.staff'
className='w-full sm:w-fit' : approvalStep === 2
? 'lti.purchase.approve.manager'
: 'lti.purchase.receive'
}
> >
<Icon icon='material-symbols:check' width={24} height={24} /> <Button
Approve onClick={handleApprovalClick}
</Button> variant='outline'
color='success'
className='w-full sm:w-fit'
>
<Icon icon='material-symbols:check' width={24} height={24} />
Approve
</Button>
</RequirePermission>
<Button <RequirePermission
variant='outline' permissions={
color='error' approvalStep === 1
className='w-full sm:w-fit' ? 'lti.purchase.approve.staff'
onClick={handleRejectionClick} : approvalStep === 2
? 'lti.purchase.approve.manager'
: 'lti.purchase.receive'
}
> >
<Icon icon='material-symbols:close' width={24} height={24} /> <Button
Reject variant='outline'
</Button> color='error'
className='w-full sm:w-fit'
onClick={handleRejectionClick}
>
<Icon icon='material-symbols:close' width={24} height={24} />
Reject
</Button>
</RequirePermission>
</div> </div>
)} )}
</div> </div>
+46 -1
View File
@@ -10,14 +10,20 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
text: 'Produksi', text: 'Produksi',
link: '/production', link: '/production',
icon: 'heroicons-outline:wrench-screwdriver', icon: 'heroicons-outline:wrench-screwdriver',
permission: [
'lti.production.project_flocks.list',
'lti.production.recording.list',
],
submenu: [ submenu: [
{ {
text: 'Daftar Flock', text: 'Daftar Flock',
link: '/production/project-flock', link: '/production/project-flock',
permission: ['lti.production.project_flocks.list'],
}, },
{ {
text: 'Recording', text: 'Recording',
link: '/production/recording', link: '/production/recording',
permission: ['lti.production.recording.list'],
}, },
{ {
text: 'Transfer to Laying', text: 'Transfer to Laying',
@@ -29,6 +35,7 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
text: 'Pembelian', text: 'Pembelian',
link: '/purchase', link: '/purchase',
icon: 'heroicons-outline:shopping-cart', icon: 'heroicons-outline:shopping-cart',
permission: ['lti.purchase.list'],
}, },
{ {
text: 'Penjualan', text: 'Penjualan',
@@ -41,14 +48,16 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
icon: 'heroicons-outline:scale', icon: 'heroicons-outline:scale',
}, },
{ {
text: 'Biaya Operasional', text: 'Biaya',
link: '/expense', link: '/expense',
icon: 'heroicons:wallet', icon: 'heroicons:wallet',
permission: ['lti.expense.list'],
}, },
{ {
text: 'Closing', text: 'Closing',
link: '/closing', link: '/closing',
icon: 'heroicons-outline:presentation-chart-bar', icon: 'heroicons-outline:presentation-chart-bar',
permission: ['lti.closing.list'],
}, },
{ {
text: 'Laporan', text: 'Laporan',
@@ -73,18 +82,26 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
text: 'Persediaan', text: 'Persediaan',
link: '/inventory', link: '/inventory',
icon: 'heroicons-outline:folder', icon: 'heroicons-outline:folder',
permission: [
'lti.inventory.product_stock.list',
'lti.inventory.product_warehouses.list',
'lti.inventory.transfer.list',
],
submenu: [ submenu: [
{ {
text: 'Stok Produk', text: 'Stok Produk',
link: '/inventory/product', link: '/inventory/product',
permission: ['lti.inventory.product_stock.list'],
}, },
{ {
text: 'Penyesuaian Stok', text: 'Penyesuaian Stok',
link: '/inventory/adjustment', link: '/inventory/adjustment',
permission: ['lti.inventory.product_stock.list'],
}, },
{ {
text: 'Transfer Stok', text: 'Transfer Stok',
link: '/inventory/movement', link: '/inventory/movement',
permission: ['lti.inventory.transfer.list'],
}, },
], ],
}, },
@@ -92,58 +109,86 @@ export const MAIN_DRAWER_LINKS: SidebarMenuItem[] = [
text: 'Master Data', text: 'Master Data',
link: '/master-data', link: '/master-data',
icon: 'heroicons-outline:circle-stack', icon: 'heroicons-outline:circle-stack',
permission: [
'lti.master.area.list',
'lti.master.banks.list',
'lti.master.customer.list',
'lti.master.fcr.list',
'lti.master.flocks.list',
'lti.master.kandangs.list',
'lti.master.locations.list',
'lti.master.nonstocks.list',
'lti.master.product_categories.list',
'lti.master.products.list',
'lti.master.suppliers.list',
'lti.master.uoms.list',
'lti.master.warehouses.list',
],
submenu: [ submenu: [
{ {
text: 'Produk', text: 'Produk',
link: '/master-data/product', link: '/master-data/product',
permission: ['lti.master.products.list'],
}, },
{ {
text: 'Kategori Produk', text: 'Kategori Produk',
link: '/master-data/product-category', link: '/master-data/product-category',
permission: ['lti.master.product_categories.list'],
}, },
{ {
text: 'Bank', text: 'Bank',
link: '/master-data/bank', link: '/master-data/bank',
permission: ['lti.master.banks.list'],
}, },
{ {
text: 'Area', text: 'Area',
link: '/master-data/area', link: '/master-data/area',
permission: ['lti.master.area.list'],
}, },
{ {
text: 'Lokasi', text: 'Lokasi',
link: '/master-data/location', link: '/master-data/location',
permission: ['lti.master.locations.list'],
}, },
{ {
text: 'Kandang', text: 'Kandang',
link: '/master-data/kandang', link: '/master-data/kandang',
permission: ['lti.master.kandangs.list'],
}, },
{ {
text: 'Warehouse', text: 'Warehouse',
link: '/master-data/warehouse', link: '/master-data/warehouse',
permission: ['lti.master.warehouses.list'],
}, },
{ {
text: 'Customer', text: 'Customer',
link: '/master-data/customer', link: '/master-data/customer',
permission: ['lti.master.customer.list'],
}, },
{ {
text: 'UOM', text: 'UOM',
link: '/master-data/uom', link: '/master-data/uom',
permission: ['lti.master.uoms.list'],
}, },
{ {
text: 'Non-Stock', text: 'Non-Stock',
link: '/master-data/nonstock', link: '/master-data/nonstock',
permission: ['lti.master.nonstocks.list'],
}, },
{ {
text: 'FCR', text: 'FCR',
link: '/master-data/fcr', link: '/master-data/fcr',
permission: ['lti.master.fcr.list'],
}, },
{ {
text: 'Supplier', text: 'Supplier',
link: '/master-data/supplier', link: '/master-data/supplier',
permission: ['lti.master.suppliers.list'],
}, },
{ {
text: 'Flock', text: 'Flock',
link: '/master-data/flock', link: '/master-data/flock',
permission: ['lti.master.flocks.list'],
}, },
], ],
}, },
+155
View File
@@ -0,0 +1,155 @@
export const ROUTE_PERMISSIONS: Record<string, string[]> = {
'/': ['lti.dashboard.list'],
// Dashboard
'/dashboard/': ['lti.dashboard.list'],
// Production
// Production - Project Flock
'/production/project-flock/': ['lti.production.project_flocks.list'],
'/production/project-flock/add/': ['lti.production.project_flocks.create'],
'/production/project-flock/detail/': ['lti.production.project_flocks.detail'],
'/production/project-flock/detail/edit/': [
'lti.production.project_flocks.update',
],
'/production/project-flock/chickin/add/kandang/': [
'lti.production.chickins.create',
],
'/production/project-flock/closing/': [
'lti.production.project_flock_kandangs.closing',
],
// Production - Recording
'/production/recording/': ['lti.production.recording.list'],
'/production/recording/add/': ['lti.production.recording.create'],
'/production/recording/detail/': ['lti.production.recording.detail'],
'/production/recording/detail/edit/': ['lti.production.recording.update'],
// Production - Transfer to Laying
'/production/transfer-to-laying/': ['lti.production.transfer_to_laying.list'],
'/production/transfer-to-laying/add/': [
'lti.production.transfer_to_laying.create',
],
'/production/transfer-to-laying/detail/': [
'lti.production.transfer_to_laying.detail',
],
'/production/transfer-to-laying/detail/edit/': [
'lti.production.transfer_to_laying.update',
],
// Purchase
'/purchase/': ['lti.purchase.list'],
'/purchase/add/': ['lti.purchase.create'],
'/purchase/detail/': ['lti.purchase.detail'],
'/purchase/detail/edit/': ['lti.purchase.update'],
// Marketing
'/marketing/': ['lti.marketing.delivery_order.list'],
'/marketing/add/delivery-orders/': ['lti.marketing.delivery_order.create'],
'/marketing/add/sales-orders/': ['lti.marketing.sales_order.create'],
'/marketing/detail/': ['lti.marketing.delivery_order.detail'],
'/marketing/detail/delivery-orders/edit/': [
'lti.marketing.delivery_order.update',
],
'/marketing/detail/sales-orders/edit/': ['lti.marketing.sales_order.update'],
// Expense
'/expense/': ['lti.expense.list'],
'/expense/add/': ['lti.expense.create'],
'/expense/detail/': ['lti.expense.detail'],
'/expense/detail/edit/': ['lti.expense.update'],
'/expense/realization/': ['lti.expense.create.realization'],
'/expense/realization/edit/': ['lti.expense.update.realization'],
// Closing
'/closing/': ['lti.closing.list'],
'/closing/detail/': ['lti.closing.detail'],
// Report
'/report/logistic-stock/': ['lti.repport.purchasesupplier.list'],
'/report/expense/': ['lti.repport.expense.list'],
'/report/marketing/': ['lti.repport.delivery.list'],
// Inventory
'/inventory/adjustment/': ['lti.inventory.list'],
'/inventory/adjustment/add/': ['lti.inventory.create'],
'/inventory/adjustment/detail/': ['lti.inventory.detail'],
'/inventory/movement/': ['lti.inventory.transfer.list'],
'/inventory/movement/add/': ['lti.inventory.transfer.create'],
'/inventory/movement/detail/': ['lti.inventory.transfer.detail'],
'/inventory/movement/detail/edit/': ['lti.inventory.transfer.update'],
'/inventory/product/': ['lti.inventory.product_stock.list'],
'/inventory/product/detail/': ['lti.inventory.product_stock.detail'],
// Master Data
'/master-data/product/': ['lti.master.products.list'],
'/master-data/product/add/': ['lti.master.products.create'],
'/master-data/product/detail/': ['lti.master.products.detail'],
'/master-data/product/detail/edit/': ['lti.master.products.update'],
'/master-data/product-category/': ['lti.master.product_categories.list'],
'/master-data/product-category/add/': [
'lti.master.product_categories.create',
],
'/master-data/product-category/detail/': [
'lti.master.product_categories.detail',
],
'/master-data/product-category/detail/edit/': [
'lti.master.product_categories.update',
],
'/master-data/bank/': ['lti.master.banks.list'],
'/master-data/bank/add/': ['lti.master.banks.create'],
'/master-data/bank/detail/': ['lti.master.banks.detail'],
'/master-data/bank/detail/edit/': ['lti.master.banks.update'],
'/master-data/area/': ['lti.master.area.list'],
'/master-data/area/add/': ['lti.master.area.create'],
'/master-data/area/detail/': ['lti.master.area.detail'],
'/master-data/area/detail/edit/': ['lti.master.area.update'],
'/master-data/location/': ['lti.master.locations.list'],
'/master-data/location/add/': ['lti.master.locations.create'],
'/master-data/location/detail/': ['lti.master.locations.detail'],
'/master-data/location/detail/edit/': ['lti.master.locations.update'],
'/master-data/kandang/': ['lti.master.kandangs.list'],
'/master-data/kandang/add/': ['lti.master.kandangs.create'],
'/master-data/kandang/detail/': ['lti.master.kandangs.detail'],
'/master-data/kandang/detail/edit/': ['lti.master.kandangs.update'],
'/master-data/warehouse/': ['lti.master.warehouses.list'],
'/master-data/warehouse/add/': ['lti.master.warehouses.create'],
'/master-data/warehouse/detail/': ['lti.master.warehouses.detail'],
'/master-data/warehouse/detail/edit/': ['lti.master.warehouses.update'],
'/master-data/customer/': ['lti.master.customer.list'],
'/master-data/customer/add/': ['lti.master.customer.create'],
'/master-data/customer/detail/': ['lti.master.customer.detail'],
'/master-data/customer/detail/edit/': ['lti.master.customer.update'],
'/master-data/uom/': ['lti.master.uoms.list'],
'/master-data/uom/add/': ['lti.master.uoms.create'],
'/master-data/uom/detail/': ['lti.master.uoms.detail'],
'/master-data/uom/detail/edit/': ['lti.master.uoms.update'],
'/master-data/nonstock/': ['lti.master.nonstocks.list'],
'/master-data/nonstock/add/': ['lti.master.nonstocks.create'],
'/master-data/nonstock/detail/': ['lti.master.nonstocks.detail'],
'/master-data/nonstock/detail/edit/': ['lti.master.nonstocks.update'],
'/master-data/fcr/': ['lti.master.fcr.list'],
'/master-data/fcr/add/': ['lti.master.fcr.create'],
'/master-data/fcr/detail/': ['lti.master.fcr.detail'],
'/master-data/fcr/detail/edit/': ['lti.master.fcr.update'],
'/master-data/supplier/': ['lti.master.suppliers.list'],
'/master-data/supplier/add/': ['lti.master.suppliers.create'],
'/master-data/supplier/detail/': ['lti.master.suppliers.detail'],
'/master-data/supplier/detail/edit/': ['lti.master.suppliers.update'],
'/master-data/flock/': ['lti.master.flocks.list'],
'/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'],
};