From 0389d6091ad5a08abb6fa9a1a317245de8d9f42b Mon Sep 17 00:00:00 2001 From: weeihan Date: Thu, 23 Jul 2026 22:32:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20phase=207=20follow-up=20?= =?UTF-8?q?=E2=80=94=20fix=20remaining=20/ims/=20occurrences=20in=20sw.js,?= =?UTF-8?q?=20notifications,=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- components/admin/site-zone-manager.tsx | 4 ++-- components/admin/truck-manager.tsx | 4 ++-- components/admin/user-manager.tsx | 4 ++-- components/capa/capa-form.tsx | 4 ++-- components/dashboard/risk-flags-panel.tsx | 2 +- components/incidents/offline-sync.tsx | 2 +- components/incidents/report-form.tsx | 4 ++-- components/notifications/bell.tsx | 4 ++-- components/settings/api-key-form.tsx | 2 +- lib/notifications/capa-escalation.ts | 2 +- lib/notifications/effectiveness-recheck.ts | 2 +- public/sw.js | 8 ++++---- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/components/admin/site-zone-manager.tsx b/components/admin/site-zone-manager.tsx index 06e9101..b484f98 100644 --- a/components/admin/site-zone-manager.tsx +++ b/components/admin/site-zone-manager.tsx @@ -27,7 +27,7 @@ export function SiteZoneManager({ sites }: Props) { const post = async (payload: Record) => { setBusy(true) setError(null) - const res = await fetch('/ims/api/admin/sites', { + const res = await fetch('/api/admin/sites', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), @@ -46,7 +46,7 @@ export function SiteZoneManager({ sites }: Props) { const id = payload.id as string setBusyId(id) setError(null) - const res = await fetch('/ims/api/admin/sites', { + const res = await fetch('/api/admin/sites', { method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), diff --git a/components/admin/truck-manager.tsx b/components/admin/truck-manager.tsx index c821ea2..6f056e2 100644 --- a/components/admin/truck-manager.tsx +++ b/components/admin/truck-manager.tsx @@ -28,7 +28,7 @@ export function TruckManager({ trucks }: Props) { setSubmitting(true) setError(null) try { - const res = await fetch('/ims/api/admin/trucks', { + const res = await fetch('/api/admin/trucks', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ truck_no: no, carrier: carrier.trim() || null }), @@ -53,7 +53,7 @@ export function TruckManager({ trucks }: Props) { setBusyId(id) setError(null) try { - const res = await fetch('/ims/api/admin/trucks', { + const res = await fetch('/api/admin/trucks', { method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), diff --git a/components/admin/user-manager.tsx b/components/admin/user-manager.tsx index d5242ce..84388c7 100644 --- a/components/admin/user-manager.tsx +++ b/components/admin/user-manager.tsx @@ -34,7 +34,7 @@ export function UserManager({ users, sites }: Props) { const patchUser = async (id: string, update: Record) => { setBusyId(id) setError(null) - const res = await fetch('/ims/api/admin/users', { + const res = await fetch('/api/admin/users', { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, ...update }), @@ -66,7 +66,7 @@ export function UserManager({ users, sites }: Props) { e.preventDefault() setSubmitting(true) setError(null) - const res = await fetch('/ims/api/admin/users', { + const res = await fetch('/api/admin/users', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ diff --git a/components/capa/capa-form.tsx b/components/capa/capa-form.tsx index c1426bc..5cf5274 100644 --- a/components/capa/capa-form.tsx +++ b/components/capa/capa-form.tsx @@ -26,7 +26,7 @@ export function CapaForm({ incidentId }: Props) { const [error, setError] = useState(null) useEffect(() => { - fetch('/ims/api/users') + fetch('/api/users') .then(r => r.json()) .then(data => { if (Array.isArray(data)) setUsers(data) }) .catch(() => {}) @@ -46,7 +46,7 @@ export function CapaForm({ incidentId }: Props) { } setSaving(true) setError(null) - const res = await fetch('/ims/api/capa', { + const res = await fetch('/api/capa', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ diff --git a/components/dashboard/risk-flags-panel.tsx b/components/dashboard/risk-flags-panel.tsx index 810569e..e4ec922 100644 --- a/components/dashboard/risk-flags-panel.tsx +++ b/components/dashboard/risk-flags-panel.tsx @@ -26,7 +26,7 @@ export function RiskFlagsPanel() { setLoading(true) setError(null) try { - const res = await fetch('/ims/api/dashboard/ai/risk-flags', { method: 'POST' }) + const res = await fetch('/api/dashboard/ai/risk-flags', { method: 'POST' }) if (!res.ok) { const data = await res.json().catch(() => ({})) setError(data.error ?? 'Analysis failed') diff --git a/components/incidents/offline-sync.tsx b/components/incidents/offline-sync.tsx index a587130..e76fd11 100644 --- a/components/incidents/offline-sync.tsx +++ b/components/incidents/offline-sync.tsx @@ -30,7 +30,7 @@ export function OfflineSync() { if (report.type_details) fd.append('type_details', JSON.stringify(report.type_details)) try { - const res = await fetch('/ims/api/incidents', { method: 'POST', body: fd }) + const res = await fetch('/api/incidents', { method: 'POST', body: fd }) if (res.ok && report.id != null) { await removePendingReport(report.id) } diff --git a/components/incidents/report-form.tsx b/components/incidents/report-form.tsx index b20e7f5..13df700 100644 --- a/components/incidents/report-form.tsx +++ b/components/incidents/report-form.tsx @@ -134,7 +134,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) { if (!overrideQuality) { try { - const qcRes = await fetch('/ims/api/incidents/ai/quality-check', { + const qcRes = await fetch('/api/incidents/ai/quality-check', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ @@ -176,7 +176,7 @@ export function ReportForm({ zoneToken, trucks, initialTruckId }: Props) { if (form.truck_id) fd.append('truck_id', form.truck_id) files.forEach(f => fd.append('files', f)) - const res = await fetch('/ims/api/incidents', { method: 'POST', body: fd }) + const res = await fetch('/api/incidents', { method: 'POST', body: fd }) // Parse JSON separately so a non-JSON response (HTML error page) surfaces the status code let data: Record = {} diff --git a/components/notifications/bell.tsx b/components/notifications/bell.tsx index f6d2cdf..5e15ca6 100644 --- a/components/notifications/bell.tsx +++ b/components/notifications/bell.tsx @@ -20,7 +20,7 @@ export function NotificationBell() { const panelRef = useRef(null) const load = useCallback(() => { - fetch('/ims/api/notifications') + fetch('/api/notifications') .then(r => (r.ok ? r.json() : Promise.reject())) .then((data: { notifications: Notification[]; unread: number }) => { setNotifications(data.notifications) @@ -45,7 +45,7 @@ export function NotificationBell() { }, [open]) const markAllRead = () => { - fetch('/ims/api/notifications', { + fetch('/api/notifications', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ all: true }), diff --git a/components/settings/api-key-form.tsx b/components/settings/api-key-form.tsx index 7b51684..4b3f0ee 100644 --- a/components/settings/api-key-form.tsx +++ b/components/settings/api-key-form.tsx @@ -25,7 +25,7 @@ export function ApiKeyForm({ settings }: Props) { setSaving(s => ({ ...s, [key]: true })) setResults(r => ({ ...r, [key]: undefined as never })) try { - const res = await fetch('/ims/api/settings', { + const res = await fetch('/api/settings', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ key, value: values[key] }), diff --git a/lib/notifications/capa-escalation.ts b/lib/notifications/capa-escalation.ts index 3c38b20..9cd555b 100644 --- a/lib/notifications/capa-escalation.ts +++ b/lib/notifications/capa-escalation.ts @@ -79,7 +79,7 @@ export async function escalateOverdueCapa(): Promise<{ notified: number }> { if (!ownerEmail) continue const incidentRef = capa.incidentRef ?? capa.incidentId - const capaUrl = `${siteUrl}/ims/hse/capa/${capa.id}` + const capaUrl = `${siteUrl}/hse/capa/${capa.id}` const subject = THRESHOLD_SUBJECT[threshold] const html = `

Hi ${ownerName},

diff --git a/lib/notifications/effectiveness-recheck.ts b/lib/notifications/effectiveness-recheck.ts index b40b9d5..6cb714e 100644 --- a/lib/notifications/effectiveness-recheck.ts +++ b/lib/notifications/effectiveness-recheck.ts @@ -85,7 +85,7 @@ export async function sendEffectivenessRecheckNotifications(): Promise<{ notifie const incidentRef = capa.incidentRef ?? capa.incidentId const roundLabel = getRoundLabel(round) const capaDesc = capa.description - const capaUrl = `${siteUrl}/ims/hse/capa/${capa.id}` + const capaUrl = `${siteUrl}/hse/capa/${capa.id}` const subject = `[IMS] ${roundLabel} effectiveness check — ${incidentRef}` const html = ` diff --git a/public/sw.js b/public/sw.js index 4f3af3f..c813a37 100644 --- a/public/sw.js +++ b/public/sw.js @@ -16,20 +16,20 @@ self.addEventListener('activate', event => { self.addEventListener('fetch', event => { const url = new URL(event.request.url) - // Only handle same-origin GET requests under /ims/ + // Only handle same-origin GET requests if ( event.request.method !== 'GET' || url.origin !== self.location.origin || - !url.pathname.startsWith('/ims/') + !url.pathname.startsWith('/') ) { return } // Skip API routes — always go to network - if (url.pathname.startsWith('/ims/api/')) return + if (url.pathname.startsWith('/api/')) return // Cache-first for immutable Next.js static assets - if (url.pathname.startsWith('/ims/_next/static/')) { + if (url.pathname.startsWith('/_next/static/')) { event.respondWith( caches.match(event.request).then(cached => { if (cached) return cached