diff --git a/apps/edr-freight-web/portal/src/App.tsx b/apps/edr-freight-web/portal/src/App.tsx index a4c2c8553..bbcdba42e 100644 --- a/apps/edr-freight-web/portal/src/App.tsx +++ b/apps/edr-freight-web/portal/src/App.tsx @@ -146,10 +146,11 @@ const sidebarItems: SidebarItem[] = [ const App = () => { const navigate = useNavigate(); const location = useLocation(); - const { user } = useAuth(); + const { user, company } = useAuth(); const displayName = user?.name?.en || user?.username || user?.email || "User"; const userEmail = user?.email; + const companyProfiles = company?.company?.companyProfiles ?? []; return ( @@ -190,6 +191,7 @@ const App = () => { enableThemeToggle userName={displayName} userEmail={userEmail} + companyProfiles={companyProfiles} > diff --git a/apps/edr-freight-web/portal/src/components/AppLayout.tsx b/apps/edr-freight-web/portal/src/components/AppLayout.tsx index 8d00baeb6..e0de92ec5 100644 --- a/apps/edr-freight-web/portal/src/components/AppLayout.tsx +++ b/apps/edr-freight-web/portal/src/components/AppLayout.tsx @@ -47,9 +47,19 @@ export interface AppLayoutProps { enableThemeToggle?: boolean; userName?: string; userEmail?: string; + /** Operational profiles for the company — surfaced as reference chips in the account menu. */ + companyProfiles?: { type: string; reference: string; status?: string }[]; children: ReactNode; } +const PROFILE_TYPE_LABELS: Record = { + importer: "Importer", + exporter: "Exporter", + freight_forwarder: "Freight Forwarder", + dj_freight_forwarder: "DJ Freight Forwarder", + transporter: "Transporter", +}; + function getInitials(name: string): string { return name .split(" ") @@ -106,6 +116,7 @@ export function AppLayout({ enableThemeToggle = false, userName = "User", userEmail, + companyProfiles = [], children, }: AppLayoutProps) { const [mobileOpen, { toggle: toggleMobile }] = useDisclosure(); @@ -306,6 +317,34 @@ export function AppLayout({ )} + {companyProfiles.length > 0 && ( + <> + + + + {companyProfiles.map((p) => ( + + + {PROFILE_TYPE_LABELS[p.type] ?? p.type} + + + {p.reference} + + + ))} + + + + )} } diff --git a/apps/edr-freight-web/portal/src/pages/ProfilePage.tsx b/apps/edr-freight-web/portal/src/pages/ProfilePage.tsx index ef5c89bb6..cf31d17a9 100644 --- a/apps/edr-freight-web/portal/src/pages/ProfilePage.tsx +++ b/apps/edr-freight-web/portal/src/pages/ProfilePage.tsx @@ -18,6 +18,7 @@ import { } from "@mantine/core"; import { useQuery } from "@tanstack/react-query"; import { + BadgeCheck, Briefcase, Building, Building2, @@ -26,11 +27,13 @@ import { Mail, MapPin, Phone, + Plus, ShieldCheck, User, UserCheck, } from "lucide-react"; import { Link } from "react-router-dom"; +import { rolesForCompanyType } from "./settings/companyRoles"; function InfoItem({ icon, @@ -129,6 +132,12 @@ export default function ProfilePage() { ); } + // Registered operational profiles keyed by type, plus the roles this company + // type may hold (importer/exporter for a customer). Mirrors CompanyRolesCard. + const refByType = new Map(profile.companyProfiles.map((p) => [p.type, p])); + const roleOptions = rolesForCompanyType(profile.companyType); + const activeOptions = roleOptions.filter((o) => refByType.has(o.type)); + return ( {/* Header */} @@ -145,12 +154,28 @@ export default function ProfilePage() { Verified - - - - {profile.companyType} - - + {activeOptions.length > 0 ? ( + + {activeOptions.map((opt) => ( + + {opt.label} · {refByType.get(opt.type)!.reference} + + ))} + + ) : ( + + + + {profile.companyType} + + + )} @@ -163,24 +188,58 @@ export default function ProfilePage() { {/* Company Details */} } + icon={ + + } title="Company Details" description="Business registration information" /> - } label="Location" value={profile.companyLocation} /> - } label="Address" value={profile.companyAddress} /> - } label="TIN Number" value={profile.tinNumber} /> - } label="FAN Number" value={profile.fanNumber} /> - } label="Email" value={profile.companyEmail} /> - } label="Phone" value={profile.companyPhone} /> + } + label="Location" + value={profile.companyLocation} + /> + } + label="Address" + value={profile.companyAddress} + /> + } + label="TIN Number" + value={profile.tinNumber} + /> + } + label="FAN Number" + value={profile.fanNumber} + /> + } + label="Email" + value={profile.companyEmail} + /> + } + label="Phone" + value={profile.companyPhone} + /> {/* Key Personnel */} } + icon={ + + } title="Key Personnel" description="Management and contact persons" /> @@ -201,7 +260,12 @@ export default function ProfilePage() { {profile.poaName && ( } + icon={ + + } title="Power of Attorney" description="Authorized representative details" /> @@ -218,37 +282,127 @@ export default function ProfilePage() { {/* Right Column */} - - - - - - - Secure Account - - - Your information is protected by enterprise-grade security. Contact - support for verified information updates. - - + )} + + ); + })} + + )} + + + {/* Secure Account */} + + - Edit Settings - - - + + + + + Secure Account + + + Your information is protected by enterprise-grade security. + Contact support for verified information updates. + + + + +