From 262f4c6ca5310c9c893db89c8cf4bec2bca0377b Mon Sep 17 00:00:00 2001 From: BOHA Date: Sun, 7 Jun 2026 08:15:18 +0200 Subject: [PATCH] feat(mui): migrate ProjectDetail onto MUI kit Co-Authored-By: Claude Opus 4.8 (1M context) --- src/admin/pages/ProjectDetail.tsx | 644 +++++++++++++++--------------- 1 file changed, 328 insertions(+), 316 deletions(-) diff --git a/src/admin/pages/ProjectDetail.tsx b/src/admin/pages/ProjectDetail.tsx index b2f6b71..cde46fa 100644 --- a/src/admin/pages/ProjectDetail.tsx +++ b/src/admin/pages/ProjectDetail.tsx @@ -3,8 +3,12 @@ import { useQuery } from "@tanstack/react-query"; import { useApiMutation } from "../lib/queries/mutations"; import { useAlert } from "../context/AlertContext"; import { useAuth } from "../context/AuthContext"; -import { useParams, useNavigate, Link } from "react-router-dom"; +import { useParams, useNavigate, Link as RouterLink } from "react-router-dom"; import { motion } from "framer-motion"; +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import IconButton from "@mui/material/IconButton"; +import MenuItem from "@mui/material/MenuItem"; import { projectDetailOptions, @@ -13,11 +17,19 @@ import { } from "../lib/queries/projects"; import { userListOptions, type User as ApiUser } from "../lib/queries/users"; import Forbidden from "../components/Forbidden"; -import ConfirmModal from "../components/ConfirmModal"; -import FormField from "../components/FormField"; -import AdminDatePicker from "../components/AdminDatePicker"; import ProjectFileManager from "../components/ProjectFileManager"; -import apiFetch from "../utils/api"; +import { + Button, + Card, + Field, + TextField, + Select, + DateField, + StatusChip, + CheckboxField, + ConfirmDialog, + LoadingState, +} from "../ui"; const API_BASE = "/api/admin"; @@ -27,6 +39,15 @@ const STATUS_LABELS: Record = { zruseny: "Zrušený", }; +const STATUS_COLORS: Record< + string, + "default" | "success" | "error" | "warning" | "info" +> = { + aktivni: "success", + dokonceny: "info", + zruseny: "default", +}; + function formatNoteDate(dateStr: string) { if (!dateStr) return ""; const d = new Date(dateStr); @@ -51,6 +72,36 @@ interface ProjectForm { responsible_user_id: string; } +const BackIcon = ( + + + +); + +const TrashIcon = ( + + + + + +); + export default function ProjectDetail() { const { id } = useParams(); const alert = useAlert(); @@ -226,353 +277,302 @@ export default function ProjectDetail() { } }; + if (isPending) { + return ; + } + if (!project) return null; const canEdit = hasPermission("projects.edit"); - if (isPending) { - return ( -
-
-
- ); - } - return ( -
+ {/* Header */} -
- - + + - -
-

- Projekt {project.project_number} -

-
-
- {canEdit && ( -
- + {!project.order_id && ( + )} - - {!project.order_id && ( - - )} -
- )} +
+ )} + - {/* Form */} + {/* Basic info form */} -
-

Základní údaje

-
-
- - - - - updateForm("name", e.target.value)} - className="admin-form-input" - placeholder="Název projektu" - disabled={!canEdit} - /> - -
- -
- - - - - - -
- -
- - - - - updateForm("start_date", val)} - disabled={!canEdit} - /> - - - updateForm("end_date", val)} - disabled={!canEdit} - /> - -
-
-
+ + + Základní údaje + + + + + + + updateForm("name", e.target.value)} + placeholder="Název projektu" + fullWidth + disabled={!canEdit} + /> + + + + + + + + + + + + + + updateForm("start_date", val)} + disabled={!canEdit} + /> + + + updateForm("end_date", val)} + disabled={!canEdit} + /> + + +
{/* Notes */} -
-

Poznámky

+ + + Poznámky + {/* Add note */} -
-