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} )}