From bdf7d52cd91e58529fe35d27d91d460bee7a0681 Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Mon, 2 Feb 2026 21:13:02 +0800 Subject: [PATCH] no message --- src/app/(main)/ps/page.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/ps/page.tsx b/src/app/(main)/ps/page.tsx index 6f1d87b..0d74e1c 100644 --- a/src/app/(main)/ps/page.tsx +++ b/src/app/(main)/ps/page.tsx @@ -12,7 +12,7 @@ import { OnlinePrediction, FileDownload, SettingsEthernet } from "@mui/icons-material"; import dayjs from "dayjs"; -import { I18nProvider } from "@/i18n"; +import { redirect } from "next/navigation"; import { NEXT_PUBLIC_API_URL } from "@/config/api"; export default function ProductionSchedulePage() { @@ -71,12 +71,22 @@ export default function ProductionSchedulePage() { const handleSearch = async () => { const token = localStorage.getItem("accessToken"); setLoading(true); + try { const response = await fetch(`${NEXT_PUBLIC_API_URL}/ps/search-ps?produceAt=${searchDate}`, { method: 'GET', headers: { 'Authorization': `Bearer ${token}` } }); + + if (response.status === 401 || response.status === 403) { + console.warn(`Auth error ${response.status} → clearing token & redirecting`); + window.location.href = "/login?session=expired"; + + return; // ← stops execution here + } + const data = await response.json(); + setSchedules(Array.isArray(data) ? data : []); } catch (e) { console.error("Search Error:", e); @@ -219,7 +229,7 @@ export default function ProductionSchedulePage() { const handleAutoGenJob = async () => { - if (!isDateToday) return; + //if (!isDateToday) return; const token = localStorage.getItem("accessToken"); setIsGenerating(true); try { @@ -375,7 +385,9 @@ export default function ProductionSchedulePage() { {/* Footer Actions */} + {/* + */}