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 { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
||||
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({
|
||||
searchParams,
|
||||
|
|
@ -12,7 +16,7 @@ export default async function NeuerAuftragPage({
|
|||
// Seitenebenen-Gate zusaetzlich zur INSERT-RLS-Policy auf `auftraege`
|
||||
// (admin/disponent-only): ohne diesen Check wuerde die Seite das Formular
|
||||
// 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.
|
||||
if (
|
||||
profileResult.status !== "ok" ||
|
||||
|
|
@ -25,54 +29,57 @@ export default async function NeuerAuftragPage({
|
|||
const [orte, fahrzeuge] = await Promise.all([listOrte(), listFahrzeuge()]);
|
||||
|
||||
return (
|
||||
<main>
|
||||
<h1>Neuen Auftrag anlegen</h1>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
<form action={createAuftrag}>
|
||||
{vorgaenger_auftrag_id && (
|
||||
<input type="hidden" name="vorgaenger_auftrag_id" value={vorgaenger_auftrag_id} />
|
||||
)}
|
||||
<div>
|
||||
<label htmlFor="abholort_id">Abholort</label>
|
||||
<select id="abholort_id" name="abholort_id" required defaultValue="">
|
||||
<option value="" disabled>
|
||||
Bitte waehlen
|
||||
</option>
|
||||
{orte.map((ort) => (
|
||||
<option key={ort.id} value={ort.id}>
|
||||
{ort.adresse} ({ort.ansprechpartner})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<main className="mx-auto max-w-xl p-4 md:p-8">
|
||||
<h1 className="mb-6 text-xl font-semibold text-asphalt-grey">Neuen Auftrag anlegen</h1>
|
||||
{error && (
|
||||
<div className="mb-6">
|
||||
<Alert>{error}</Alert>
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="zielort_id">Zielort</label>
|
||||
<select id="zielort_id" name="zielort_id" required defaultValue="">
|
||||
<option value="" disabled>
|
||||
Bitte waehlen
|
||||
</option>
|
||||
{orte.map((ort) => (
|
||||
<option key={ort.id} value={ort.id}>
|
||||
{ort.adresse} ({ort.ansprechpartner})
|
||||
)}
|
||||
<Card>
|
||||
<form action={createAuftrag}>
|
||||
{vorgaenger_auftrag_id && (
|
||||
<input type="hidden" name="vorgaenger_auftrag_id" value={vorgaenger_auftrag_id} />
|
||||
)}
|
||||
<FormField label="Abholort" htmlFor="abholort_id">
|
||||
<select id="abholort_id" name="abholort_id" required defaultValue="" className={FIELD_CLASSES}>
|
||||
<option value="" disabled>
|
||||
Bitte waehlen
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="fahrzeug_id">Fahrzeug</label>
|
||||
<select id="fahrzeug_id" name="fahrzeug_id" required defaultValue="">
|
||||
<option value="" disabled>
|
||||
Bitte waehlen
|
||||
</option>
|
||||
{fahrzeuge.map((fahrzeug) => (
|
||||
<option key={fahrzeug.id} value={fahrzeug.id}>
|
||||
{fahrzeug.kennzeichen}
|
||||
{orte.map((ort) => (
|
||||
<option key={ort.id} value={ort.id}>
|
||||
{ort.adresse} ({ort.ansprechpartner})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</FormField>
|
||||
<FormField label="Zielort" htmlFor="zielort_id">
|
||||
<select id="zielort_id" name="zielort_id" required defaultValue="" className={FIELD_CLASSES}>
|
||||
<option value="" disabled>
|
||||
Bitte waehlen
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit">Auftrag anlegen</button>
|
||||
</form>
|
||||
{orte.map((ort) => (
|
||||
<option key={ort.id} value={ort.id}>
|
||||
{ort.adresse} ({ort.ansprechpartner})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</FormField>
|
||||
<FormField label="Fahrzeug" htmlFor="fahrzeug_id">
|
||||
<select id="fahrzeug_id" name="fahrzeug_id" required defaultValue="" className={FIELD_CLASSES}>
|
||||
<option value="" disabled>
|
||||
Bitte waehlen
|
||||
</option>
|
||||
{fahrzeuge.map((fahrzeug) => (
|
||||
<option key={fahrzeug.id} value={fahrzeug.id}>
|
||||
{fahrzeug.kennzeichen}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</FormField>
|
||||
<Button type="submit">Auftrag anlegen</Button>
|
||||
</form>
|
||||
</Card>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue