The owner page Where: Manage → Business → Holidays, at /owner/settings/holidays. It needs the same permission as Business Details. Adding: you enter a name, a start date and an optional end date. Leaving the end empty gives a single day. Upcoming and past: upcoming holidays are listed by date, with a trash icon to remove each one. Past ones sit in a collapsed “Past” list. Existing bookings: if appointments are already booked on those dates, you see them and confirm with “Add Anyway”, the same pattern as Opening Hours. Nothing is cancelled automatically. What it does to booking Customer calendar: holiday dates are greyed out, for every staff member and every service. Time slots: no slots are offered on those dates. Direct bookings: staff and owner bookings and reschedules onto a holiday are refused, with a message naming the holiday. This is deliberate, but if you want owners to be able to override it, that’s a small change.
This commit is contained in:
13 files changed
+914
-3
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import type { Metadata } from "next";
|
||||
import { redirect } from "next/navigation";
|
||||
import { auth } from "@/auth";
|
||||
import { SettingsPageShell } from "@/components/settings/settings-page-shell";
|
||||
import { prisma } from "@/lib/db/prisma";
|
||||
import { hasPermission } from "@/lib/auth/permissions";
|
||||
import { Permission } from "@/generated/prisma/enums";
|
||||
import { getActingBusinessContext } from "@/lib/business/get-acting-business-context";
|
||||
import { todayIn } from "@/lib/time/business-time";
|
||||
import { listBusinessHolidays } from "@/services/business/holiday.service";
|
||||
import { HolidaysManager } from "@/features/owner/components/holidays-manager";
|
||||
|
||||
export const metadata: Metadata = { title: "Holidays" };
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function OwnerHolidaysPage() {
|
||||
const session = await auth();
|
||||
if (!session?.user) redirect("/sign-in");
|
||||
|
||||
const canManage = await hasPermission(session.user.id, Permission.MANAGE_BUSINESS_PROFILE);
|
||||
if (!canManage) redirect("/staff");
|
||||
|
||||
const context = await getActingBusinessContext();
|
||||
if (!context) redirect("/staff");
|
||||
|
||||
const business = await prisma.business.findUnique({
|
||||
where: { id: context.businessId },
|
||||
select: { timezone: true, locale: true },
|
||||
});
|
||||
if (!business) redirect("/staff");
|
||||
|
||||
const holidays = await listBusinessHolidays(prisma, context.businessId);
|
||||
|
||||
return (
|
||||
<SettingsPageShell title="Holidays" mainClassName="lg:max-w-2xl">
|
||||
<HolidaysManager
|
||||
holidays={holidays}
|
||||
today={todayIn(business.timezone)}
|
||||
locale={business.locale}
|
||||
/>
|
||||
</SettingsPageShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user