690 files changed
+12045
-33943
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import { Scissors } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
import { auth } from "@/auth";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { getBranding } from "@/lib/business/branding";
|
||||
import { getPrimaryBusiness } from "@/lib/business/get-primary-business";
|
||||
import { hasPermission, isSuperAdmin } from "@/lib/auth/permissions";
|
||||
import { Permission } from "@/generated/prisma/enums";
|
||||
import { prisma } from "@/lib/db/prisma";
|
||||
import { WelcomeInstallCard } from "@/features/pwa/components/welcome-install-card";
|
||||
|
||||
/** The normal business welcome screen. Kept outside the root entry point so
|
||||
* Manager mode can redirect without evaluating business-only imports. */
|
||||
export default async function BusinessWelcomePage() {
|
||||
const session = await auth();
|
||||
if (session?.user) {
|
||||
const staffProfile = await prisma.staffProfile.findUnique({ where: { userId: session.user.id } });
|
||||
if (staffProfile) {
|
||||
const canManageStaff = await hasPermission(session.user.id, Permission.MANAGE_STAFF);
|
||||
redirect(canManageStaff ? "/owner" : "/staff");
|
||||
}
|
||||
if (await isSuperAdmin(session.user.id)) redirect("/owner/calendar");
|
||||
redirect("/home");
|
||||
}
|
||||
|
||||
const [branding, business] = await Promise.all([getBranding(), getPrimaryBusiness()]);
|
||||
const guestBookingEnabled = business.bookingRule?.allowGuestBooking ?? false;
|
||||
const heroImageMobileUrl = branding.welcomeBackgroundMobileUrl ?? branding.welcomeBackgroundDesktopUrl ?? branding.coverImageUrl;
|
||||
const heroImageDesktopUrl = branding.welcomeBackgroundDesktopUrl ?? branding.welcomeBackgroundMobileUrl ?? branding.coverImageUrl;
|
||||
const hasHeroImage = !!(heroImageMobileUrl || heroImageDesktopUrl);
|
||||
|
||||
return (
|
||||
<div id="main-content" className="relative flex min-h-screen flex-col justify-end overflow-hidden bg-ink px-8 pb-16 text-white">
|
||||
{heroImageMobileUrl && <div className="absolute inset-0 block bg-cover bg-center md:hidden" style={{ backgroundImage: `url(${heroImageMobileUrl})` }} aria-hidden="true" />}
|
||||
{heroImageDesktopUrl && <div className="absolute inset-0 hidden bg-cover bg-center md:block" style={{ backgroundImage: `url(${heroImageDesktopUrl})` }} aria-hidden="true" />}
|
||||
{hasHeroImage && <div className="from-ink via-ink/60 absolute inset-0 bg-gradient-to-t to-transparent" aria-hidden="true" />}
|
||||
<div className="relative z-10 mx-auto flex w-full max-w-sm flex-1 flex-col justify-end">
|
||||
<div className="mx-auto mb-8 flex items-center justify-center overflow-hidden text-ink">
|
||||
{branding.logoUrl ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element -- external business-supplied URL.
|
||||
<img src={branding.logoUrl} alt="" className="h-48 w-48 object-cover" />
|
||||
) : <Scissors className="h-8 w-8" aria-hidden="true" />}
|
||||
</div>
|
||||
<h1 className="mb-4 text-3xl font-bold tracking-tight">{branding.name}</h1>
|
||||
<p className="mb-8 max-w-xs text-lg text-white/85">Find, book & manage your appointments with ease.</p>
|
||||
<div className="space-y-4">
|
||||
<Button asChild variant="secondary" size="lg" className="w-full bg-white"><Link href="/register">Create Account</Link></Button>
|
||||
<Button asChild variant="secondary" size="lg" className="w-full border-2 border-white/20 bg-transparent text-white hover:bg-white/10"><Link href="/sign-in">Sign In</Link></Button>
|
||||
{guestBookingEnabled && <Button asChild variant="ghost" size="lg" className="w-full text-white/70 hover:bg-white/10 hover:text-white"><Link href="/book">Continue as Guest</Link></Button>}
|
||||
<Button asChild variant="ghost" size="lg" className="w-full text-white/70 hover:bg-white/10 hover:text-white"><Link href="/home">Browse Services</Link></Button>
|
||||
</div>
|
||||
<div className="mt-6"><WelcomeInstallCard businessName={branding.name} /></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user