mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
- Added RequirePermission component to manage access based on user permissions. - Integrated permission checks in MySeaRecordsPage, SeafarerRegistrationPage, VesselRegistrationPage, WaiverPage, and PortalLayout. - Updated router to enforce permissions for specific routes. - Introduced PORTAL_PERMISSIONS and LICENSE_PERMISSIONS constants for consistent permission management. - Enhanced usePermissions hook to fetch permissions from the server and determine access rights. - Refactored UI components to conditionally render based on user permissions, improving security and user experience.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { Button, Tooltip } from '@mantine/core';
|
|
import { IconShieldCog } from '@tabler/icons-react';
|
|
import type { TFunction } from 'i18next';
|
|
import type { AdvancedColumn } from '@ema-platform/ui';
|
|
import { LICENSE_PERMISSIONS, RequirePermission } from '@ema-platform/auth';
|
|
import type { ProfileRow } from './columns';
|
|
|
|
export function seafarerStatusActionColumn(
|
|
t: TFunction,
|
|
handlers: { onStatus: (profile: ProfileRow) => void },
|
|
): AdvancedColumn<ProfileRow> {
|
|
return {
|
|
header: '',
|
|
label: t('seafarerRegistry.columns.actions', 'Actions'),
|
|
cell: ({ row }) =>
|
|
row.original.seafarerNumber ? (
|
|
<RequirePermission
|
|
anyOf={[LICENSE_PERMISSIONS.MANAGE_SEAFARER_STATUS]}
|
|
hideOnly
|
|
>
|
|
<Tooltip label={t('seafarerRegistry.statusActionTooltip', 'Suspend / reinstate / close')}>
|
|
<Button
|
|
size="compact-xs"
|
|
variant="subtle"
|
|
leftSection={<IconShieldCog size={14} />}
|
|
onClick={() => handlers.onStatus(row.original)}
|
|
>
|
|
{t('seafarerRegistry.statusAction', 'Status')}
|
|
</Button>
|
|
</Tooltip>
|
|
</RequirePermission>
|
|
) : null,
|
|
};
|
|
}
|