From 611c4eecc16a081c27f929d9a6d8d77e42af9867 Mon Sep 17 00:00:00 2001 From: "vluk@2fi-solutions.com.hk" Date: Thu, 21 May 2026 23:37:13 +0800 Subject: [PATCH] no message --- src/app/(main)/testing/page.tsx | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/app/(main)/testing/page.tsx b/src/app/(main)/testing/page.tsx index 2af8f13..21214ff 100644 --- a/src/app/(main)/testing/page.tsx +++ b/src/app/(main)/testing/page.tsx @@ -95,12 +95,17 @@ export default function TestingPage() { const [laserLastReceive, setLaserLastReceive] = useState(null); const bomShopSyncInFlightRef = useRef(false); + const bomShopSyncAllInFlightRef = useRef(false); const [bomShopSyncBomId, setBomShopSyncBomId] = useState("78"); const [bomShopM18HeaderId, setBomShopM18HeaderId] = useState(""); const [bomShopSyncLoading, setBomShopSyncLoading] = useState(false); const [bomShopSyncResult, setBomShopSyncResult] = useState( null, ); + const [bomShopSyncAllLoading, setBomShopSyncAllLoading] = useState(false); + const [bomShopSyncAllResult, setBomShopSyncAllResult] = useState< + string | null + >(null); const bomByItemCodeInFlightRef = useRef(false); const [bomByItemCodeInput, setBomByItemCodeInput] = useState(""); const [bomByItemCodeLoading, setBomByItemCodeLoading] = useState(false); @@ -315,6 +320,39 @@ export default function TestingPage() { } }; + const handleBomShopSyncAllM18 = async () => { + if (bomShopSyncAllInFlightRef.current) return; + bomShopSyncAllInFlightRef.current = true; + setBomShopSyncAllLoading(true); + setBomShopSyncAllResult(null); + try { + const response = await clientAuthFetch( + `${NEXT_PUBLIC_API_URL}/scheduler/trigger/bom-shop-sync-all`, + { method: "GET" }, + ); + if (response.status === 401 || response.status === 403) return; + const text = await response.text(); + let display = text; + try { + const parsed: unknown = JSON.parse(text); + display = JSON.stringify(parsed, null, 2); + } catch { + /* plain string from backend is fine */ + } + if (!response.ok) { + setBomShopSyncAllResult(`HTTP ${response.status}\n\n${display}`); + return; + } + setBomShopSyncAllResult(display); + } catch (e) { + const msg = e instanceof Error ? e.message : String(e); + setBomShopSyncAllResult(`Error: ${msg}`); + } finally { + setBomShopSyncAllLoading(false); + bomShopSyncAllInFlightRef.current = false; + } + }; + const handleBomLookupByItemCode = async () => { if (bomByItemCodeInFlightRef.current) return; const code = bomByItemCodeInput.trim(); @@ -768,6 +806,39 @@ export default function TestingPage() { M18 udfBomForShop sync + + GET /scheduler/trigger/bom-shop-sync-all: push{" "} + all non-deleted BOMs (same nightly job path; + respects M18.bom.shop.sync.enabled). Check{" "} + scheduler_sync_log (M18_BOM_SHOP) for row + counts. + + + + + {bomShopSyncAllResult ? ( + + ) : null} POST /m18/test/bom-shop-sync/:bomId with optional{" "} ?m18HeaderId= (M18 udfBomForShop header id for{" "}