Merge pull request #63 from Tria-plc/WorkflowChange

This commit is contained in:
Nati Nigussie
2026-09-02 14:50:18 +03:00
committed by Nati
17 changed files with 270 additions and 80 deletions

View File

@@ -25,8 +25,6 @@ import {
import { useTranslation } from 'react-i18next';
import { FilePreviewModal } from '@ema-platform/ui';
const MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
interface Props {
requirements: DocumentRequirement[];
attachments: Attachment[];
@@ -87,7 +85,11 @@ export function DocumentSlots({
async function handle(documentKey: string, file: File | null) {
if (!file) return;
if (file.size > MAX_FILE_SIZE_BYTES) {
// The slot's own limit, as configured in the backoffice — the server
// refuses anything larger, so the check here only saves the round trip.
const maxSizeMb =
requirements.find((r) => r.key === documentKey)?.maxSizeMb ?? 5;
if (file.size > maxSizeMb * 1024 * 1024) {
setError(
t('licensing.msg.fileTooLarge', {
size: `${(file.size / 1024 / 1024).toFixed(1)}MB`,

View File

@@ -118,8 +118,20 @@ export function LicenseApplicationPage() {
const localized = useLocalized();
const accountUser = useAppSelector((state) => state.auth.user);
const [appId, setAppId] = useState<string | undefined>(applicationId);
// Fetched before the requirements because the application's kind decides
// which document set is asked for: a renewal started from a licence card
// must be shown the RENEWAL slots, not the NEW ones — the same set the
// server validates against at submission.
const { data: detail, refetch } = useGetApplicationQuery(appId as string, {
skip: !appId,
});
const { data: config, isLoading: loadingConfig } =
useGetLicenseTypeRequirementsQuery({ idOrKey: typeCode });
useGetLicenseTypeRequirementsQuery({
idOrKey: typeCode,
kind: detail?.application?.kind ?? "NEW",
});
const { profile } = useCurrentProfile();
const { can: hasPermission, known: permissionsKnown } = usePermissions();
// Only the vessel-select field (ConfigDrivenSection) reads this — fetched
@@ -130,7 +142,6 @@ export function LicenseApplicationPage() {
skip: !permissionsKnown || !hasPermission([PORTAL_PERMISSIONS.VIEW_OWN_VESSELS]),
});
const [createApplication] = useCreateApplicationMutation();
const [appId, setAppId] = useState<string | undefined>(applicationId);
// Create (or resume) the draft up front, so uploads have a real owner to
// attach to and nothing is lost if the browser is closed mid-wizard.
@@ -151,9 +162,6 @@ export function LicenseApplicationPage() {
);
}, [appId, config, createApplication, typeCode]);
const { data: detail, refetch } = useGetApplicationQuery(appId as string, {
skip: !appId,
});
const { data: attachments = [], refetch: refetchAttachments } =
useGetAttachmentsQuery(
{ ownerType: "APPLICATION", ownerId: appId as string },