forked from fahrPool/fahrPool
feat: restyle Auftrag-anlegen page
This commit is contained in:
parent
55f19858d7
commit
ae78bcaab2
|
|
@ -2,6 +2,10 @@ import { redirect } from "next/navigation";
|
||||||
import { createAuftrag } from "./actions";
|
import { createAuftrag } from "./actions";
|
||||||
import { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
import { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
||||||
import { loadProfile } from "@/lib/auth/profile";
|
import { loadProfile } from "@/lib/auth/profile";
|
||||||
|
import { Card } from "@/components/ui/Card";
|
||||||
|
import { Button } from "@/components/ui/Button";
|
||||||
|
import { Alert } from "@/components/ui/Alert";
|
||||||
|
import { FormField, FIELD_CLASSES } from "@/components/ui/FormField";
|
||||||
|
|
||||||
export default async function NeuerAuftragPage({
|
export default async function NeuerAuftragPage({
|
||||||
searchParams,
|
searchParams,
|
||||||
|
|
@ -12,7 +16,7 @@ export default async function NeuerAuftragPage({
|
||||||
// Seitenebenen-Gate zusaetzlich zur INSERT-RLS-Policy auf `auftraege`
|
// Seitenebenen-Gate zusaetzlich zur INSERT-RLS-Policy auf `auftraege`
|
||||||
// (admin/disponent-only): ohne diesen Check wuerde die Seite das Formular
|
// (admin/disponent-only): ohne diesen Check wuerde die Seite das Formular
|
||||||
// auch Fahrern/Readonly anzeigen, obwohl ein Submit dann ohnehin an der
|
// auch Fahrern/Readonly anzeigen, obwohl ein Submit dann ohnehin an der
|
||||||
// RLS-Policy scheitern wuerde -- das ist verwirrend UX statt eines echten
|
// RLS-Policy scheitern wuerde -- das ist verwirrende UX statt eines echten
|
||||||
// Sicherheitslecks, aber ein frueher Redirect ist die klarere Loesung.
|
// Sicherheitslecks, aber ein frueher Redirect ist die klarere Loesung.
|
||||||
if (
|
if (
|
||||||
profileResult.status !== "ok" ||
|
profileResult.status !== "ok" ||
|
||||||
|
|
@ -25,16 +29,20 @@ export default async function NeuerAuftragPage({
|
||||||
const [orte, fahrzeuge] = await Promise.all([listOrte(), listFahrzeuge()]);
|
const [orte, fahrzeuge] = await Promise.all([listOrte(), listFahrzeuge()]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main className="mx-auto max-w-xl p-4 md:p-8">
|
||||||
<h1>Neuen Auftrag anlegen</h1>
|
<h1 className="mb-6 text-xl font-semibold text-asphalt-grey">Neuen Auftrag anlegen</h1>
|
||||||
{error && <p role="alert">{error}</p>}
|
{error && (
|
||||||
|
<div className="mb-6">
|
||||||
|
<Alert>{error}</Alert>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Card>
|
||||||
<form action={createAuftrag}>
|
<form action={createAuftrag}>
|
||||||
{vorgaenger_auftrag_id && (
|
{vorgaenger_auftrag_id && (
|
||||||
<input type="hidden" name="vorgaenger_auftrag_id" value={vorgaenger_auftrag_id} />
|
<input type="hidden" name="vorgaenger_auftrag_id" value={vorgaenger_auftrag_id} />
|
||||||
)}
|
)}
|
||||||
<div>
|
<FormField label="Abholort" htmlFor="abholort_id">
|
||||||
<label htmlFor="abholort_id">Abholort</label>
|
<select id="abholort_id" name="abholort_id" required defaultValue="" className={FIELD_CLASSES}>
|
||||||
<select id="abholort_id" name="abholort_id" required defaultValue="">
|
|
||||||
<option value="" disabled>
|
<option value="" disabled>
|
||||||
Bitte waehlen
|
Bitte waehlen
|
||||||
</option>
|
</option>
|
||||||
|
|
@ -44,10 +52,9 @@ export default async function NeuerAuftragPage({
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</FormField>
|
||||||
<div>
|
<FormField label="Zielort" htmlFor="zielort_id">
|
||||||
<label htmlFor="zielort_id">Zielort</label>
|
<select id="zielort_id" name="zielort_id" required defaultValue="" className={FIELD_CLASSES}>
|
||||||
<select id="zielort_id" name="zielort_id" required defaultValue="">
|
|
||||||
<option value="" disabled>
|
<option value="" disabled>
|
||||||
Bitte waehlen
|
Bitte waehlen
|
||||||
</option>
|
</option>
|
||||||
|
|
@ -57,10 +64,9 @@ export default async function NeuerAuftragPage({
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</FormField>
|
||||||
<div>
|
<FormField label="Fahrzeug" htmlFor="fahrzeug_id">
|
||||||
<label htmlFor="fahrzeug_id">Fahrzeug</label>
|
<select id="fahrzeug_id" name="fahrzeug_id" required defaultValue="" className={FIELD_CLASSES}>
|
||||||
<select id="fahrzeug_id" name="fahrzeug_id" required defaultValue="">
|
|
||||||
<option value="" disabled>
|
<option value="" disabled>
|
||||||
Bitte waehlen
|
Bitte waehlen
|
||||||
</option>
|
</option>
|
||||||
|
|
@ -70,9 +76,10 @@ export default async function NeuerAuftragPage({
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</FormField>
|
||||||
<button type="submit">Auftrag anlegen</button>
|
<Button type="submit">Auftrag anlegen</Button>
|
||||||
</form>
|
</form>
|
||||||
|
</Card>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue