From 070c4bdab1a205c60e56f7860d0913fae10dcc4f Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Thu, 23 Jul 2026 04:26:13 +0530 Subject: [PATCH] fix: job seekers unable to submit verification documents The dashboard's Submit for Verification widget checked profile_data for a documents/documents_data field that GET /api/jobseeker/profile/me never returns, so the Submit button stayed permanently disabled. Even bypassing that, it POSTed {document_urls: []}, a field the backend doesn't recognize, instead of the profile_data shape submit-for-verification actually expects. Now fetches the job seeker's real uploaded documents via GET /api/jobseeker/profile/documents, checks the correct document_type field, and submits profile_data merged with the uploaded document URLs. Co-Authored-By: Claude Sonnet 5 --- src/components/dashboard/MyDashboardPage.tsx | 32 ++++++++++++-------- src/lib/api.ts | 5 +++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/components/dashboard/MyDashboardPage.tsx b/src/components/dashboard/MyDashboardPage.tsx index 45d5ad9..93effd4 100644 --- a/src/components/dashboard/MyDashboardPage.tsx +++ b/src/components/dashboard/MyDashboardPage.tsx @@ -13,7 +13,7 @@ import ProfileCompletionWidget from './widgets/ProfileCompletionWidget'; import VerificationWidget from './widgets/VerificationWidget'; import AiUsageWidget from './widgets/AiUsageWidget'; import VerificationSubmissionGuide from './VerificationSubmissionGuide'; -import { fetchProfile } from '~/lib/api'; +import { fetchProfile, fetchDocuments } from '~/lib/api'; import { getBasicFields, getDocFields, @@ -101,6 +101,7 @@ export default function MyDashboardPage(props: Props) { const [draggingIdx, setDraggingIdx] = createSignal(null); const [visibleWidgets, setVisibleWidgets] = createSignal>(new Set()); const [profileData, setProfileData] = createSignal>({}); + const [documents, setDocuments] = createSignal([]); const [submitting, setSubmitting] = createSignal(false); const getRoleType = (): string => { @@ -135,6 +136,11 @@ export default function MyDashboardPage(props: Props) { const data = await fetchProfile(prefix); if (data) setProfileData(data); } catch { /* ignore */ } + if (props.roleKey === 'JOB_SEEKER') { + try { + setDocuments(await fetchDocuments(prefix)); + } catch { /* ignore */ } + } }; const missingBasicLabels = createMemo(() => { @@ -148,12 +154,10 @@ export default function MyDashboardPage(props: Props) { }); const missingDocLabels = createMemo(() => { - const data = profileData(); - if (!data) return []; - const docs = data.documents || data.documents_data || []; + const docs = documents(); return getDocFields(props.roleKey) .filter((doc) => doc.required) - .filter((doc) => !docs.some((d: any) => d?.doc_type === doc.key)) + .filter((doc) => !docs.some((d: any) => d?.document_type === doc.key)) .map((doc) => doc.label); }); @@ -178,14 +182,18 @@ export default function MyDashboardPage(props: Props) { } setSubmitting(true); try { - const res = await apiFetch("/api/profile/submit-for-verification", { - method: "POST", - body: JSON.stringify({ roleKey: props.roleKey, document_urls: [] }), - }); - if (res.ok || res.status === 200) { - // Update verification status to PENDING - props.onVerificationStatusChange?.("PENDING"); + const data = profileData(); + const p = data.profile || data; + const docUrls: Record = {}; + for (const d of documents()) { + if (d?.document_type && d?.file_url) docUrls[d.document_type] = d.file_url; } + // apiFetch() throws on a non-2xx response, so reaching this point means the submission succeeded. + await apiFetch("/api/profile/submit-for-verification", { + method: "POST", + body: JSON.stringify({ roleKey: props.roleKey, profile_data: { ...p, ...docUrls } }), + }); + props.onVerificationStatusChange?.("PENDING"); } catch { // silently fail - the profile page handles submission errors } finally { diff --git a/src/lib/api.ts b/src/lib/api.ts index 400568e..6fb18cd 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -70,6 +70,11 @@ export async function saveProfile(rolePrefix: string, payload: any): Promise { + const res = await apiFetch(`/api/${rolePrefix}/profile/documents`); + return res?.data ?? []; +} + export async function submitProfileForVerification(rolePrefix: string): Promise { return apiFetch(`/api/${rolePrefix}/profile/submit`, { method: 'POST',