Staff / Owner

Merged staff and owner settings
This commit is contained in:
Stefan Lazic committed 2026-08-05 16:35:52 +01:00
1 parent cf3a28f3cd
commit 3300045d9e
23 files changed
+693 -236

No files matched your search

+6 -6
View File
@@ -4,7 +4,7 @@ import Link from "next/link";
import { redirect } from "next/navigation";
import { EmptyState } from "@/components/feedback/empty-state";
import { prisma } from "@/lib/db/prisma";
import { getActingStaff } from "@/lib/staff/get-acting-staff";
import { getActingBusinessContext } from "@/lib/business/get-acting-business-context";
import { matchesCustomerSearch } from "@/services/customer/customer.service";
import { getLoyaltySummariesForCustomers } from "@/services/loyalty/loyalty.service";
import { cn } from "@/lib/utils/cn";
@@ -19,8 +19,8 @@ export default async function StaffClientsPage({
}: {
searchParams: Promise<{ q?: string; sort?: string }>;
}) {
const staff = await getActingStaff();
if (!staff) redirect("/home");
const context = await getActingBusinessContext();
if (!context) redirect("/home");
const { q = "", sort } = await searchParams;
@@ -33,7 +33,7 @@ export default async function StaffClientsPage({
// every appointment of every client on every page view (see the Phase 7
// performance pass).
const customers = await prisma.customerProfile.findMany({
where: { appointments: { some: { businessId: staff.businessId } } },
where: { appointments: { some: { businessId: context.businessId } } },
select: {
id: true,
firstName: true,
@@ -41,7 +41,7 @@ export default async function StaffClientsPage({
email: true,
phone: true,
appointments: {
where: { businessId: staff.businessId },
where: { businessId: context.businessId },
orderBy: { startAt: "desc" },
select: { status: true, startAt: true },
},
@@ -49,7 +49,7 @@ export default async function StaffClientsPage({
});
const loyaltySummaries = await getLoyaltySummariesForCustomers(prisma, {
businessId: staff.businessId,
businessId: context.businessId,
customerIds: customers.map((c) => c.id),
});