Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
118 lines
4.6 KiB
TypeScript
118 lines
4.6 KiB
TypeScript
"use client";
|
|
|
|
import type { ReactNode } from "react";
|
|
import { AlertCircle, Check, CheckCircle2 } from "lucide-react";
|
|
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
|
import { cn } from "@/app/lib/utils";
|
|
|
|
// Product setup hierarchy (feedback 2026-10-26). Every main section is numbered and says whether it is
|
|
// required, with a tick once nothing in it blocks Save. "Done" is read from the same check Save runs
|
|
// (buildSave), so the page never claims a section is complete when Save would still refuse it. The
|
|
// step numbers are labels, not a stepper: every section stays open and editable in any order (the
|
|
// stepper was removed on purpose, 32e93b791).
|
|
|
|
export interface StepInfo {
|
|
n: number;
|
|
/** Nothing in this section blocks Save. */
|
|
done: boolean;
|
|
required: boolean;
|
|
}
|
|
|
|
/** A section title with its step number (a tick once done) and a Required / Optional tag. */
|
|
export function StepTitle({ step, children }: { step?: StepInfo; children: ReactNode }) {
|
|
const t = useT();
|
|
if (!step) return <>{children}</>;
|
|
return (
|
|
<span className="flex w-full flex-wrap items-center gap-2.5">
|
|
<span
|
|
aria-hidden="true"
|
|
className={cn(
|
|
"flex size-7 shrink-0 items-center justify-center rounded-full text-sm font-semibold",
|
|
step.done ? "bg-positive/15 text-positive" : "bg-contrast-soft text-contrast-foreground",
|
|
)}
|
|
>
|
|
{step.done ? <Check className="size-4" /> : step.n}
|
|
</span>
|
|
<span>{children}</span>
|
|
{step.done && <span className="sr-only">{t("SetupStepDone")}</span>}
|
|
<span
|
|
className={cn(
|
|
"ml-auto rounded-full px-2 py-0.5 text-xs font-medium",
|
|
step.required ? "bg-contrast-soft text-contrast-foreground" : "border text-muted-foreground",
|
|
)}
|
|
>
|
|
{t(step.required ? "SetupRequired" : "SetupOptional")}
|
|
</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export interface JumpItem extends StepInfo {
|
|
id: string;
|
|
label: string;
|
|
}
|
|
|
|
/**
|
|
* "On this page" (owner, 2026-10-28: a proposal): the sections as chips in the sticky header, each
|
|
* with its tick, each a plain in-page link. No step state and nothing is locked.
|
|
*/
|
|
export function OnThisPage({ items }: { items: JumpItem[] }) {
|
|
const t = useT();
|
|
return (
|
|
<nav aria-label={t("SetupOnThisPage")} className="flex min-w-0 items-center gap-2">
|
|
<span className="hidden shrink-0 text-xs font-semibold tracking-wide text-muted-foreground uppercase sm:inline">{t("SetupOnThisPage")}</span>
|
|
<ol className="flex min-w-0 gap-1.5 overflow-x-auto pb-0.5">
|
|
{items.map(item => (
|
|
<li key={item.id} className="shrink-0">
|
|
<a
|
|
href={`#${item.id}`}
|
|
className={cn(
|
|
"relative inline-flex items-center gap-1.5 rounded-full border py-0.5 pr-2.5 pl-1 text-xs font-medium hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
item.done ? "border-positive/30" : "",
|
|
)}
|
|
>
|
|
<span
|
|
aria-hidden="true"
|
|
className={cn(
|
|
"flex size-5 items-center justify-center rounded-full text-[11px] font-semibold",
|
|
item.done ? "bg-positive/15 text-positive" : "bg-muted text-muted-foreground",
|
|
)}
|
|
>
|
|
{item.done ? <Check className="size-3" /> : item.n}
|
|
</span>
|
|
{item.label}
|
|
<span className="sr-only">{t(item.done ? "SetupStepDone" : item.required ? "SetupRequired" : "SetupOptional")}</span>
|
|
</a>
|
|
</li>
|
|
))}
|
|
</ol>
|
|
</nav>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* The header's readiness line: how many fields still block Save, or "Ready to save". Pressing it runs
|
|
* the same check as Save without saving, so the fields show their messages and the first one is focused.
|
|
*/
|
|
export function Readiness({ count, onShow }: { count: number; onShow: () => void }) {
|
|
const t = useT();
|
|
if (count === 0) {
|
|
return (
|
|
<span className="inline-flex items-center gap-1.5 text-sm font-medium text-positive">
|
|
<CheckCircle2 aria-hidden="true" className="size-4" />
|
|
{t("SetupReadyToSave")}
|
|
</span>
|
|
);
|
|
}
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={onShow}
|
|
className="inline-flex items-center gap-1.5 rounded-full bg-warning/10 px-2.5 py-0.5 text-sm font-medium text-warning underline-offset-2 hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
|
|
>
|
|
<AlertCircle aria-hidden="true" className="size-4" />
|
|
{t(count === 1 ? "SetupFieldsLeftOne" : "SetupFieldsLeftMany", { count })}
|
|
</button>
|
|
);
|
|
}
|