Explorar el Código

no message

MergeProblem1
[email protected] hace 1 día
padre
commit
bdf7d52cd9
Se han modificado 1 ficheros con 16 adiciones y 2 borrados
  1. +16
    -2
      src/app/(main)/ps/page.tsx

+ 16
- 2
src/app/(main)/ps/page.tsx Ver fichero

@@ -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 */}
<DialogActions sx={{ p: 2, bgcolor: '#f9f9f9' }}>
<Stack direction="row" spacing={2}>
{/*
<Tooltip title={!isDateToday ? "Job Orders can only be generated for the current day's schedule." : ""}>
*/}
<span>
<Button
variant="contained"
@@ -388,7 +400,9 @@ export default function ProductionSchedulePage() {
自動生成工單
</Button>
</span>
{/*
</Tooltip>
*/}
<Button
onClick={() => setIsDetailOpen(false)}
variant="outlined"


Cargando…
Cancelar
Guardar