forked from fahrPool/fahrPool
64 lines
2.1 KiB
TypeScript
64 lines
2.1 KiB
TypeScript
import { createAuftrag } from "./actions";
|
|
import { listOrte, listFahrzeuge } from "@/lib/auftraege/queries";
|
|
|
|
export default async function NeuerAuftragPage({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ error?: string; vorgaenger_auftrag_id?: string }>;
|
|
}) {
|
|
const { error, vorgaenger_auftrag_id } = await searchParams;
|
|
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>
|
|
</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})
|
|
</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}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</div>
|
|
<button type="submit">Auftrag anlegen</button>
|
|
</form>
|
|
</main>
|
|
);
|
|
}
|