mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 10:58:14 +00:00
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { Building2, FileCheck, Mail, MapPin, Phone, User } from "lucide-react";
|
|
import { Text } from "@mantine/core";
|
|
|
|
import type { BookingDetail } from "@/types/booking";
|
|
import { LinkedEntityCard } from "@/components/detail";
|
|
import type { FieldRowProps } from "@/components/detail";
|
|
import { SectionCard } from "./SectionCard";
|
|
|
|
export interface BookingCompanyCardProps {
|
|
booking: BookingDetail;
|
|
}
|
|
|
|
/** Customer (company) quick info for the booking, linking to its detail page. */
|
|
export function BookingCompanyCard({ booking }: BookingCompanyCardProps) {
|
|
const company = booking.company;
|
|
|
|
// Government bookings may not carry a company; show the institution instead.
|
|
if (!company && booking.isGovernment) {
|
|
return (
|
|
<SectionCard icon={Building2} title="Customer" accent="blue">
|
|
<Text size="sm" fw={600}>
|
|
{booking.governmentInstitution ?? "Government"}
|
|
</Text>
|
|
</SectionCard>
|
|
);
|
|
}
|
|
|
|
if (!company) {
|
|
return (
|
|
<SectionCard icon={Building2} title="Customer" accent="blue">
|
|
<Text size="sm" c="dimmed">
|
|
No customer linked to this booking.
|
|
</Text>
|
|
</SectionCard>
|
|
);
|
|
}
|
|
|
|
const companyName = company.companyName ?? company.name ?? company.label;
|
|
|
|
const rows: FieldRowProps[] = [
|
|
{ icon: FileCheck, label: "TIN", value: company.tin },
|
|
{ icon: Mail, label: "Email", value: company.email },
|
|
{ icon: Phone, label: "Phone", value: company.phone },
|
|
{ icon: MapPin, label: "Address", value: company.address },
|
|
{ icon: User, label: "Contact person", value: company.contactPersonName },
|
|
{ icon: Phone, label: "Contact phone", value: company.contactPersonPhone },
|
|
];
|
|
|
|
return (
|
|
<LinkedEntityCard
|
|
icon={Building2}
|
|
title="Customer"
|
|
name={companyName ?? "Unnamed company"}
|
|
to={company.id ? `/dashboard/customers/${company.id}` : null}
|
|
accent="blue"
|
|
rows={rows}
|
|
emptyMessage="No additional company details available."
|
|
/>
|
|
);
|
|
}
|