diff --git a/src/admin/components/PlanCategoriesModal.tsx b/src/admin/components/PlanCategoriesModal.tsx index cc53da0..a83462d 100644 --- a/src/admin/components/PlanCategoriesModal.tsx +++ b/src/admin/components/PlanCategoriesModal.tsx @@ -1,5 +1,6 @@ import { useState } from "react"; -import FormModal from "./FormModal"; +import Box from "@mui/material/Box"; +import { Modal, TextField, Button } from "../ui"; import { useApiMutation } from "../lib/queries/mutations"; import { useAlert } from "../context/AlertContext"; import { PlanCategory } from "../lib/queries/plan"; @@ -91,20 +92,26 @@ export default function PlanCategoriesModal({ const busy = createCat.isPending || updateCat.isPending || deleteCat.isPending; + // Shared layout for a category row: color swatch | text input | actions. + const rowSx = { + display: "flex", + alignItems: "center", + gap: 1, + py: 1, + } as const; + return ( - -
+ {categories.map((c) => ( -
+ - { const v = e.target.value.trim(); if (v && v !== c.label) patch(c.id, { label: v }); }} - aria-label={`Název – ${c.label}`} + inputProps={{ "aria-label": `Název – ${c.label}` }} /> {confirmDeleteId === c.id ? ( <> - - + ) : ( <> - - + )} -
+
))} -
+ setNewColor(e.target.value)} aria-label="Barva nové kategorie" /> - setNewLabel(e.target.value)} onKeyDown={(e) => e.key === "Enter" && handleAdd()} /> - -
-
-
+ + + + ); } diff --git a/src/admin/components/PlanCellModal.tsx b/src/admin/components/PlanCellModal.tsx index bad9f29..6f01651 100644 --- a/src/admin/components/PlanCellModal.tsx +++ b/src/admin/components/PlanCellModal.tsx @@ -1,9 +1,18 @@ import { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; -import FormModal from "./FormModal"; -import FormField from "./FormField"; -import AdminDatePicker from "./AdminDatePicker"; -import ConfirmModal from "./ConfirmModal"; +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import { + Modal, + ConfirmDialog, + Field, + TextField, + Select, + DateField, + CheckboxField, + Button, + Card, +} from "../ui"; import useReducedMotion from "../hooks/useReducedMotion"; import { ResolvedCell, @@ -77,6 +86,26 @@ interface Props { onSwitchToEditRange: (entryId: number, userId: number, date: string) => void; } +const TrashIcon = ( + + + + + + + +); + export default function PlanCellModal(props: Props) { const { open, mode, onClose } = props; if (!open || mode.kind === "closed") return null; @@ -213,128 +242,111 @@ function EditForm(props: Props) { } }; + // If the row's current category was retired/hidden, still show it (marked) + // so the select reflects reality instead of silently snapping to the first + // active option. The server only re-checks the category if it changes, so + // keeping it saves fine. + const showRetiredCategory = + category && !activeCategories.some((c) => c.key === category); + return ( <> - + {mode.kind !== "create" && ( + + - ) : null - } - > - - + + )} + + - + {!isOverride && ( - - - + + + )} {!isOverride && isRange && ( - - - + + + )} - - - - - setProjectId(val ? Number(val) : null)} + options={[ + { value: "", label: "— bez projektu —" }, + ...projects.map((p) => ({ + value: String(p.id), + label: p.name, + })), + ]} + /> + + + - - -