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.
33 lines
936 B
TypeScript
33 lines
936 B
TypeScript
import { Button } from '@mantine/core';
|
|
import { IconEdit } from '@tabler/icons-react';
|
|
import type { TFunction } from 'i18next';
|
|
import type { LicenseType } from '@ema-platform/api';
|
|
import type { AdvancedColumn } from '@ema-platform/ui';
|
|
import { LICENSE_PERMISSIONS, RequirePermission } from '@ema-platform/auth';
|
|
|
|
export function paymentConfigActionsColumn(
|
|
t: TFunction,
|
|
handlers: { onEdit: (type: LicenseType) => void },
|
|
): AdvancedColumn<LicenseType> {
|
|
return {
|
|
header: '',
|
|
size: 90,
|
|
align: 'right',
|
|
cell: ({ row }) => (
|
|
<RequirePermission
|
|
anyOf={[LICENSE_PERMISSIONS.UPDATE_LICENSE_TYPE]}
|
|
hideOnly
|
|
>
|
|
<Button
|
|
size="xs"
|
|
variant="light"
|
|
leftSection={<IconEdit size={14} />}
|
|
onClick={() => handlers.onEdit(row.original)}
|
|
>
|
|
{t('paymentConfig.edit', 'Edit')}
|
|
</Button>
|
|
</RequirePermission>
|
|
),
|
|
};
|
|
}
|