From 7b05c8cbce267b1985b17f46fa9f89928d196637 Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Wed, 29 Oct 2025 08:30:30 +0000 Subject: [PATCH] Add a weekly guard schedule overview page Add a new page to display a summarized weekly schedule for guards, divided by location, with detailed shift information accessible on click. Includes error handling for data fetching. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e0b5b11c-5b75-4389-8ea9-5f3cd9332f88 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e0b5b11c-5b75-4389-8ea9-5f3cd9332f88/EPTvOHB --- .replit | 4 ++++ client/src/pages/weekly-guards.tsx | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.replit b/.replit index bc23a6a..53baf59 100644 --- a/.replit +++ b/.replit @@ -19,6 +19,10 @@ externalPort = 80 localPort = 33035 externalPort = 3001 +[[ports]] +localPort = 39861 +externalPort = 6000 + [[ports]] localPort = 40417 externalPort = 8000 diff --git a/client/src/pages/weekly-guards.tsx b/client/src/pages/weekly-guards.tsx index 5a7d62c..f5bd40f 100644 --- a/client/src/pages/weekly-guards.tsx +++ b/client/src/pages/weekly-guards.tsx @@ -69,8 +69,18 @@ export default function WeeklyGuards() { ); const [dialogData, setDialogData] = useState(null); - const { data: scheduleData, isLoading } = useQuery({ + const { data: scheduleData, isLoading, error } = useQuery({ queryKey: ["/api/weekly-guards-schedule", selectedLocation, format(currentWeekStart, "yyyy-MM-dd")], + queryFn: async () => { + const startDate = format(currentWeekStart, "yyyy-MM-dd"); + const response = await fetch( + `/api/weekly-guards-schedule?location=${selectedLocation}&startDate=${startDate}` + ); + if (!response.ok) { + throw new Error("Failed to fetch weekly schedule"); + } + return response.json(); + }, enabled: !!selectedLocation, }); @@ -237,6 +247,14 @@ export default function WeeklyGuards() {

Caricamento...

+ ) : error ? ( + + +

+ Errore nel caricamento della pianificazione. Riprova più tardi. +

+
+
) : scheduleData && scheduleData.guards.length > 0 ? ( @@ -331,12 +349,12 @@ export default function WeeklyGuards() { {dialogData?.type === "fixed" ? ( <> - Turno Fisso - {dialogData.guardName} + Turno Fisso - {dialogData?.guardName} ) : ( <> - Turno Mobile - {dialogData.guardName} + Turno Mobile - {dialogData?.guardName} )}