diff --git a/app/(protected)/capa-owner/page.tsx b/app/(protected)/capa-owner/page.tsx index 55b4e32..87e040c 100644 --- a/app/(protected)/capa-owner/page.tsx +++ b/app/(protected)/capa-owner/page.tsx @@ -78,9 +78,7 @@ export default async function CapaOwnerPage() {
{capa.description}
{incRef && ( - - {incRef} - +{incRef}
)}CAPA on-time rate: {capaRows.length > 0 ? Math.round((capaVerifiedCount / capaRows.length) * 100) : 'N/A'}%
+CAPA verification rate: {capaRows.length > 0 ? Math.round((capaVerifiedCount / capaRows.length) * 100) : 'N/A'}%
)} diff --git a/lib/notifications/capa-escalation.ts b/lib/notifications/capa-escalation.ts index 6764c87..1140589 100644 --- a/lib/notifications/capa-escalation.ts +++ b/lib/notifications/capa-escalation.ts @@ -45,6 +45,9 @@ export async function escalateOverdueCapa( const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? 'http://localhost:3000' let notified = 0 + const whatsappPhoneNumberId = await getApiKey(supabase, 'META_WHATSAPP_PHONE_NUMBER_ID') + const whatsappAccessToken = await getApiKey(supabase, 'META_WHATSAPP_ACCESS_TOKEN') + for (const capa of capas) { const threshold = getEscalationThreshold((capa as { due_date: string }).due_date) if (!threshold) continue @@ -98,14 +101,12 @@ export async function escalateOverdueCapa( const ownerPhone = (capa.owner as unknown as { phone: string | null } | null)?.phone ?? '' if (ownerPhone) { try { - const phoneNumberId = await getApiKey(supabase, 'META_WHATSAPP_PHONE_NUMBER_ID') - const accessToken = await getApiKey(supabase, 'META_WHATSAPP_ACCESS_TOKEN') await sendWhatsAppMessage( ownerPhone, 'ims_capa_overdue', [incidentRef, (capa as { description: string }).description, (capa as { due_date: string }).due_date], - phoneNumberId, - accessToken, + whatsappPhoneNumberId, + whatsappAccessToken, ) } catch (waErr) { console.error('WhatsApp escalation error:', waErr)