🎉 initial commit

This commit is contained in:
2026-08-17 00:22:30 +02:00
parent cd04ebe254
commit 55a51a521d
19 changed files with 1645 additions and 35 deletions
+78
View File
@@ -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>
)
}