diff --git a/package-lock.json b/package-lock.json index f9d1d7e..dbc0086 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "date-fns": "^4.4.0", "image-size": "^2.0.2", "jszip": "^3.10.1", + "libphonenumber-js": "^1.13.15", "lucide-react": "^1.28.0", "luxon": "^3.7.2", "mariadb": "^3.5.3", @@ -8186,6 +8187,12 @@ "node": ">= 0.8.0" } }, + "node_modules/libphonenumber-js": { + "version": "1.13.15", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.13.15.tgz", + "integrity": "sha512-AHdhEQeDFEJ4GKDAQ9AwxChy+v2kUILUB3TGQRpkXMkWePjXTU/WQEzWVQoIx/Gz8fE73Wr5SEuZCy2vk8jrMQ==", + "license": "MIT" + }, "node_modules/lie": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", diff --git a/package.json b/package.json index 3c2d63e..11a607d 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "date-fns": "^4.4.0", "image-size": "^2.0.2", "jszip": "^3.10.1", + "libphonenumber-js": "^1.13.15", "lucide-react": "^1.28.0", "luxon": "^3.7.2", "mariadb": "^3.5.3", diff --git a/prisma/migrations/20261015120000_add_whatsapp_reminder_sent_at/migration.sql b/prisma/migrations/20261015120000_add_whatsapp_reminder_sent_at/migration.sql new file mode 100644 index 0000000..2d5040b --- /dev/null +++ b/prisma/migrations/20261015120000_add_whatsapp_reminder_sent_at/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE `Appointment` ADD COLUMN `whatsappReminderSentAt` DATETIME(3) NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d30522b..9a7f30a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1136,6 +1136,15 @@ model Appointment { /// notifying on reassignment exactly as it did before. staffSelectedByCustomer Boolean @default(true) + /// When staff last tapped "send on WhatsApp" for this booking's reminder — + /// the manual, free route (see lib/messaging/whatsapp.ts), so this records + /// that the message was OPENED for sending, not that it was delivered + /// (the app can't know). Exists so two people sharing a reminders list + /// don't text the same customer twice. Cleared whenever the booking's + /// time or barber changes (rescheduleAppointment): a reminder for the old + /// slot says nothing about the new one. + whatsappReminderSentAt DateTime? + status AppointmentStatus @default(CONFIRMED) /// Stored as UTC instants; the business's `timezone` (see Business model) diff --git a/src/app/(owner)/owner/appointments/[id]/page.tsx b/src/app/(owner)/owner/appointments/[id]/page.tsx index 88af4d5..5bacf8f 100644 --- a/src/app/(owner)/owner/appointments/[id]/page.tsx +++ b/src/app/(owner)/owner/appointments/[id]/page.tsx @@ -1,5 +1,6 @@ import type { Metadata } from "next"; import { Mail, Phone } from "lucide-react"; +import { WhatsAppButton } from "@/features/staff/components/whatsapp-button"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { auth } from "@/auth"; @@ -131,6 +132,19 @@ export default async function OwnerAppointmentDetailsPage({ >