Add company_email to company table and detail page

This commit is contained in:
Dave 2026-08-17 19:19:12 +02:00
parent 19f60eba42
commit b0b625414a
5 changed files with 33 additions and 5 deletions

View file

@ -115,13 +115,13 @@ async function sendSignedLetterToAll(appointmentId: string) {
}>;
const allDirectorEmails: string[] = [];
for (const j of junctions) {
const d = j.expand?.director as { email?: string; cell?: string; first_names?: string; surname?: string } | undefined;
const d = j.expand?.director as { email?: string; telephone?: string; first_names?: string; surname?: string } | undefined;
if (d?.email) allDirectorEmails.push(d.email);
}
// Add company email
// Company email is not in the schema — we'll add it later; skip for now
const uniqueEmails = [...new Set(allDirectorEmails)];
// Add company email if available
const companyEmail = (company as { company_email?: string } | undefined)?.company_email;
const uniqueEmails = [...new Set(companyEmail ? [...allDirectorEmails, companyEmail] : allDirectorEmails)];
// Send to each director email
for (const email of uniqueEmails) {

View file

@ -342,6 +342,7 @@ export default function CompanyExplorer({
<th className="text-left font-semibold px-4 py-3">Compliance</th>
<th className="text-left font-semibold px-4 py-3">Client</th>
<th className="text-left font-semibold px-4 py-3">Last checked</th>
<th className="text-left font-semibold px-4 py-3">Email</th>
<th className="px-3 py-3"></th>
</tr>
</thead>
@ -397,6 +398,20 @@ export default function CompanyExplorer({
<td className="px-4 py-3 text-muted whitespace-nowrap">
{formatDate(c.last_checked)}
</td>
<td className="px-4 py-3">
{c.company_email ? (
<a
href={`mailto:${c.company_email}`}
onClick={(e) => e.stopPropagation()}
className="text-xs text-accent hover:underline no-underline"
title={c.company_email}
>
{c.company_email}
</a>
) : (
<span className="text-muted text-xs">—</span>
)}
</td>
<td className="px-4 py-3 pr-5 whitespace-nowrap">
<div className="flex items-center gap-1.5 justify-end">
<button
@ -446,6 +461,7 @@ export default function CompanyExplorer({
<td className="px-4 py-3"><Skeleton className="h-5 w-24" /></td>
<td className="px-4 py-3"><Skeleton className="h-4 w-24" /></td>
<td className="px-4 py-3"><Skeleton className="h-5 w-24" /></td>
<td className="px-4 py-3"><Skeleton className="h-4 w-36" /></td>
<td className="px-3 py-3"></td>
</tr>
))
@ -526,6 +542,11 @@ export default function CompanyExplorer({
<p className="text-xs text-muted">
Last checked: {formatDate(c.last_checked)}
</p>
{c.company_email ? (
<p className="text-xs text-accent mt-0.5">
{c.company_email}
</p>
) : null}
</div>
);
})}

View file

@ -255,6 +255,12 @@ export default async function CompanyDetailPage({ params }: Props) {
<div className="bg-surface border border-border rounded-lg p-6">
<h2 className="text-lg font-semibold text-fg mb-3">Postal address</h2>
<p className="text-sm text-fg-2 whitespace-pre-line break-words leading-relaxed">{text(company.postal_address)}</p>
{company.company_email ? (
<div className="mt-3 pt-3 border-t border-border-soft">
<p className="text-xs uppercase tracking-[0.08em] text-muted font-semibold mb-1">Email</p>
<a href={`mailto:${company.company_email}`} className="text-sm text-accent hover:underline">{text(company.company_email)}</a>
</div>
) : null}
</div>
</section>

View file

@ -76,6 +76,7 @@ export interface YsterbaardCompany {
postal_address: string | null;
physical_address_normalized: string | null;
postal_address_normalized: string | null;
company_email: string | null;
sars_tax_number: string | null;
uif_registration_number: string | null;
compensation_fund_registration_number: string | null;

File diff suppressed because one or more lines are too long