import { useEffect, useState } from 'react'; import { Link, useOutletContext } from 'react-router-dom'; import { api } from '../api.js'; import { pathForNextStep, userApi } from '../userApi.js'; /** * @param {unknown} value */ function formatWhen(value) { if (!value) { return null; } const date = new Date(String(value)); return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleString(); } /** * @param {string | null | undefined} status */ function agreementStatusLabel(status) { switch (status) { case 'APPROVED': return 'Approved'; case 'SUBMITTED': return 'Submitted — awaiting approval'; case 'REJECTED': return 'Rejected'; case 'DRAFT': return 'Draft'; default: return 'Not started'; } } /** * @param {{ status?: string | null, done?: boolean }} surveyStep * @param {{ status?: string | null } | null} survey */ function surveyStatusLabel(surveyStep, survey) { if (surveyStep?.done || survey?.status === 'COMPLETED') { return 'Completed'; } if (survey?.status === 'IN_PROGRESS' || surveyStep?.status === 'IN_PROGRESS') { return 'In progress'; } return 'Not started'; } /** * @param {string} label * @returns {'completed' | 'in-process' | 'not-started' | 'rejected'} */ function stepStatusTone(label) { const normalized = label.toLowerCase(); if (normalized === 'completed' || normalized === 'approved') { return 'completed'; } if (normalized === 'rejected') { return 'rejected'; } if ( normalized === 'not started' || normalized === 'not-started' || normalized === '' ) { return 'not-started'; } return 'in-process'; } /** * @param {{ label: string }} props */ function StepStatusBadge({ label }) { return ( {label} ); } /** * @param {{ status: string }} props */ function StatusBadge({ status }) { const tone = status.toLowerCase(); return {status}; } /** * @param {{ * application: Record | null | undefined, * previewUrl: string, * finalPdfUrl: string, * chequeUrl: string, * previewError: string, * }} props */ function AgreementDetails({ application, previewUrl, finalPdfUrl, chequeUrl, previewError }) { if (!application) { return

No agreement details yet.

; } const rows = [ ['Agreement date', application.agreement_date], ['Full name', application.full_name], ['Age', application.age], ['Address', application.address], ['Registration no.', application.registration_no], ['Medical council', application.medical_council], ['PAN', application.pan], ['GSTIN', application.gstin || '—'], ['Bank name', application.bank_name], ['Account holder', application.account_holder], ['Account number', application.account_number], ['IFSC', application.ifsc], ]; return (

Agreement details

{application.status ? : null}
{rows.map(([label, value]) => value === undefined || value === null || value === '' ? null : (
{label}
{String(value)}
), )}
{chequeUrl ? (

Cancelled cheque

Cancelled cheque
) : null} {finalPdfUrl ? (

Download final agreement PDF

) : null}
{previewError ? (

{previewError}

) : previewUrl ? (