Initial PHP rebuild of the app
This commit is contained in:
690 files changed
+33944
-12046
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import type { Metadata } from "next";
|
||||
import { redirect } from "next/navigation";
|
||||
import { auth } from "@/auth";
|
||||
import { TopNav } from "@/components/navigation/top-nav";
|
||||
import { prisma } from "@/lib/db/prisma";
|
||||
import { getBranding } from "@/lib/business/branding";
|
||||
import { CalendarConnectionPanel } from "@/features/calendar/components/calendar-connection-panel";
|
||||
|
||||
export const metadata: Metadata = { title: "Google Calendar" };
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function StaffCalendarSettingsPage() {
|
||||
const session = await auth();
|
||||
if (!session?.user?.id) redirect("/sign-in?callbackUrl=/staff/settings/calendar");
|
||||
|
||||
const staffProfile = await prisma.staffProfile.findUnique({ where: { userId: session.user.id } });
|
||||
if (!staffProfile) redirect("/home");
|
||||
|
||||
const [connection, branding] = await Promise.all([
|
||||
prisma.staffCalendarConnection.findUnique({ where: { staffId: staffProfile.id } }),
|
||||
getBranding(),
|
||||
]);
|
||||
const connected = !!connection && !connection.revokedAt;
|
||||
const configured = !!process.env.GOOGLE_CALENDAR_CLIENT_ID && !!process.env.GOOGLE_CALENDAR_CLIENT_SECRET;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 px-6 pt-12 pb-12">
|
||||
<TopNav title="Google Calendar" onBack sticky className="bg-stone" />
|
||||
<p className="text-muted text-sm">
|
||||
One-way sync: {branding.name} stays the source of truth, and your confirmed appointments are pushed to
|
||||
Google Calendar. Nothing is ever imported back from Google.
|
||||
</p>
|
||||
<CalendarConnectionPanel
|
||||
configured={configured}
|
||||
initial={
|
||||
connected
|
||||
? {
|
||||
connected: true,
|
||||
accountEmail: connection.accountEmail,
|
||||
selectedCalendarName: connection.selectedCalendarName,
|
||||
lastSyncAt: connection.lastSyncAt?.toISOString(),
|
||||
lastSyncError: connection.lastSyncError,
|
||||
}
|
||||
: { connected: false }
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user