| @@ -26,6 +26,7 @@ type Props = { | |||
| workbenchRelease?: boolean; | |||
| } | |||
| /** FP-MTMS Version Checklist | Functions Ref. No. 78 | v1.0.0 | 2026-09-08 */ | |||
| const DoDetail: React.FC<Props> = ({ | |||
| defaultValues, | |||
| id, | |||
| @@ -57,22 +58,13 @@ const DoDetail: React.FC<Props> = ({ | |||
| setSuccessMessage("") | |||
| if (id) { | |||
| // Get current user ID from session | |||
| //const currentUserId = session?.id ? parseInt(session.id) : undefined; | |||
| //if (!currentUserId) { | |||
| // setServerError("User session not found. Please login again."); | |||
| // return; | |||
| //} | |||
| /* | |||
| const response = await releaseDo({ | |||
| id: id, | |||
| //userId: currentUserId // Pass user ID from session | |||
| }) | |||
| */ | |||
| if (!currentUserId) { | |||
| setServerError(t("User session not found")); | |||
| return; | |||
| } | |||
| const response = await startWorkbenchBatchReleaseAsyncSingleV2({ | |||
| doId: id, | |||
| userId: currentUserId ?? 0 | |||
| userId: currentUserId | |||
| }) | |||
| if (response?.code === "STARTED") { | |||
| setSuccessMessage(t("DO released successfully! Pick orders created.")); | |||
| @@ -91,7 +83,7 @@ const DoDetail: React.FC<Props> = ({ | |||
| } finally { | |||
| setIsUploading(false) | |||
| } | |||
| }, [id, formProps, t, setIsUploading, session]) // Add session to dependencies | |||
| }, [id, formProps, t, setIsUploading, session, currentUserId, router]) | |||
| // UPDATE STORE-BASED ASSIGNMENT HANDLERS | |||
| const handleAssignByStore = useCallback(async (storeId: string) => { | |||
| @@ -81,6 +81,7 @@ function isTruckLaneSearchMissingEta(truckLanceCode: string, estimatedArrivalDat | |||
| return truckLanceCode.trim() !== "" && estimatedArrivalDate.trim() === ""; | |||
| } | |||
| /** FP-MTMS Version Checklist | Functions Ref. No. 77 | v1.0.0 | 2026-09-08 */ | |||
| const DoSearch: React.FC<Props> = ({ filterArgs, searchQuery, onDeliveryOrderSearch }) => { | |||
| const apiRef = useGridApiRef(); | |||
| @@ -509,6 +510,16 @@ const DoSearch: React.FC<Props> = ({ filterArgs, searchQuery, onDeliveryOrderSea | |||
| const handleBatchRelease = useCallback(async (isWorkbench: boolean) => { | |||
| try { | |||
| if (!currentUserId) { | |||
| await Swal.fire({ | |||
| icon: "error", | |||
| title: t("Error"), | |||
| text: t("User session not found"), | |||
| confirmButtonText: t("OK"), | |||
| didOpen: (popup) => applyMainContentAreaSwalOffset(popup), | |||
| }); | |||
| return; | |||
| } | |||
| const tabFilter = resolveTabFilter(activeTab); | |||
| const tabTruckKeyword = tabFilter.forceTruckKeyword ?? ""; | |||
| const effectiveTruckLanceCode = tabTruckKeyword || currentSearchParams.truckLanceCode || ""; | |||
| @@ -659,12 +670,12 @@ const DoSearch: React.FC<Props> = ({ filterArgs, searchQuery, onDeliveryOrderSea | |||
| if(isWorkbench){ | |||
| startRes = await startWorkbenchBatchReleaseAsyncV2({ | |||
| ids: idsToRelease, | |||
| userId: currentUserId ?? 1, | |||
| userId: currentUserId, | |||
| mergeExtraIntoLaneTicket, | |||
| }); | |||
| } | |||
| else{ | |||
| startRes = await startBatchReleaseAsync({ ids: idsToRelease, userId: currentUserId ?? 1 }); | |||
| startRes = await startBatchReleaseAsync({ ids: idsToRelease, userId: currentUserId }); | |||
| } | |||
| //await startBatchReleaseAsync({ ids: idsToRelease, userId: currentUserId ?? 1 }); | |||
| const jobId = startRes?.entity?.jobId; | |||
| @@ -61,6 +61,7 @@ function isTruckLaneSearchMissingEta(truckLanceCode: string, estimatedArrivalDat | |||
| return truckLanceCode.trim() !== "" && estimatedArrivalDate.trim() === ""; | |||
| } | |||
| /** FP-MTMS Version Checklist | Functions Ref. No. 78 | v1.0.0 | 2026-09-08 */ | |||
| const DoSearchWorkbench: React.FC<Props> = ({ | |||
| filterArgs, | |||
| searchQuery, | |||
| @@ -538,6 +539,15 @@ const handleSearch = useCallback(async (query: SearchBoxInputs) => { | |||
| const handleBatchRelease = useCallback(async () => { | |||
| try { | |||
| if (!currentUserId) { | |||
| await Swal.fire({ | |||
| icon: "error", | |||
| title: t("Error"), | |||
| text: t("User session not found"), | |||
| confirmButtonText: t("OK"), | |||
| }); | |||
| return; | |||
| } | |||
| if ( | |||
| isTruckLaneSearchMissingEta( | |||
| currentSearchParams.truckLanceCode ?? "", | |||
| @@ -657,7 +667,7 @@ const handleSearch = useCallback(async (query: SearchBoxInputs) => { | |||
| (result.value as { mergeExtraIntoLaneTicket?: boolean } | undefined)?.mergeExtraIntoLaneTicket ?? false; | |||
| const startRes = await startWorkbenchBatchReleaseAsyncV2({ | |||
| ids: idsToRelease, | |||
| userId: currentUserId ?? 1, | |||
| userId: currentUserId, | |||
| mergeExtraIntoLaneTicket, | |||
| }); | |||
| const startEntity = startRes?.entity as { jobId?: string } | undefined; | |||
| @@ -166,6 +166,9 @@ | |||
| "Truck X": "Truck X", | |||
| "Truck lane search requires date message": "Truck lane search requires date message", | |||
| "Truck lane search requires date title": "Truck lane search requires date title", | |||
| "User session not found": "User session not found. Please login again.", | |||
| "Error": "Error", | |||
| "OK": "OK", | |||
| "Warning: Some delivery orders do not have matching trucks for the target date.": "Warning: Some delivery orders do not have matching trucks for the target date.", | |||
| "Workbench Batch Release": "Workbench Batch Release", | |||
| "code": "code", | |||
| @@ -221,5 +221,6 @@ | |||
| "Replenishment demo note": "此為前端假資料回應;正式環境將呼叫後端 API。", | |||
| "Search Delivery Order": "搜尋送貨單", | |||
| "DO Replenishment": "送貨單補貨", | |||
| "Error": "錯誤" | |||
| "Error": "錯誤", | |||
| "User session not found": "找不到登入使用者,請重新登入。" | |||
| } | |||