🎉 initial commit
This commit is contained in:
+58
-1
@@ -1,4 +1,4 @@
|
||||
import { integer, pgTable, serial, text, timestamp, unique } from 'drizzle-orm/pg-core'
|
||||
import { boolean, integer, pgTable, serial, text, timestamp, unique } from 'drizzle-orm/pg-core'
|
||||
|
||||
export const restaurantTables = pgTable('restaurant_tables', {
|
||||
id: serial('id').primaryKey(),
|
||||
@@ -22,6 +22,63 @@ export const reservations = pgTable(
|
||||
(table) => [unique().on(table.tableId, table.reservationTime)],
|
||||
)
|
||||
|
||||
// Better Auth's standard schema (staff accounts) — see https://www.better-auth.com/docs/concepts/database
|
||||
// `role`/`banned`/`banReason`/`banExpires` and `session.impersonatedBy` are added by the `admin` plugin.
|
||||
export const user = pgTable('user', {
|
||||
id: text('id').primaryKey(),
|
||||
name: text('name').notNull(),
|
||||
email: text('email').notNull().unique(),
|
||||
emailVerified: boolean('email_verified').notNull(),
|
||||
image: text('image'),
|
||||
createdAt: timestamp('created_at').notNull(),
|
||||
updatedAt: timestamp('updated_at').notNull(),
|
||||
role: text('role'),
|
||||
banned: boolean('banned'),
|
||||
banReason: text('ban_reason'),
|
||||
banExpires: timestamp('ban_expires'),
|
||||
})
|
||||
|
||||
export const session = pgTable('session', {
|
||||
id: text('id').primaryKey(),
|
||||
expiresAt: timestamp('expires_at').notNull(),
|
||||
token: text('token').notNull().unique(),
|
||||
createdAt: timestamp('created_at').notNull(),
|
||||
updatedAt: timestamp('updated_at').notNull(),
|
||||
ipAddress: text('ip_address'),
|
||||
userAgent: text('user_agent'),
|
||||
userId: text('user_id')
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: 'cascade' }),
|
||||
impersonatedBy: text('impersonated_by'),
|
||||
})
|
||||
|
||||
export const account = pgTable('account', {
|
||||
id: text('id').primaryKey(),
|
||||
accountId: text('account_id').notNull(),
|
||||
providerId: text('provider_id').notNull(),
|
||||
userId: text('user_id')
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: 'cascade' }),
|
||||
accessToken: text('access_token'),
|
||||
refreshToken: text('refresh_token'),
|
||||
idToken: text('id_token'),
|
||||
accessTokenExpiresAt: timestamp('access_token_expires_at'),
|
||||
refreshTokenExpiresAt: timestamp('refresh_token_expires_at'),
|
||||
scope: text('scope'),
|
||||
password: text('password'),
|
||||
createdAt: timestamp('created_at').notNull(),
|
||||
updatedAt: timestamp('updated_at').notNull(),
|
||||
})
|
||||
|
||||
export const verification = pgTable('verification', {
|
||||
id: text('id').primaryKey(),
|
||||
identifier: text('identifier').notNull(),
|
||||
value: text('value').notNull(),
|
||||
expiresAt: timestamp('expires_at').notNull(),
|
||||
createdAt: timestamp('created_at'),
|
||||
updatedAt: timestamp('updated_at'),
|
||||
})
|
||||
|
||||
export type RestaurantTable = typeof restaurantTables.$inferSelect
|
||||
export type Reservation = typeof reservations.$inferSelect
|
||||
export type NewReservation = typeof reservations.$inferInsert
|
||||
|
||||
+65
-13
@@ -1,22 +1,74 @@
|
||||
import 'dotenv/config'
|
||||
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { hashPassword } from 'better-auth/crypto'
|
||||
import { eq } from 'drizzle-orm'
|
||||
|
||||
import { db } from './index'
|
||||
import { restaurantTables } from './schema'
|
||||
import { account, restaurantTables, user } from './schema'
|
||||
|
||||
async function seed() {
|
||||
const tables = await db
|
||||
.insert(restaurantTables)
|
||||
.values([
|
||||
{ name: 'Tisch 1', seats: 2 },
|
||||
{ name: 'Tisch 2', seats: 2 },
|
||||
{ name: 'Tisch 3', seats: 4 },
|
||||
{ name: 'Tisch 4', seats: 4 },
|
||||
{ name: 'Tisch 5', seats: 6 },
|
||||
{ name: 'Tisch 6', seats: 8 },
|
||||
])
|
||||
.returning()
|
||||
const [existingTable] = await db.select().from(restaurantTables).limit(1)
|
||||
|
||||
if (existingTable) {
|
||||
console.log('Skipped table seed (restaurant_tables is not empty).')
|
||||
} else {
|
||||
const tables = await db
|
||||
.insert(restaurantTables)
|
||||
.values([
|
||||
{ name: 'Tisch 1', seats: 2 },
|
||||
{ name: 'Tisch 2', seats: 2 },
|
||||
{ name: 'Tisch 3', seats: 4 },
|
||||
{ name: 'Tisch 4', seats: 4 },
|
||||
{ name: 'Tisch 5', seats: 6 },
|
||||
{ name: 'Tisch 6', seats: 8 },
|
||||
])
|
||||
.returning()
|
||||
|
||||
console.log(`Seeded ${tables.length} tables.`)
|
||||
}
|
||||
|
||||
const staffEmail = process.env.STAFF_SEED_EMAIL
|
||||
const staffPassword = process.env.STAFF_SEED_PASSWORD
|
||||
|
||||
if (staffEmail && staffPassword) {
|
||||
const email = staffEmail.toLowerCase()
|
||||
const [existing] = await db.select().from(user).where(eq(user.email, email))
|
||||
|
||||
if (existing) {
|
||||
console.log(`Staff account already exists: ${email}`)
|
||||
} else {
|
||||
const staffUserId = randomUUID()
|
||||
const now = new Date()
|
||||
|
||||
await db.insert(user).values({
|
||||
id: staffUserId,
|
||||
name: 'Admin',
|
||||
email,
|
||||
emailVerified: true,
|
||||
role: 'admin',
|
||||
banned: false,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
})
|
||||
|
||||
// Mirrors what Better Auth's sign-up endpoint stores for an email/password account.
|
||||
await db.insert(account).values({
|
||||
id: randomUUID(),
|
||||
userId: staffUserId,
|
||||
accountId: staffUserId,
|
||||
providerId: 'credential',
|
||||
password: await hashPassword(staffPassword),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
})
|
||||
|
||||
console.log(`Seeded staff account: ${email}`)
|
||||
}
|
||||
} else {
|
||||
console.log('Skipped staff account seed (STAFF_SEED_EMAIL / STAFF_SEED_PASSWORD not set).')
|
||||
}
|
||||
|
||||
console.log(`Seeded ${tables.length} tables.`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createAuthClient } from 'better-auth/react'
|
||||
import { adminClient } from 'better-auth/client/plugins'
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
plugins: [adminClient()],
|
||||
})
|
||||
@@ -0,0 +1,43 @@
|
||||
import { betterAuth } from 'better-auth'
|
||||
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
|
||||
import { admin } from 'better-auth/plugins/admin'
|
||||
import { tanstackStartCookies } from 'better-auth/tanstack-start'
|
||||
|
||||
import { db } from '#/db'
|
||||
import * as schema from '#/db/schema'
|
||||
|
||||
function createAuth() {
|
||||
const secret = process.env.BETTER_AUTH_SECRET
|
||||
|
||||
if (!secret) {
|
||||
throw new Error('BETTER_AUTH_SECRET environment variable is not set')
|
||||
}
|
||||
|
||||
return betterAuth({
|
||||
secret,
|
||||
database: drizzleAdapter(db, {
|
||||
provider: 'pg',
|
||||
schema,
|
||||
}),
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
// Staff accounts are provisioned via the seed script, not public self sign-up.
|
||||
disableSignUp: true,
|
||||
},
|
||||
session: {
|
||||
expiresIn: 60 * 60 * 12,
|
||||
},
|
||||
// `tanstackStartCookies` must stay last so it sees every other plugin's Set-Cookie headers.
|
||||
plugins: [admin(), tanstackStartCookies()],
|
||||
})
|
||||
}
|
||||
|
||||
let authInstance: ReturnType<typeof createAuth> | undefined
|
||||
|
||||
// Lazily constructed so nothing here runs at module load time — a top-level
|
||||
// `betterAuth(...)` call would get pulled into the client bundle (and with it
|
||||
// the Postgres driver) by any route file that imports a sibling export.
|
||||
export function getAuth() {
|
||||
authInstance ??= createAuth()
|
||||
return authInstance
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { createServerFn } from '@tanstack/react-start'
|
||||
import { getRequest } from '@tanstack/react-start/server'
|
||||
|
||||
export async function getStaffSession() {
|
||||
const { getAuth } = await import('#/lib/auth-instance')
|
||||
return getAuth().api.getSession({ headers: getRequest().headers })
|
||||
}
|
||||
|
||||
export async function requireStaffSession() {
|
||||
const session = await getStaffSession()
|
||||
|
||||
if (!session) {
|
||||
throw new Error('Not signed in')
|
||||
}
|
||||
|
||||
return session
|
||||
}
|
||||
|
||||
export const getCurrentStaffUser = createServerFn({ method: 'GET' }).handler(async () => {
|
||||
const session = await getStaffSession()
|
||||
return session?.user ?? null
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
export function formatDateTimeLocal(date: Date) {
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
}
|
||||
+80
-1
@@ -1,15 +1,18 @@
|
||||
import { createServerFn } from '@tanstack/react-start'
|
||||
import { and, eq } from 'drizzle-orm'
|
||||
import { and, eq, ne } from 'drizzle-orm'
|
||||
import { z } from 'zod'
|
||||
|
||||
import { db } from '#/db'
|
||||
import { reservations, restaurantTables } from '#/db/schema'
|
||||
import { requireStaffSession } from '#/lib/auth'
|
||||
|
||||
export const getTables = createServerFn({ method: 'GET' }).handler(async () => {
|
||||
return db.select().from(restaurantTables).orderBy(restaurantTables.name)
|
||||
})
|
||||
|
||||
export const getReservations = createServerFn({ method: 'GET' }).handler(async () => {
|
||||
await requireStaffSession()
|
||||
|
||||
return db
|
||||
.select({
|
||||
id: reservations.id,
|
||||
@@ -84,3 +87,79 @@ export const createReservation = createServerFn({ method: 'POST' })
|
||||
|
||||
return reservation
|
||||
})
|
||||
|
||||
const updateReservationSchema = createReservationSchema.extend({
|
||||
id: z.number().int().positive(),
|
||||
})
|
||||
|
||||
export const updateReservation = createServerFn({ method: 'POST' })
|
||||
.validator(updateReservationSchema)
|
||||
.handler(async ({ data }) => {
|
||||
await requireStaffSession()
|
||||
|
||||
const reservationTime = new Date(data.reservationTime)
|
||||
|
||||
const [table] = await db
|
||||
.select()
|
||||
.from(restaurantTables)
|
||||
.where(eq(restaurantTables.id, data.tableId))
|
||||
|
||||
if (!table) {
|
||||
throw new Error('Selected table does not exist')
|
||||
}
|
||||
|
||||
if (data.partySize > table.seats) {
|
||||
throw new Error(`${table.name} only seats up to ${table.seats} guests`)
|
||||
}
|
||||
|
||||
const [conflict] = await db
|
||||
.select()
|
||||
.from(reservations)
|
||||
.where(
|
||||
and(
|
||||
eq(reservations.tableId, data.tableId),
|
||||
eq(reservations.reservationTime, reservationTime),
|
||||
ne(reservations.id, data.id),
|
||||
),
|
||||
)
|
||||
|
||||
if (conflict) {
|
||||
throw new Error('This table is already booked for that time')
|
||||
}
|
||||
|
||||
const [updated] = await db
|
||||
.update(reservations)
|
||||
.set({
|
||||
tableId: data.tableId,
|
||||
customerName: data.customerName,
|
||||
customerEmail: data.customerEmail,
|
||||
partySize: data.partySize,
|
||||
reservationTime,
|
||||
})
|
||||
.where(eq(reservations.id, data.id))
|
||||
.returning()
|
||||
|
||||
if (!updated) {
|
||||
throw new Error('Reservation not found')
|
||||
}
|
||||
|
||||
return updated
|
||||
})
|
||||
|
||||
const deleteReservationSchema = z.object({
|
||||
id: z.number().int().positive(),
|
||||
})
|
||||
|
||||
export const deleteReservation = createServerFn({ method: 'POST' })
|
||||
.validator(deleteReservationSchema)
|
||||
.handler(async ({ data }) => {
|
||||
await requireStaffSession()
|
||||
|
||||
const [deleted] = await db.delete(reservations).where(eq(reservations.id, data.id)).returning()
|
||||
|
||||
if (!deleted) {
|
||||
throw new Error('Reservation not found')
|
||||
}
|
||||
|
||||
return deleted
|
||||
})
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createServerFn } from '@tanstack/react-start'
|
||||
|
||||
export const listStaffMembers = createServerFn({ method: 'GET' }).handler(async () => {
|
||||
const [{ getAuth }, { getRequest }] = await Promise.all([
|
||||
import('#/lib/auth-instance'),
|
||||
import('@tanstack/react-start/server'),
|
||||
])
|
||||
|
||||
const { users } = await getAuth().api.listUsers({
|
||||
headers: getRequest().headers,
|
||||
query: { sortBy: 'createdAt', sortDirection: 'asc', limit: 100 },
|
||||
})
|
||||
|
||||
return users
|
||||
})
|
||||
+58
-3
@@ -11,6 +11,9 @@
|
||||
import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as IndexRouteImport } from './routes/index'
|
||||
import { Route as ImpressumRouteImport } from './routes/impressum'
|
||||
import { Route as StaffIndexRouteImport } from './routes/staff.index'
|
||||
import { Route as StaffLoginRouteImport } from './routes/staff.login'
|
||||
import { Route as StaffTeamRouteImport } from './routes/staff.team'
|
||||
|
||||
const IndexRoute = IndexRouteImport.update({
|
||||
id: '/',
|
||||
@@ -22,31 +25,59 @@ const ImpressumRoute = ImpressumRouteImport.update({
|
||||
path: '/impressum',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const StaffIndexRoute = StaffIndexRouteImport.update({
|
||||
id: '/staff/',
|
||||
path: '/staff/',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const StaffLoginRoute = StaffLoginRouteImport.update({
|
||||
id: '/staff/login',
|
||||
path: '/staff/login',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const StaffTeamRoute = StaffTeamRouteImport.update({
|
||||
id: '/staff/team',
|
||||
path: '/staff/team',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'/impressum': typeof ImpressumRoute
|
||||
'/staff/login': typeof StaffLoginRoute
|
||||
'/staff/team': typeof StaffTeamRoute
|
||||
'/staff/': typeof StaffIndexRoute
|
||||
}
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'/impressum': typeof ImpressumRoute
|
||||
'/staff/login': typeof StaffLoginRoute
|
||||
'/staff/team': typeof StaffTeamRoute
|
||||
'/staff': typeof StaffIndexRoute
|
||||
}
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRouteImport
|
||||
'/': typeof IndexRoute
|
||||
'/impressum': typeof ImpressumRoute
|
||||
'/staff/login': typeof StaffLoginRoute
|
||||
'/staff/team': typeof StaffTeamRoute
|
||||
'/staff/': typeof StaffIndexRoute
|
||||
}
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths: '/' | '/impressum'
|
||||
fullPaths: '/' | '/impressum' | '/staff/login' | '/staff/team' | '/staff/'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to: '/' | '/impressum'
|
||||
id: '__root__' | '/' | '/impressum'
|
||||
to: '/' | '/impressum' | '/staff/login' | '/staff/team' | '/staff'
|
||||
id:
|
||||
'__root__' | '/' | '/impressum' | '/staff/login' | '/staff/team' | '/staff/'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
ImpressumRoute: typeof ImpressumRoute
|
||||
StaffLoginRoute: typeof StaffLoginRoute
|
||||
StaffTeamRoute: typeof StaffTeamRoute
|
||||
StaffIndexRoute: typeof StaffIndexRoute
|
||||
}
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
@@ -65,12 +96,36 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ImpressumRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/staff/': {
|
||||
id: '/staff/'
|
||||
path: '/staff'
|
||||
fullPath: '/staff/'
|
||||
preLoaderRoute: typeof StaffIndexRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/staff/login': {
|
||||
id: '/staff/login'
|
||||
path: '/staff/login'
|
||||
fullPath: '/staff/login'
|
||||
preLoaderRoute: typeof StaffLoginRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/staff/team': {
|
||||
id: '/staff/team'
|
||||
path: '/staff/team'
|
||||
fullPath: '/staff/team'
|
||||
preLoaderRoute: typeof StaffTeamRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
ImpressumRoute: ImpressumRoute,
|
||||
StaffLoginRoute: StaffLoginRoute,
|
||||
StaffTeamRoute: StaffTeamRoute,
|
||||
StaffIndexRoute: StaffIndexRoute,
|
||||
}
|
||||
export const routeTree = rootRouteImport
|
||||
._addFileChildren(rootRouteChildren)
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createFileRoute, useRouter } from '@tanstack/react-router'
|
||||
|
||||
import { SiteFooter } from '#/components/site-footer'
|
||||
import { SiteHeader } from '#/components/site-header'
|
||||
import { formatDateTimeLocal } from '#/lib/datetime'
|
||||
import { createReservation, getTables } from '#/lib/reservations'
|
||||
|
||||
export const Route = createFileRoute('/')({
|
||||
@@ -23,11 +24,6 @@ const OPENING_HOURS = [
|
||||
{ day: 'Sonntag', hours: ['11:30 – 13:30', '17:00 – 22:00'] },
|
||||
]
|
||||
|
||||
function formatDateTimeLocal(date: Date) {
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
}
|
||||
|
||||
function FlameIcon() {
|
||||
return (
|
||||
<svg className="hero-flame" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
import { useState } from 'react'
|
||||
import { createFileRoute, Link, redirect, useRouter } from '@tanstack/react-router'
|
||||
|
||||
import { getCurrentStaffUser } from '#/lib/auth'
|
||||
import { authClient } from '#/lib/auth-client'
|
||||
import { formatDateTimeLocal } from '#/lib/datetime'
|
||||
import {
|
||||
createReservation,
|
||||
deleteReservation,
|
||||
getReservations,
|
||||
getTables,
|
||||
updateReservation,
|
||||
} from '#/lib/reservations'
|
||||
|
||||
export const Route = createFileRoute('/staff/')({
|
||||
component: StaffDashboard,
|
||||
beforeLoad: async () => {
|
||||
const staffUser = await getCurrentStaffUser()
|
||||
if (!staffUser) {
|
||||
throw redirect({ to: '/staff/login' })
|
||||
}
|
||||
return { staffUser }
|
||||
},
|
||||
loader: async ({ context }) => {
|
||||
const [reservations, tables] = await Promise.all([getReservations(), getTables()])
|
||||
return { staffUser: context.staffUser, reservations, tables }
|
||||
},
|
||||
})
|
||||
|
||||
const dateTimeFormatter = new Intl.DateTimeFormat('de-DE', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
})
|
||||
|
||||
function isSameDay(a: Date, b: Date) {
|
||||
return (
|
||||
a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate()
|
||||
)
|
||||
}
|
||||
|
||||
type ReservationRow = Awaited<ReturnType<typeof getReservations>>[number]
|
||||
|
||||
type FormState = {
|
||||
tableId: number | string
|
||||
customerName: string
|
||||
customerEmail: string
|
||||
partySize: number
|
||||
reservationTime: string
|
||||
}
|
||||
|
||||
function emptyForm(defaultTableId: number | string): FormState {
|
||||
return {
|
||||
tableId: defaultTableId,
|
||||
customerName: '',
|
||||
customerEmail: '',
|
||||
partySize: 2,
|
||||
reservationTime: formatDateTimeLocal(new Date(Date.now() + 60 * 60 * 1000)),
|
||||
}
|
||||
}
|
||||
|
||||
function StaffDashboard() {
|
||||
const router = useRouter()
|
||||
const { staffUser, reservations, tables } = Route.useLoaderData()
|
||||
|
||||
const [editingId, setEditingId] = useState<number | null>(null)
|
||||
const [form, setForm] = useState<FormState>(() => emptyForm(tables[0]?.id ?? ''))
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [success, setSuccess] = useState<string | null>(null)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [deletingId, setDeletingId] = useState<number | null>(null)
|
||||
|
||||
const now = new Date()
|
||||
const todaysReservations = reservations.filter((r) => isSameDay(new Date(r.reservationTime), now))
|
||||
const guestsToday = todaysReservations.reduce((sum, r) => sum + r.partySize, 0)
|
||||
const upcoming = reservations.filter((r) => new Date(r.reservationTime).getTime() >= now.getTime())
|
||||
|
||||
function startEdit(reservation: ReservationRow) {
|
||||
setEditingId(reservation.id)
|
||||
setForm({
|
||||
tableId: reservation.tableId,
|
||||
customerName: reservation.customerName,
|
||||
customerEmail: reservation.customerEmail,
|
||||
partySize: reservation.partySize,
|
||||
reservationTime: formatDateTimeLocal(new Date(reservation.reservationTime)),
|
||||
})
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
}
|
||||
|
||||
function cancelEdit() {
|
||||
setEditingId(null)
|
||||
setForm(emptyForm(tables[0]?.id ?? ''))
|
||||
setError(null)
|
||||
}
|
||||
|
||||
async function handleSubmit(event: React.FormEvent) {
|
||||
event.preventDefault()
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
|
||||
if (!form.tableId) {
|
||||
setError('Bitte wählen Sie einen Tisch aus')
|
||||
return
|
||||
}
|
||||
|
||||
setIsSubmitting(true)
|
||||
try {
|
||||
const payload = {
|
||||
tableId: Number(form.tableId),
|
||||
customerName: form.customerName,
|
||||
customerEmail: form.customerEmail,
|
||||
partySize: Number(form.partySize),
|
||||
reservationTime: new Date(form.reservationTime).toISOString(),
|
||||
}
|
||||
|
||||
if (editingId) {
|
||||
await updateReservation({ data: { id: editingId, ...payload } })
|
||||
setSuccess('Reservierung wurde aktualisiert.')
|
||||
} else {
|
||||
await createReservation({ data: payload })
|
||||
setSuccess('Reservierung wurde angelegt.')
|
||||
}
|
||||
|
||||
setEditingId(null)
|
||||
setForm(emptyForm(tables[0]?.id ?? ''))
|
||||
await router.invalidate()
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Etwas ist schiefgelaufen')
|
||||
} finally {
|
||||
setIsSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete(reservation: ReservationRow) {
|
||||
if (!window.confirm(`Reservierung von ${reservation.customerName} wirklich löschen?`)) {
|
||||
return
|
||||
}
|
||||
|
||||
setDeletingId(reservation.id)
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
|
||||
try {
|
||||
await deleteReservation({ data: { id: reservation.id } })
|
||||
if (editingId === reservation.id) {
|
||||
cancelEdit()
|
||||
}
|
||||
setSuccess('Reservierung wurde gelöscht.')
|
||||
await router.invalidate()
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Etwas ist schiefgelaufen')
|
||||
} finally {
|
||||
setDeletingId(null)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleLogout() {
|
||||
await authClient.signOut()
|
||||
await router.navigate({ to: '/staff/login' })
|
||||
await router.invalidate()
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="staff-page">
|
||||
<header className="staff-topbar">
|
||||
<Link className="wordmark" to="/">
|
||||
Steakhaus <span>bei Mirko</span>
|
||||
</Link>
|
||||
<div className="staff-topbar-right">
|
||||
{staffUser.role === 'admin' && (
|
||||
<Link className="btn btn-secondary" to="/staff/team">
|
||||
Mitarbeiter
|
||||
</Link>
|
||||
)}
|
||||
<span>Angemeldet als {staffUser.name}</span>
|
||||
<button type="button" className="btn btn-secondary" onClick={handleLogout}>
|
||||
Abmelden
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className="page staff-main">
|
||||
<h1 className="section-heading">Reservierungen</h1>
|
||||
|
||||
<div className="staff-stats">
|
||||
<div className="stat-card">
|
||||
<span className="stat-value">{reservations.length}</span>
|
||||
<span className="stat-label">Reservierungen gesamt</span>
|
||||
</div>
|
||||
<div className="stat-card">
|
||||
<span className="stat-value">{todaysReservations.length}</span>
|
||||
<span className="stat-label">Heute</span>
|
||||
</div>
|
||||
<div className="stat-card">
|
||||
<span className="stat-value">{guestsToday}</span>
|
||||
<span className="stat-label">Gäste heute</span>
|
||||
</div>
|
||||
<div className="stat-card">
|
||||
<span className="stat-value">{upcoming.length}</span>
|
||||
<span className="stat-label">Anstehend</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="staff-form-section">
|
||||
<h2 className="section-heading staff-subheading">
|
||||
{editingId ? 'Reservierung bearbeiten' : 'Neue Reservierung'}
|
||||
</h2>
|
||||
|
||||
<form className="reservation-form" onSubmit={handleSubmit}>
|
||||
<label>
|
||||
Tisch
|
||||
<select
|
||||
value={form.tableId}
|
||||
onChange={(e) => setForm((f) => ({ ...f, tableId: e.target.value }))}
|
||||
required
|
||||
>
|
||||
<option value="" disabled>
|
||||
Tisch auswählen
|
||||
</option>
|
||||
{tables.map((table) => (
|
||||
<option key={table.id} value={table.id}>
|
||||
{table.name} ({table.seats} Plätze)
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<div className="form-row">
|
||||
<label>
|
||||
Name
|
||||
<input
|
||||
type="text"
|
||||
value={form.customerName}
|
||||
onChange={(e) => setForm((f) => ({ ...f, customerName: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
E-Mail
|
||||
<input
|
||||
type="email"
|
||||
value={form.customerEmail}
|
||||
onChange={(e) => setForm((f) => ({ ...f, customerEmail: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="form-row">
|
||||
<label>
|
||||
Anzahl Personen
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
max={20}
|
||||
value={form.partySize}
|
||||
onChange={(e) => setForm((f) => ({ ...f, partySize: Number(e.target.value) }))}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Datum & Uhrzeit
|
||||
<input
|
||||
type="datetime-local"
|
||||
value={form.reservationTime}
|
||||
onChange={(e) => setForm((f) => ({ ...f, reservationTime: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="form-actions">
|
||||
<button type="submit" disabled={isSubmitting}>
|
||||
{isSubmitting ? 'Wird gespeichert …' : editingId ? 'Speichern' : 'Anlegen'}
|
||||
</button>
|
||||
{editingId && (
|
||||
<button type="button" className="btn btn-secondary" onClick={cancelEdit}>
|
||||
Abbrechen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{error && <p className="message message-error">{error}</p>}
|
||||
{success && <p className="message message-success">{success}</p>}
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="staff-table-section">
|
||||
{reservations.length === 0 ? (
|
||||
<p className="empty-state">Noch keine Reservierungen vorhanden.</p>
|
||||
) : (
|
||||
<div className="table-scroll">
|
||||
<table className="reservations-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum & Uhrzeit</th>
|
||||
<th>Tisch</th>
|
||||
<th>Kunde</th>
|
||||
<th>Personen</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{reservations.map((reservation) => (
|
||||
<tr key={reservation.id} className={editingId === reservation.id ? 'is-editing' : undefined}>
|
||||
<td>{dateTimeFormatter.format(new Date(reservation.reservationTime))}</td>
|
||||
<td>{reservation.tableName}</td>
|
||||
<td>
|
||||
{reservation.customerName}
|
||||
<br />
|
||||
<span className="muted">{reservation.customerEmail}</span>
|
||||
</td>
|
||||
<td>{reservation.partySize}</td>
|
||||
<td className="table-actions">
|
||||
<button type="button" className="btn btn-secondary" onClick={() => startEdit(reservation)}>
|
||||
Bearbeiten
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-danger"
|
||||
disabled={deletingId === reservation.id}
|
||||
onClick={() => handleDelete(reservation)}
|
||||
>
|
||||
{deletingId === reservation.id ? 'Löschen …' : 'Löschen'}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { useState } from 'react'
|
||||
import { createFileRoute, redirect, useRouter } from '@tanstack/react-router'
|
||||
|
||||
import { getCurrentStaffUser } from '#/lib/auth'
|
||||
import { authClient } from '#/lib/auth-client'
|
||||
|
||||
export const Route = createFileRoute('/staff/login')({
|
||||
component: StaffLogin,
|
||||
beforeLoad: async () => {
|
||||
const staffUser = await getCurrentStaffUser()
|
||||
if (staffUser) {
|
||||
throw redirect({ to: '/staff' })
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
function StaffLogin() {
|
||||
const router = useRouter()
|
||||
|
||||
const [email, setEmail] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
async function handleSubmit(event: React.FormEvent) {
|
||||
event.preventDefault()
|
||||
setError(null)
|
||||
setIsSubmitting(true)
|
||||
|
||||
const { error: signInError } = await authClient.signIn.email({ email, password })
|
||||
|
||||
if (signInError) {
|
||||
setError(signInError.message ?? 'Etwas ist schiefgelaufen')
|
||||
setIsSubmitting(false)
|
||||
return
|
||||
}
|
||||
|
||||
await router.navigate({ to: '/staff' })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="staff-page staff-login-page">
|
||||
<form className="reservation-form staff-login-form" onSubmit={handleSubmit}>
|
||||
<div className="staff-login-heading">
|
||||
<span className="section-kicker">Mitarbeiterbereich</span>
|
||||
<h1 className="section-heading">Anmelden</h1>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
E-Mail
|
||||
<input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
autoFocus
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Passwort
|
||||
<input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<button type="submit" disabled={isSubmitting}>
|
||||
{isSubmitting ? 'Wird geprüft …' : 'Anmelden'}
|
||||
</button>
|
||||
|
||||
{error && <p className="message message-error">{error}</p>}
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
import { useState } from 'react'
|
||||
import { createFileRoute, Link, redirect, useRouter } from '@tanstack/react-router'
|
||||
|
||||
import { getCurrentStaffUser } from '#/lib/auth'
|
||||
import { authClient } from '#/lib/auth-client'
|
||||
import { listStaffMembers } from '#/lib/staff'
|
||||
|
||||
export const Route = createFileRoute('/staff/team')({
|
||||
component: StaffTeam,
|
||||
beforeLoad: async () => {
|
||||
const staffUser = await getCurrentStaffUser()
|
||||
if (!staffUser) {
|
||||
throw redirect({ to: '/staff/login' })
|
||||
}
|
||||
if (staffUser.role !== 'admin') {
|
||||
throw redirect({ to: '/staff' })
|
||||
}
|
||||
return { staffUser }
|
||||
},
|
||||
loader: async ({ context }) => {
|
||||
const members = await listStaffMembers()
|
||||
return { staffUser: context.staffUser, members }
|
||||
},
|
||||
})
|
||||
|
||||
type StaffMember = Awaited<ReturnType<typeof listStaffMembers>>[number]
|
||||
|
||||
type FormState = {
|
||||
name: string
|
||||
email: string
|
||||
password: string
|
||||
role: 'admin' | 'user'
|
||||
}
|
||||
|
||||
function emptyForm(): FormState {
|
||||
return { name: '', email: '', password: '', role: 'user' }
|
||||
}
|
||||
|
||||
function StaffTeam() {
|
||||
const router = useRouter()
|
||||
const { staffUser, members } = Route.useLoaderData()
|
||||
|
||||
const [form, setForm] = useState<FormState>(emptyForm)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [success, setSuccess] = useState<string | null>(null)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [busyId, setBusyId] = useState<string | null>(null)
|
||||
|
||||
async function handleCreate(event: React.FormEvent) {
|
||||
event.preventDefault()
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
setIsSubmitting(true)
|
||||
|
||||
const { error: createError } = await authClient.admin.createUser({
|
||||
name: form.name,
|
||||
email: form.email,
|
||||
password: form.password,
|
||||
role: form.role,
|
||||
})
|
||||
|
||||
if (createError) {
|
||||
setError(createError.message ?? 'Etwas ist schiefgelaufen')
|
||||
setIsSubmitting(false)
|
||||
return
|
||||
}
|
||||
|
||||
setSuccess('Mitarbeiter wurde angelegt.')
|
||||
setForm(emptyForm())
|
||||
setIsSubmitting(false)
|
||||
await router.invalidate()
|
||||
}
|
||||
|
||||
async function handleRemove(member: StaffMember) {
|
||||
if (!window.confirm(`Zugang für ${member.name} wirklich entfernen?`)) {
|
||||
return
|
||||
}
|
||||
|
||||
setBusyId(member.id)
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
|
||||
const { error: removeError } = await authClient.admin.removeUser({ userId: member.id })
|
||||
|
||||
if (removeError) {
|
||||
setError(removeError.message ?? 'Etwas ist schiefgelaufen')
|
||||
} else {
|
||||
setSuccess('Zugang wurde entfernt.')
|
||||
await router.invalidate()
|
||||
}
|
||||
|
||||
setBusyId(null)
|
||||
}
|
||||
|
||||
async function handleToggleRole(member: StaffMember) {
|
||||
const nextRole = member.role === 'admin' ? 'user' : 'admin'
|
||||
setBusyId(member.id)
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
|
||||
const { error: roleError } = await authClient.admin.setRole({ userId: member.id, role: nextRole })
|
||||
|
||||
if (roleError) {
|
||||
setError(roleError.message ?? 'Etwas ist schiefgelaufen')
|
||||
} else {
|
||||
setSuccess('Rolle wurde aktualisiert.')
|
||||
await router.invalidate()
|
||||
}
|
||||
|
||||
setBusyId(null)
|
||||
}
|
||||
|
||||
async function handleToggleBan(member: StaffMember) {
|
||||
setBusyId(member.id)
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
|
||||
const { error: banError } = member.banned
|
||||
? await authClient.admin.unbanUser({ userId: member.id })
|
||||
: await authClient.admin.banUser({ userId: member.id })
|
||||
|
||||
if (banError) {
|
||||
setError(banError.message ?? 'Etwas ist schiefgelaufen')
|
||||
} else {
|
||||
setSuccess(member.banned ? 'Zugang wurde reaktiviert.' : 'Zugang wurde gesperrt.')
|
||||
await router.invalidate()
|
||||
}
|
||||
|
||||
setBusyId(null)
|
||||
}
|
||||
|
||||
async function handleSetPassword(member: StaffMember) {
|
||||
const newPassword = window.prompt(`Neues Passwort für ${member.name} (mind. 8 Zeichen):`)
|
||||
|
||||
if (!newPassword) {
|
||||
return
|
||||
}
|
||||
|
||||
setBusyId(member.id)
|
||||
setError(null)
|
||||
setSuccess(null)
|
||||
|
||||
const { error: passwordError } = await authClient.admin.setUserPassword({
|
||||
userId: member.id,
|
||||
newPassword,
|
||||
})
|
||||
|
||||
if (passwordError) {
|
||||
setError(passwordError.message ?? 'Etwas ist schiefgelaufen')
|
||||
} else {
|
||||
setSuccess(`Passwort für ${member.name} wurde geändert.`)
|
||||
}
|
||||
|
||||
setBusyId(null)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="staff-page">
|
||||
<header className="staff-topbar">
|
||||
<Link className="wordmark" to="/">
|
||||
Steakhaus <span>bei Mirko</span>
|
||||
</Link>
|
||||
<div className="staff-topbar-right">
|
||||
<Link className="btn btn-secondary" to="/staff">
|
||||
Zu den Reservierungen
|
||||
</Link>
|
||||
<span>Angemeldet als {staffUser.name}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className="page staff-main">
|
||||
<h1 className="section-heading">Mitarbeiter</h1>
|
||||
|
||||
<section className="staff-form-section">
|
||||
<h2 className="section-heading staff-subheading">Neuer Mitarbeiter</h2>
|
||||
|
||||
<form className="reservation-form" onSubmit={handleCreate}>
|
||||
<div className="form-row">
|
||||
<label>
|
||||
Name
|
||||
<input
|
||||
type="text"
|
||||
value={form.name}
|
||||
onChange={(e) => setForm((f) => ({ ...f, name: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
E-Mail
|
||||
<input
|
||||
type="email"
|
||||
value={form.email}
|
||||
onChange={(e) => setForm((f) => ({ ...f, email: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="form-row">
|
||||
<label>
|
||||
Passwort
|
||||
<input
|
||||
type="password"
|
||||
value={form.password}
|
||||
onChange={(e) => setForm((f) => ({ ...f, password: e.target.value }))}
|
||||
minLength={8}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Rolle
|
||||
<select
|
||||
value={form.role}
|
||||
onChange={(e) => setForm((f) => ({ ...f, role: e.target.value as FormState['role'] }))}
|
||||
>
|
||||
<option value="user">Mitarbeiter</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" disabled={isSubmitting}>
|
||||
{isSubmitting ? 'Wird angelegt …' : 'Anlegen'}
|
||||
</button>
|
||||
|
||||
{error && <p className="message message-error">{error}</p>}
|
||||
{success && <p className="message message-success">{success}</p>}
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section className="staff-table-section">
|
||||
<div className="table-scroll">
|
||||
<table className="reservations-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>E-Mail</th>
|
||||
<th>Rolle</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{members.map((member) => (
|
||||
<tr key={member.id}>
|
||||
<td>{member.name}</td>
|
||||
<td>{member.email}</td>
|
||||
<td>{member.role === 'admin' ? 'Admin' : 'Mitarbeiter'}</td>
|
||||
<td>{member.banned ? 'Gesperrt' : 'Aktiv'}</td>
|
||||
<td className="table-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={busyId === member.id}
|
||||
onClick={() => handleToggleRole(member)}
|
||||
>
|
||||
{member.role === 'admin' ? 'Zu Mitarbeiter machen' : 'Zu Admin machen'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={busyId === member.id}
|
||||
onClick={() => handleSetPassword(member)}
|
||||
>
|
||||
Passwort setzen
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={busyId === member.id || member.id === staffUser.id}
|
||||
onClick={() => handleToggleBan(member)}
|
||||
>
|
||||
{member.banned ? 'Entsperren' : 'Sperren'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-danger"
|
||||
disabled={busyId === member.id || member.id === staffUser.id}
|
||||
onClick={() => handleRemove(member)}
|
||||
>
|
||||
Entfernen
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { createStartHandler, defaultStreamHandler } from '@tanstack/react-start/server'
|
||||
import type { Register } from '@tanstack/react-router'
|
||||
import type { RequestHandler } from '@tanstack/react-start/server'
|
||||
|
||||
import { getAuth } from '#/lib/auth-instance'
|
||||
|
||||
const startFetch = createStartHandler(defaultStreamHandler)
|
||||
|
||||
export type ServerEntry = { fetch: RequestHandler<Register> }
|
||||
|
||||
const fetch: RequestHandler<Register> = (request, opts) => {
|
||||
const url = new URL(request.url)
|
||||
|
||||
if (url.pathname.startsWith('/api/auth')) {
|
||||
return getAuth().handler(request)
|
||||
}
|
||||
|
||||
return startFetch(request, opts)
|
||||
}
|
||||
|
||||
export default { fetch } satisfies ServerEntry
|
||||
+185
@@ -408,6 +408,191 @@ a {
|
||||
color: var(--gold-bright);
|
||||
}
|
||||
|
||||
/* Staff dashboard */
|
||||
|
||||
.staff-page {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.staff-topbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 1rem;
|
||||
padding: 1.25rem 1.5rem;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.staff-topbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.staff-topbar-right .btn {
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.staff-main {
|
||||
padding: 3rem 1.5rem 4rem;
|
||||
}
|
||||
|
||||
.staff-subheading {
|
||||
font-size: 1.35rem;
|
||||
margin: 2.5rem 0 1.25rem;
|
||||
}
|
||||
|
||||
.staff-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 1rem;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 40rem) {
|
||||
.staff-stats {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
padding: 1.25rem;
|
||||
background: var(--bg-raised);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-family: 'Fraunces', Georgia, serif;
|
||||
font-size: 1.75rem;
|
||||
color: var(--gold-bright);
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 0.8rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.staff-form-section {
|
||||
max-width: 36rem;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-actions .btn {
|
||||
font: inherit;
|
||||
padding: 0.7rem 1.5rem;
|
||||
}
|
||||
|
||||
.staff-table-section {
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
|
||||
.table-scroll {
|
||||
overflow-x: auto;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.reservations-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.reservations-table th,
|
||||
.reservations-table td {
|
||||
padding: 0.85rem 1rem;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.reservations-table th {
|
||||
color: var(--gold);
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
background: var(--bg-raised);
|
||||
}
|
||||
|
||||
.reservations-table tbody tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.reservations-table tr.is-editing {
|
||||
background: rgba(201, 161, 90, 0.08);
|
||||
}
|
||||
|
||||
.reservations-table .muted {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.table-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.table-actions .btn {
|
||||
font: inherit;
|
||||
padding: 0.4rem 0.85rem;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: transparent;
|
||||
border-color: #5c1f1f;
|
||||
color: #f3a9a9;
|
||||
}
|
||||
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: #3a1414;
|
||||
}
|
||||
|
||||
.btn-danger:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
color: var(--text-muted);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.staff-login-page {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.staff-login-form {
|
||||
width: 100%;
|
||||
max-width: 24rem;
|
||||
}
|
||||
|
||||
.staff-login-heading {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.staff-login-heading .section-heading {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
/* Legal page */
|
||||
|
||||
.legal-page {
|
||||
|
||||
Reference in New Issue
Block a user