now auto shows after being added.
This commit is contained in:
2 files changed
+25
-11
No files matched your search
@@ -31,14 +31,29 @@ export default async function StaffClientsPage({
|
|||||||
|
|
||||||
// Scoped via the appointment relation, not "every CustomerProfile row" —
|
// Scoped via the appointment relation, not "every CustomerProfile row" —
|
||||||
// a real business boundary even though this is a single-business v1 app
|
// a real business boundary even though this is a single-business v1 app
|
||||||
// (see docs/phase-5-summary.md). `select`-scoped rather than the full
|
// (see docs/phase-5-summary.md). A registered client with NO appointment
|
||||||
// row + full appointment `include` this used to fetch — the card only
|
// anywhere yet (freshly added via /staff/clients/add, or self-registered
|
||||||
// ever reads status/startAt off each appointment, never the service
|
// but never booked) is also included — otherwise a client staff just
|
||||||
// lines/notes/discount that a full include would also pull down for
|
// added would be invisible here until their first booking, which reads
|
||||||
// every appointment of every client on every page view (see the Phase 7
|
// as "did that even work?". A registered client with appointments only
|
||||||
// performance pass).
|
// at some other business (not reachable in this single-business-per-
|
||||||
|
// deployment app, but kept as a real predicate rather than an assumption)
|
||||||
|
// is correctly excluded either way. Guests are never included by this
|
||||||
|
// second branch — a guest profile is only ever created alongside an
|
||||||
|
// appointment (see resolveGuestCustomer), so one with zero appointments
|
||||||
|
// shouldn't exist, but isGuest: false is there as a real guard, not a
|
||||||
|
// guess. `select`-scoped rather than the full row + full appointment
|
||||||
|
// `include` this used to fetch — the card only ever reads status/startAt
|
||||||
|
// off each appointment, never the service lines/notes/discount that a
|
||||||
|
// full include would also pull down for every appointment of every
|
||||||
|
// client on every page view (see the Phase 7 performance pass).
|
||||||
const customers = await prisma.customerProfile.findMany({
|
const customers = await prisma.customerProfile.findMany({
|
||||||
where: { appointments: { some: { businessId: context.businessId } } },
|
where: {
|
||||||
|
OR: [
|
||||||
|
{ appointments: { some: { businessId: context.businessId } } },
|
||||||
|
{ isGuest: false, appointments: { none: {} } },
|
||||||
|
],
|
||||||
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
firstName: true,
|
firstName: true,
|
||||||
@@ -72,7 +87,7 @@ export default async function StaffClientsPage({
|
|||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="pb-8 lg:max-w-5xl">
|
<div className="pb-8">
|
||||||
<TopNav
|
<TopNav
|
||||||
title="Clients"
|
title="Clients"
|
||||||
sticky
|
sticky
|
||||||
@@ -141,7 +156,7 @@ export default async function StaffClientsPage({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid gap-3 lg:grid-cols-2">
|
<div className="grid gap-3 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
|
||||||
{sorted.map((customer) => {
|
{sorted.map((customer) => {
|
||||||
const completedVisits = customer.appointments.filter(
|
const completedVisits = customer.appointments.filter(
|
||||||
(a) => a.status === "COMPLETED",
|
(a) => a.status === "COMPLETED",
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ export function AddClientForm() {
|
|||||||
<div className="space-y-4 rounded-md border-line border bg-white p-6">
|
<div className="space-y-4 rounded-md border-line border bg-white p-6">
|
||||||
<p className="text-sm font-bold">{added.name} has been added.</p>
|
<p className="text-sm font-bold">{added.name} has been added.</p>
|
||||||
<p className="text-muted text-sm">
|
<p className="text-muted text-sm">
|
||||||
They can sign in anytime with just their email — no password, no invite email sent. They'll show up
|
They can sign in anytime with just their email — no password, no invite email sent.
|
||||||
in Clients once they have an appointment.
|
|
||||||
</p>
|
</p>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<Button variant="secondary" className="flex-1" onClick={() => router.push("/staff/clients")}>
|
<Button variant="secondary" className="flex-1" onClick={() => router.push("/staff/clients")}>
|
||||||
|
|||||||
Reference in new issue
Block a user