diff --git a/apps/edr-freight-web/portal/src/components/onboarding/OnboardingWizardDialog.tsx b/apps/edr-freight-web/portal/src/components/onboarding/OnboardingWizardDialog.tsx index 0dd3e4462..b06b1487c 100644 --- a/apps/edr-freight-web/portal/src/components/onboarding/OnboardingWizardDialog.tsx +++ b/apps/edr-freight-web/portal/src/components/onboarding/OnboardingWizardDialog.tsx @@ -492,6 +492,15 @@ export default function OnboardingWizardDialog({ licenseFiles, onLicenseChange: setLicenseFiles, uploadedDocumentKeys, + // What the server says is already on file, per operational profile. The + // wizard's own `roleProfiles` cannot say: getInfo leaves `licenseFiles` + // empty, so a resumed wizard asked for a licence it had already been given + // and refused to submit until it was uploaded a second time. + uploadedLicenceProfileIds: ( + requirementsQuery.data?.licenseProfiles ?? [] + ) + .filter((p) => p.uploaded) + .map((p) => p.profileId), onUploadDocuments: handleUploadDocuments, // The company's single identity verification, and whose it is. Fayda is // mandatory for an Ethiopian company; a foreign one may instead type a diff --git a/apps/edr-freight-web/portal/src/pages/accounts/CompanyProfileForm.tsx b/apps/edr-freight-web/portal/src/pages/accounts/CompanyProfileForm.tsx index 542fd17b5..fd0e060e1 100644 --- a/apps/edr-freight-web/portal/src/pages/accounts/CompanyProfileForm.tsx +++ b/apps/edr-freight-web/portal/src/pages/accounts/CompanyProfileForm.tsx @@ -61,6 +61,7 @@ export default function CompanyProfileForm({ onLicenseChange, submitError, uploadedDocumentKeys, + uploadedLicenceProfileIds, onUploadDocuments, identity: rawIdentity, onIdentityChange, @@ -96,6 +97,16 @@ export default function CompanyProfileForm({ submitError?: string | null; /** fileKeys whose company document is already uploaded server-side (resume). */ uploadedDocumentKeys?: string[]; + /** + * Profile ids whose business licence the server already holds. + * + * `roleProfiles.existingFiles` cannot answer this on a resumed wizard: + * `getInfo` does not populate `licenseFiles`, so every profile looks empty + * however many licences are on file. Taken from the onboarding requirements, + * which is the server's own verdict and what `markOnboardingComplete` + * enforces. + */ + uploadedLicenceProfileIds?: string[]; /** * Auto-upload the currently-selected company documents (the Documents step's * "Continue" action). Resolves to an error message string on failure so the @@ -688,7 +699,9 @@ export default function CompanyProfileForm({ if (cooperative) return errs; for (const p of roleProfiles ?? []) { const hasNew = (licenseFiles?.[p.id]?.length ?? 0) > 0; - const hasExisting = p.existingFiles.length > 0; + const hasExisting = + p.existingFiles.length > 0 || + (uploadedLicenceProfileIds ?? []).includes(p.id); if (!hasNew && !hasExisting) { errs[p.id] = "Business license is required"; }