refactor(mui): migrate ReservationPicker to kit Select
Replace the raw admin-form-select with the MUI kit Select (string-based value, converted at the boundary). Same query (warehouseReservationList, ACTIVE, perPage 100), same option labels, same onChange contract (reservationId|null, remainingQty). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import { Select } from "../../ui";
|
||||||
import { warehouseReservationListOptions } from "../../lib/queries/warehouse";
|
import { warehouseReservationListOptions } from "../../lib/queries/warehouse";
|
||||||
|
|
||||||
interface ReservationPickerProps {
|
interface ReservationPickerProps {
|
||||||
@@ -26,11 +28,9 @@ export default function ReservationPicker({
|
|||||||
const reservations = result?.data ?? [];
|
const reservations = result?.data ?? [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<select
|
<Select
|
||||||
className="admin-form-select"
|
value={value == null ? "" : String(value)}
|
||||||
value={value ?? ""}
|
onChange={(val) => {
|
||||||
onChange={(e) => {
|
|
||||||
const val = e.target.value;
|
|
||||||
if (!val) {
|
if (!val) {
|
||||||
onChange(null, 0);
|
onChange(null, 0);
|
||||||
return;
|
return;
|
||||||
@@ -42,13 +42,13 @@ export default function ReservationPicker({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option value="">— žádná rezervace —</option>
|
<MenuItem value="">— žádná rezervace —</MenuItem>
|
||||||
{reservations.map((r) => (
|
{reservations.map((r) => (
|
||||||
<option key={r.id} value={r.id}>
|
<MenuItem key={r.id} value={String(r.id)}>
|
||||||
R{r.id} — {r.project?.name ?? `Projekt #${r.project_id}`} — zbývá:{" "}
|
R{r.id} — {r.project?.name ?? `Projekt #${r.project_id}`} — zbývá:{" "}
|
||||||
{Number(r.remaining_qty)} {r.item?.unit ?? "ks"}
|
{Number(r.remaining_qty)} {r.item?.unit ?? "ks"}
|
||||||
</option>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</select>
|
</Select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user