mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 21:15:41 +00:00
fix: customer settings fix
This commit is contained in:
@@ -59,6 +59,13 @@ const FIELD_LABELS: Record<string, string> = {
|
||||
woreda: "Woreda",
|
||||
kebele: "Kebele",
|
||||
houseNo: "House no.",
|
||||
statusDescription: "eTrade status",
|
||||
dateRegistered: "Date registered",
|
||||
renewedFrom: "Renewed from",
|
||||
renewalDate: "Renewal date",
|
||||
renewedTo: "Renewed to",
|
||||
etradePhone: "eTrade phone",
|
||||
ownerPassportNumber: "Owner passport number",
|
||||
};
|
||||
|
||||
/** Best-effort current value on the live company for a proposed field key. */
|
||||
@@ -85,6 +92,74 @@ function currentValue(company: Company, key: string): string {
|
||||
return v === null || v === undefined || v === "" ? "—" : String(v);
|
||||
}
|
||||
|
||||
/** Subject a staged `snapshot.faydaIdentity` blob belongs to, from which of its `*FaydaSub` keys is present. */
|
||||
function faydaIdentitySubject(
|
||||
snapshot: Record<string, unknown>,
|
||||
): "owner" | "poa" | null {
|
||||
if ("ownerFaydaSub" in snapshot) return "owner";
|
||||
if ("poaFaydaSub" in snapshot) return "poa";
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* `stageIdentityChange` writes a nested `snapshot.faydaIdentity` object
|
||||
* (attrs-key names like `ownerEmail`, not top-level DTO keys), so the generic
|
||||
* `DiffRow` loop below can't render it — it would just stringify to
|
||||
* `[object Object]`. Render it as its own before/after block instead, using
|
||||
* the company's current `identity.owner`/`identity.poa` as the "before" side.
|
||||
*/
|
||||
function FaydaIdentityDiff({
|
||||
company,
|
||||
snapshot,
|
||||
}: {
|
||||
company: Company;
|
||||
snapshot: Record<string, unknown>;
|
||||
}) {
|
||||
const subject = faydaIdentitySubject(snapshot);
|
||||
if (!subject) return null;
|
||||
const current =
|
||||
subject === "owner" ? company.identity?.owner : company.identity?.poa;
|
||||
const read = (key: string) => snapshot[`${subject}${key}`] as string | undefined;
|
||||
const verifiedAt = read("FaydaVerifiedAt");
|
||||
const fields: { label: string; from?: string | null; to?: string }[] = [
|
||||
{ label: "Name", from: current?.name, to: read("Name") },
|
||||
{ label: "Email", from: current?.email, to: read("Email") },
|
||||
{ label: "Phone", from: current?.phone, to: read("Phone") },
|
||||
{ label: "Address", from: current?.address, to: read("Address") },
|
||||
].filter((f) => f.to !== undefined);
|
||||
|
||||
return (
|
||||
<Stack gap={8}>
|
||||
<Group gap={8}>
|
||||
<Text size="sm" fw={600} c="edr-text">
|
||||
{subject === "owner" ? "Owner re-verification" : "PoA re-verification"}
|
||||
</Text>
|
||||
{verifiedAt && (
|
||||
<Text size="xs" c="dimmed">
|
||||
Verified {formatDate(verifiedAt)}
|
||||
</Text>
|
||||
)}
|
||||
</Group>
|
||||
{fields.length > 0 ? (
|
||||
<SimpleGrid cols={{ base: 1, sm: 2, lg: 3 }} spacing="lg">
|
||||
{fields.map((f) => (
|
||||
<DiffRow
|
||||
key={f.label}
|
||||
label={f.label}
|
||||
from={f.from?.trim() ? f.from : "—"}
|
||||
to={f.to?.trim() ? f.to : "—"}
|
||||
/>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
) : (
|
||||
<Text size="sm" c="dimmed">
|
||||
Identity re-verified — no name/email/phone/address change.
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
function DiffRow({
|
||||
label,
|
||||
from,
|
||||
@@ -153,8 +228,11 @@ export function ChangeRequestReview({ company }: { company: Company }) {
|
||||
if (!pending && history.length === 0) return null;
|
||||
|
||||
const proposedKeys = pending
|
||||
? Object.keys(pending.snapshot ?? {})
|
||||
? Object.keys(pending.snapshot ?? {}).filter((k) => k !== "faydaIdentity")
|
||||
: ([] as string[]);
|
||||
const faydaIdentitySnapshot = pending?.snapshot?.faydaIdentity as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
const docCount = pending?.documentFileIds?.length ?? 0;
|
||||
const licenseChanges = pending?.licenseChanges ?? [];
|
||||
const documentChanges = pending?.documentChanges ?? [];
|
||||
@@ -209,10 +287,14 @@ export function ChangeRequestReview({ company }: { company: Company }) {
|
||||
/>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
) : (
|
||||
) : !faydaIdentitySnapshot ? (
|
||||
<Text size="sm" c="dimmed">
|
||||
No field changes — document uploads only.
|
||||
</Text>
|
||||
) : null}
|
||||
|
||||
{faydaIdentitySnapshot && (
|
||||
<FaydaIdentityDiff company={company} snapshot={faydaIdentitySnapshot} />
|
||||
)}
|
||||
|
||||
{documentChanges.length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user