142 lines
5.5 KiB
TypeScript
142 lines
5.5 KiB
TypeScript
import { Form, Head } from '@inertiajs/react';
|
|
import InputError from '@/components/input-error';
|
|
import PasskeyVerify from '@/components/passkey-verify';
|
|
import PasswordInput from '@/components/password-input';
|
|
import TextLink from '@/components/text-link';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Checkbox } from '@/components/ui/checkbox';
|
|
import { Input } from '@/components/ui/input';
|
|
import { Label } from '@/components/ui/label';
|
|
import { Spinner } from '@/components/ui/spinner';
|
|
import { store } from '@/routes/login';
|
|
import { request } from '@/routes/password';
|
|
|
|
type Props = {
|
|
status?: string;
|
|
canResetPassword: boolean;
|
|
microsoftEnabled: boolean;
|
|
};
|
|
|
|
export default function Login({
|
|
status,
|
|
canResetPassword,
|
|
microsoftEnabled,
|
|
}: Props) {
|
|
return (
|
|
<>
|
|
<Head title="Entrar" />
|
|
|
|
<PasskeyVerify
|
|
label="Entrar com chave de acesso"
|
|
loadingLabel="A autenticar..."
|
|
separator="Ou continuar com email"
|
|
/>
|
|
|
|
{microsoftEnabled && (
|
|
<>
|
|
<Button variant="outline" className="w-full" asChild>
|
|
<a href="/auth/microsoft/redirect">
|
|
Entrar com a conta Microsoft
|
|
</a>
|
|
</Button>
|
|
<div className="relative text-center text-sm">
|
|
<span className="relative z-10 bg-background px-2 text-muted-foreground">
|
|
ou utilize a conta local
|
|
</span>
|
|
<span className="absolute inset-x-0 top-1/2 border-t" />
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
<Form
|
|
{...store.form()}
|
|
resetOnSuccess={['password']}
|
|
className="flex flex-col gap-6"
|
|
>
|
|
{({ processing, errors }) => (
|
|
<>
|
|
<div className="grid gap-6">
|
|
<div className="grid gap-2">
|
|
<Label htmlFor="email">Email</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
name="email"
|
|
required
|
|
autoFocus
|
|
tabIndex={1}
|
|
autoComplete="email"
|
|
placeholder="nome@escola.pt"
|
|
/>
|
|
<InputError message={errors.email} />
|
|
</div>
|
|
|
|
<div className="grid gap-2">
|
|
<div className="flex items-center">
|
|
<Label htmlFor="password">
|
|
Palavra-passe
|
|
</Label>
|
|
{canResetPassword && (
|
|
<TextLink
|
|
href={request()}
|
|
className="ml-auto text-sm"
|
|
tabIndex={5}
|
|
>
|
|
Recuperar palavra-passe
|
|
</TextLink>
|
|
)}
|
|
</div>
|
|
<PasswordInput
|
|
id="password"
|
|
name="password"
|
|
required
|
|
tabIndex={2}
|
|
autoComplete="current-password"
|
|
placeholder="Palavra-passe"
|
|
/>
|
|
<InputError message={errors.password} />
|
|
</div>
|
|
|
|
<div className="flex items-center space-x-3">
|
|
<Checkbox
|
|
id="remember"
|
|
name="remember"
|
|
tabIndex={3}
|
|
/>
|
|
<Label htmlFor="remember">Manter sessão</Label>
|
|
</div>
|
|
|
|
<Button
|
|
type="submit"
|
|
className="mt-4 w-full"
|
|
tabIndex={4}
|
|
disabled={processing}
|
|
data-test="login-button"
|
|
>
|
|
{processing && <Spinner />}
|
|
Entrar
|
|
</Button>
|
|
</div>
|
|
|
|
<p className="text-center text-sm text-muted-foreground">
|
|
O acesso é atribuído pela escola. Contacte os
|
|
Serviços de Informática se ainda não tiver conta.
|
|
</p>
|
|
</>
|
|
)}
|
|
</Form>
|
|
|
|
{status && (
|
|
<div className="mb-4 text-center text-sm font-medium text-green-600">
|
|
{status}
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
|
|
Login.layout = {
|
|
title: 'Entrar no Portal de Reservas',
|
|
description: 'Utilize o seu endereço institucional e palavra-passe.',
|
|
};
|