From 9b5d1306d97b6eb49b68e75fe9a2df5d998932a3 Mon Sep 17 00:00:00 2001 From: "CANCERYS\\kw093" Date: Sat, 14 Mar 2026 18:54:40 +0800 Subject: [PATCH] stocktakeALL --- .../ApproverAllCardList.tsx | 197 +++++ .../StockTakeManagement/ApproverCardList.tsx | 2 +- .../ApproverStockTakeAll.tsx | 808 ++++++++++++++++++ .../StockTakeManagement/StockTakeTab.tsx | 90 +- src/i18n/zh/inventory.json | 1 + 5 files changed, 1077 insertions(+), 21 deletions(-) create mode 100644 src/components/StockTakeManagement/ApproverAllCardList.tsx create mode 100644 src/components/StockTakeManagement/ApproverStockTakeAll.tsx diff --git a/src/components/StockTakeManagement/ApproverAllCardList.tsx b/src/components/StockTakeManagement/ApproverAllCardList.tsx new file mode 100644 index 0000000..4af4874 --- /dev/null +++ b/src/components/StockTakeManagement/ApproverAllCardList.tsx @@ -0,0 +1,197 @@ +"use client"; + +import { + Box, + Card, + CardContent, + CardActions, + Typography, + CircularProgress, + Grid, + Chip, + Button, + TablePagination, +} from "@mui/material"; +import { useCallback, useEffect, useMemo, useState } from "react"; +import { useTranslation } from "react-i18next"; +import { + AllPickedStockTakeListReponse, + getApproverStockTakeRecords, +} from "@/app/api/stockTake/actions"; +import dayjs from "dayjs"; +import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; + +const PER_PAGE = 6; + +interface ApproverAllCardListProps { + onCardClick: (session: AllPickedStockTakeListReponse) => void; +} + +const ApproverAllCardList: React.FC = ({ + onCardClick, +}) => { + const { t } = useTranslation(["inventory", "common"]); + const [loading, setLoading] = useState(false); + const [sessions, setSessions] = useState([]); + const [page, setPage] = useState(0); + + const fetchSessions = useCallback(async () => { + setLoading(true); + try { + const data = await getApproverStockTakeRecords(); + const list = Array.isArray(data) ? data : []; + + // 找出最新一轮的 planStartDate + const withPlanStart = list.filter((s) => s.planStartDate); + if (withPlanStart.length === 0) { + setSessions([]); + setPage(0); + return; + } + + const latestPlanStart = withPlanStart + .map((s) => s.planStartDate as string) + .sort((a, b) => dayjs(b).valueOf() - dayjs(a).valueOf())[0]; + + // 这一轮下所有 section 的卡片 + const roundSessions = list.filter((s) => s.planStartDate === latestPlanStart); + + // 汇总这一轮的总 item / lot 数 + const totalItems = roundSessions.reduce( + (sum, s) => sum + (s.totalItemNumber || 0), + 0 + ); + const totalLots = roundSessions.reduce( + (sum, s) => sum + (s.totalInventoryLotNumber || 0), + 0 + ); + + // 用这一轮里的第一条作为代表,覆盖汇总数字 + const representative = roundSessions[0]; + const mergedRound: AllPickedStockTakeListReponse = { + ...representative, + totalItemNumber: totalItems, + totalInventoryLotNumber: totalLots, + }; + + // UI 上只展示这一轮一张卡 + setSessions([mergedRound]); + setPage(0); + } catch (e) { + console.error(e); + setSessions([]); + } finally { + setLoading(false); + } + }, []); + + useEffect(() => { + fetchSessions(); + }, [fetchSessions]); + + const getStatusColor = (status: string | null) => { + if (!status) return "default"; + const statusLower = status.toLowerCase(); + if (statusLower === "completed") return "success"; + if (statusLower === "approving") return "info"; + return "warning"; + }; + + const paged = useMemo(() => { + const startIdx = page * PER_PAGE; + return sessions.slice(startIdx, startIdx + PER_PAGE); + }, [page, sessions]); + + if (loading) { + return ( + + + + ); + } + + return ( + + + + + {paged.map((session) => { + const statusColor = getStatusColor(session.status); + const planStart = session.planStartDate + ? dayjs(session.planStartDate).format(OUTPUT_DATE_FORMAT) + : "-"; + + return ( + + onCardClick(session)} + > + + + {t("Stock Take Round")}: {planStart} + + + {t("Plan Start Date")}: {planStart} + + + {t("Total Items")}: {session.totalItemNumber} + + + {t("Total Lots")}: {session.totalInventoryLotNumber} + + + + + {session.status ? ( + + ) : ( + + )} + + + + ); + })} + + + {sessions.length > 0 && ( + setPage(p)} + rowsPerPageOptions={[PER_PAGE]} + /> + )} + + ); +}; + +export default ApproverAllCardList; + diff --git a/src/components/StockTakeManagement/ApproverCardList.tsx b/src/components/StockTakeManagement/ApproverCardList.tsx index 8c92cdf..44db58a 100644 --- a/src/components/StockTakeManagement/ApproverCardList.tsx +++ b/src/components/StockTakeManagement/ApproverCardList.tsx @@ -23,7 +23,7 @@ import { } from "@/app/api/stockTake/actions"; import dayjs from "dayjs"; import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; - +import { I18nProvider, getServerI18n } from "@/i18n"; const PER_PAGE = 6; interface ApproverCardListProps { diff --git a/src/components/StockTakeManagement/ApproverStockTakeAll.tsx b/src/components/StockTakeManagement/ApproverStockTakeAll.tsx new file mode 100644 index 0000000..d5c65fe --- /dev/null +++ b/src/components/StockTakeManagement/ApproverStockTakeAll.tsx @@ -0,0 +1,808 @@ +"use client"; + +import { + Box, + Button, + Stack, + Typography, + Chip, + CircularProgress, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Paper, + TextField, + Radio, + TablePagination, +} from "@mui/material"; +import { useState, useCallback, useEffect, useMemo } from "react"; +import { useTranslation } from "react-i18next"; +import { + AllPickedStockTakeListReponse, + InventoryLotDetailResponse, + SaveApproverStockTakeRecordRequest, + saveApproverStockTakeRecord, + getApproverInventoryLotDetailsAll, + BatchSaveApproverStockTakeAllRequest, + batchSaveApproverStockTakeRecordsAll, + updateStockTakeRecordStatusToNotMatch, +} from "@/app/api/stockTake/actions"; +import { useSession } from "next-auth/react"; +import { SessionWithTokens } from "@/config/authConfig"; +import dayjs from "dayjs"; +import { OUTPUT_DATE_FORMAT } from "@/app/utils/formatUtil"; + +interface ApproverStockTakeAllProps { + selectedSession: AllPickedStockTakeListReponse; + onBack: () => void; + onSnackbar: (message: string, severity: "success" | "error" | "warning") => void; +} + +type QtySelectionType = "first" | "second" | "approver"; + +const ApproverStockTakeAll: React.FC = ({ + selectedSession, + onBack, + onSnackbar, +}) => { + const { t } = useTranslation(["inventory", "common"]); + const { data: session } = useSession() as { data: SessionWithTokens | null }; + + const [inventoryLotDetails, setInventoryLotDetails] = useState([]); + const [loadingDetails, setLoadingDetails] = useState(false); + const [variancePercentTolerance, setVariancePercentTolerance] = useState("5"); + const [qtySelection, setQtySelection] = useState>({}); + const [approverQty, setApproverQty] = useState>({}); + const [approverBadQty, setApproverBadQty] = useState>({}); + const [saving, setSaving] = useState(false); + const [batchSaving, setBatchSaving] = useState(false); + const [updatingStatus, setUpdatingStatus] = useState(false); + const [page, setPage] = useState(0); + const [pageSize, setPageSize] = useState("all"); + const [total, setTotal] = useState(0); + + const currentUserId = session?.id ? parseInt(session.id) : undefined; + + const handleChangePage = useCallback((_: unknown, newPage: number) => { + setPage(newPage); + }, []); + + const handleChangeRowsPerPage = useCallback( + (event: React.ChangeEvent) => { + const newSize = parseInt(event.target.value, 10); + if (newSize === -1) { + setPageSize("all"); + } else if (!isNaN(newSize)) { + setPageSize(newSize); + } + setPage(0); + }, + [] + ); + + const loadDetails = useCallback( + async (pageNum: number, size: number | string) => { + setLoadingDetails(true); + try { + let actualSize: number; + if (size === "all") { + if (total > 0) { + actualSize = total; + } else if (selectedSession.totalInventoryLotNumber > 0) { + actualSize = selectedSession.totalInventoryLotNumber; + } else { + actualSize = 10000; + } + } else { + actualSize = typeof size === "string" ? parseInt(size, 10) : size; + } + + const response = await getApproverInventoryLotDetailsAll( + selectedSession.stockTakeId > 0 ? selectedSession.stockTakeId : null, + pageNum, + actualSize + ); + setInventoryLotDetails(Array.isArray(response.records) ? response.records : []); + setTotal(response.total || 0); + } catch (e) { + console.error(e); + setInventoryLotDetails([]); + setTotal(0); + } finally { + setLoadingDetails(false); + } + }, + [selectedSession, total] + ); + + useEffect(() => { + loadDetails(page, pageSize); + }, [page, pageSize, loadDetails]); + + useEffect(() => { + const newSelections: Record = {}; + inventoryLotDetails.forEach((detail) => { + if (!qtySelection[detail.id]) { + if (detail.secondStockTakeQty != null && detail.secondStockTakeQty > 0) { + newSelections[detail.id] = "second"; + } else { + newSelections[detail.id] = "first"; + } + } + }); + + if (Object.keys(newSelections).length > 0) { + setQtySelection((prev) => ({ ...prev, ...newSelections })); + } + }, [inventoryLotDetails, qtySelection]); + + const calculateDifference = useCallback( + (detail: InventoryLotDetailResponse, selection: QtySelectionType): number => { + let selectedQty = 0; + + if (selection === "first") { + selectedQty = detail.firstStockTakeQty || 0; + } else if (selection === "second") { + selectedQty = detail.secondStockTakeQty || 0; + } else if (selection === "approver") { + selectedQty = + (parseFloat(approverQty[detail.id] || "0") - + parseFloat(approverBadQty[detail.id] || "0")) || 0; + } + + const bookQty = detail.bookQty != null ? detail.bookQty : detail.availableQty || 0; + return selectedQty - bookQty; + }, + [approverQty, approverBadQty] + ); + + const filteredDetails = useMemo(() => { + const percent = parseFloat(variancePercentTolerance || "0"); + const thresholdPercent = isNaN(percent) || percent < 0 ? 0 : percent; + + return inventoryLotDetails.filter((detail) => { + if (detail.finalQty != null || detail.stockTakeRecordStatus === "completed") { + return true; + } + const selection = + qtySelection[detail.id] ?? + (detail.secondStockTakeQty != null && detail.secondStockTakeQty > 0 + ? "second" + : "first"); + const difference = calculateDifference(detail, selection); + const bookQty = + detail.bookQty != null ? detail.bookQty : (detail.availableQty || 0); + if (bookQty === 0) return difference !== 0; + const threshold = Math.abs(bookQty) * (thresholdPercent / 100); + return Math.abs(difference) > threshold; + }); + }, [ + inventoryLotDetails, + variancePercentTolerance, + qtySelection, + calculateDifference, + ]); + + const handleSaveApproverStockTake = useCallback( + async (detail: InventoryLotDetailResponse) => { + if (!selectedSession || !currentUserId) { + return; + } + + const selection = qtySelection[detail.id] || "first"; + let finalQty: number; + let finalBadQty: number; + + if (selection === "first") { + if (detail.firstStockTakeQty == null) { + onSnackbar(t("First QTY is not available"), "error"); + return; + } + finalQty = detail.firstStockTakeQty; + finalBadQty = detail.firstBadQty || 0; + } else if (selection === "second") { + if (detail.secondStockTakeQty == null) { + onSnackbar(t("Second QTY is not available"), "error"); + return; + } + + finalQty = detail.secondStockTakeQty; + finalBadQty = detail.secondBadQty || 0; + } else { + const approverQtyValue = approverQty[detail.id]; + const approverBadQtyValue = approverBadQty[detail.id]; + + if ( + approverQtyValue === undefined || + approverQtyValue === null || + approverQtyValue === "" + ) { + onSnackbar(t("Please enter Approver QTY"), "error"); + return; + } + if ( + approverBadQtyValue === undefined || + approverBadQtyValue === null || + approverBadQtyValue === "" + ) { + onSnackbar(t("Please enter Approver Bad QTY"), "error"); + return; + } + + finalQty = parseFloat(approverQtyValue) || 0; + finalBadQty = parseFloat(approverBadQtyValue) || 0; + } + + setSaving(true); + try { + const request: SaveApproverStockTakeRecordRequest = { + stockTakeRecordId: detail.stockTakeRecordId || null, + qty: finalQty, + badQty: finalBadQty, + approverId: currentUserId, + approverQty: selection === "approver" ? finalQty : null, + approverBadQty: selection === "approver" ? finalBadQty : null, + }; + + await saveApproverStockTakeRecord(request, selectedSession.stockTakeId); + + onSnackbar(t("Approver stock take record saved successfully"), "success"); + + const goodQty = finalQty - finalBadQty; + + setInventoryLotDetails((prev) => + prev.map((d) => + d.id === detail.id + ? { + ...d, + finalQty: goodQty, + approverQty: selection === "approver" ? finalQty : d.approverQty, + approverBadQty: selection === "approver" ? finalBadQty : d.approverBadQty, + stockTakeRecordStatus: "completed", + } + : d + ) + ); + } catch (e: any) { + console.error("Save approver stock take record error:", e); + let errorMessage = t("Failed to save approver stock take record"); + + if (e?.message) { + errorMessage = e.message; + } else if (e?.response) { + try { + const errorData = await e.response.json(); + errorMessage = errorData.message || errorData.error || errorMessage; + } catch { + } + } + + onSnackbar(errorMessage, "error"); + } finally { + setSaving(false); + } + }, + [selectedSession, currentUserId, qtySelection, approverQty, approverBadQty, t, onSnackbar] + ); + + const handleUpdateStatusToNotMatch = useCallback( + async (detail: InventoryLotDetailResponse) => { + if (!detail.stockTakeRecordId) { + onSnackbar(t("Stock take record ID is required"), "error"); + return; + } + + setUpdatingStatus(true); + try { + await updateStockTakeRecordStatusToNotMatch(detail.stockTakeRecordId); + + onSnackbar(t("Stock take record status updated to not match"), "success"); + setInventoryLotDetails((prev) => + prev.map((d) => + d.id === detail.id ? { ...d, stockTakeRecordStatus: "notMatch" } : d + ) + ); + } catch (e: any) { + console.error("Update stock take record status error:", e); + let errorMessage = t("Failed to update stock take record status"); + + if (e?.message) { + errorMessage = e.message; + } else if (e?.response) { + try { + const errorData = await e.response.json(); + errorMessage = errorData.message || errorData.error || errorMessage; + } catch { + } + } + + onSnackbar(errorMessage, "error"); + } finally { + setUpdatingStatus(false); + } + }, + [t, onSnackbar] + ); + + const handleBatchSubmitAll = useCallback(async () => { + if (!selectedSession || !currentUserId) { + return; + } + + setBatchSaving(true); + try { + const request: BatchSaveApproverStockTakeAllRequest = { + stockTakeId: selectedSession.stockTakeId, + approverId: currentUserId, + variancePercentTolerance: parseFloat(variancePercentTolerance || "0") || undefined, + }; + + const result = await batchSaveApproverStockTakeRecordsAll(request); + + onSnackbar( + t("Batch approver save completed: {{success}} success, {{errors}} errors", { + success: result.successCount, + errors: result.errorCount, + }), + result.errorCount > 0 ? "warning" : "success" + ); + + await loadDetails(page, pageSize); + } catch (e: any) { + console.error("handleBatchSubmitAll (all): Error:", e); + let errorMessage = t("Failed to batch save approver stock take records"); + + if (e?.message) { + errorMessage = e.message; + } else if (e?.response) { + try { + const errorData = await e.response.json(); + errorMessage = errorData.message || errorData.error || errorMessage; + } catch { + } + } + + onSnackbar(errorMessage, "error"); + } finally { + setBatchSaving(false); + } + }, [selectedSession, currentUserId, variancePercentTolerance, t, onSnackbar, loadDetails, page, pageSize]); + + const formatNumber = (num: number | null | undefined): string => { + if (num == null) return "0"; + return num.toLocaleString("en-US", { + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }); + }; + + const uniqueWarehouses = useMemo( + () => + Array.from( + new Set( + inventoryLotDetails + .map((detail) => detail.warehouse) + .filter((warehouse) => warehouse && warehouse.trim() !== "") + ) + ).join(", "), + [inventoryLotDetails] + ); + + return ( + + + + + + {uniqueWarehouses && ( + <> {t("Warehouse")}: {uniqueWarehouses} + )} + + + + setVariancePercentTolerance(e.target.value)} + label={t("Variance %")} + sx={{ width: 100 }} + inputProps={{ min: 0, max: 100, step: 0.1 }} + /> + + + + {loadingDetails ? ( + + + + ) : ( + <> + + + + + + {t("Warehouse Location")} + {t("Item-lotNo-ExpiryDate")} + {t("UOM")} + + {t("Stock Take Qty(include Bad Qty)= Available Qty")} + + {t("Remark")} + {t("Record Status")} + {t("Action")} + + + + {filteredDetails.length === 0 ? ( + + + + {t("No data")} + + + + ) : ( + filteredDetails.map((detail) => { + const hasFirst = + detail.firstStockTakeQty != null && detail.firstStockTakeQty >= 0; + const hasSecond = + detail.secondStockTakeQty != null && detail.secondStockTakeQty >= 0; + const selection = + qtySelection[detail.id] || (hasSecond ? "second" : "first"); + + return ( + + + {detail.warehouseArea || "-"} + {detail.warehouseSlot || "-"} + + + + + {detail.itemCode || "-"} {detail.itemName || "-"} + + {detail.lotNo || "-"} + + {detail.expiryDate + ? dayjs(detail.expiryDate).format(OUTPUT_DATE_FORMAT) + : "-"} + + + + {detail.uom || "-"} + + {detail.finalQty != null ? ( + + {(() => { + const bookQtyToUse = + detail.bookQty != null + ? detail.bookQty + : detail.availableQty || 0; + const finalDifference = + (detail.finalQty || 0) - bookQtyToUse; + const differenceColor = + detail.stockTakeRecordStatus === "completed" + ? "text.secondary" + : finalDifference !== 0 + ? "error.main" + : "success.main"; + + return ( + + {t("Difference")}: {formatNumber(detail.finalQty)} -{" "} + {formatNumber(bookQtyToUse)} ={" "} + {formatNumber(finalDifference)} + + ); + })()} + + ) : ( + + {hasFirst && ( + + + setQtySelection({ + ...qtySelection, + [detail.id]: "first", + }) + } + /> + + {t("First")}:{" "} + {formatNumber( + (detail.firstStockTakeQty ?? 0) + + (detail.firstBadQty ?? 0) + )}{" "} + ({detail.firstBadQty ?? 0}) ={" "} + {formatNumber(detail.firstStockTakeQty ?? 0)} + + + )} + + {hasSecond && ( + + + setQtySelection({ + ...qtySelection, + [detail.id]: "second", + }) + } + /> + + {t("Second")}:{" "} + {formatNumber( + (detail.secondStockTakeQty ?? 0) + + (detail.secondBadQty ?? 0) + )}{" "} + ({detail.secondBadQty ?? 0}) ={" "} + {formatNumber(detail.secondStockTakeQty ?? 0)} + + + )} + + {hasSecond && ( + + + setQtySelection({ + ...qtySelection, + [detail.id]: "approver", + }) + } + /> + + {t("Approver Input")}: + + + setApproverQty({ + ...approverQty, + [detail.id]: e.target.value, + }) + } + sx={{ + width: 130, + minWidth: 130, + "& .MuiInputBase-input": { + height: "1.4375em", + padding: "4px 8px", + }, + }} + placeholder={t("Stock Take Qty")} + disabled={selection !== "approver"} + /> + + + setApproverBadQty({ + ...approverBadQty, + [detail.id]: e.target.value, + }) + } + sx={{ + width: 130, + minWidth: 130, + "& .MuiInputBase-input": { + height: "1.4375em", + padding: "4px 8px", + }, + }} + placeholder={t("Bad Qty")} + disabled={selection !== "approver"} + /> + + ={" "} + {formatNumber( + parseFloat(approverQty[detail.id] || "0") - + parseFloat( + approverBadQty[detail.id] || "0" + ) + )} + + + )} + + {(() => { + let selectedQty = 0; + + if (selection === "first") { + selectedQty = detail.firstStockTakeQty || 0; + } else if (selection === "second") { + selectedQty = detail.secondStockTakeQty || 0; + } else if (selection === "approver") { + selectedQty = + (parseFloat(approverQty[detail.id] || "0") - + parseFloat( + approverBadQty[detail.id] || "0" + )) || 0; + } + + const bookQty = + detail.bookQty != null + ? detail.bookQty + : detail.availableQty || 0; + const difference = selectedQty - bookQty; + const differenceColor = + detail.stockTakeRecordStatus === "completed" + ? "text.secondary" + : difference !== 0 + ? "error.main" + : "success.main"; + + return ( + + {t("Difference")}:{" "} + {t("selected stock take qty")}( + {formatNumber(selectedQty)}) -{" "} + {t("book qty")}( + {formatNumber(bookQty)}) ={" "} + {formatNumber(difference)} + + ); + })()} + + )} + + + + + {detail.remarks || "-"} + + + + + {detail.stockTakeRecordStatus === "completed" ? ( + + ) : detail.stockTakeRecordStatus === "pass" ? ( + + ) : detail.stockTakeRecordStatus === "notMatch" ? ( + + ) : ( + + )} + + + {detail.stockTakeRecordId && + detail.stockTakeRecordStatus !== "notMatch" && ( + + + + )} +
+ {detail.finalQty == null && ( + + + + )} +
+
+ ); + }) + )} +
+
+
+ + + )} +
+ ); +}; + +export default ApproverStockTakeAll; + diff --git a/src/components/StockTakeManagement/StockTakeTab.tsx b/src/components/StockTakeManagement/StockTakeTab.tsx index d61aa23..3155ce8 100644 --- a/src/components/StockTakeManagement/StockTakeTab.tsx +++ b/src/components/StockTakeManagement/StockTakeTab.tsx @@ -9,12 +9,17 @@ import ApproverCardList from "./ApproverCardList"; import PickerStockTake from "./PickerStockTake"; import PickerReStockTake from "./PickerReStockTake"; import ApproverStockTake from "./ApproverStockTake"; +import ApproverAllCardList from "./ApproverAllCardList"; +import ApproverStockTakeAll from "./ApproverStockTakeAll"; + +type ViewScope = "picker" | "approver-by-section" | "approver-all"; const StockTakeTab: React.FC = () => { const { t } = useTranslation(["inventory", "common"]); const [tabValue, setTabValue] = useState(0); const [selectedSession, setSelectedSession] = useState(null); const [viewMode, setViewMode] = useState<"details" | "reStockTake">("details"); + const [viewScope, setViewScope] = useState("picker"); const [snackbar, setSnackbar] = useState<{ open: boolean; message: string; @@ -30,9 +35,16 @@ const StockTakeTab: React.FC = () => { setViewMode("details"); }, []); + const handleApproverAllCardClick = useCallback((session: AllPickedStockTakeListReponse) => { + setSelectedSession(session); + setViewMode("details"); + setViewScope("approver-all"); + }, []); + const handleReStockTakeClick = useCallback((session: AllPickedStockTakeListReponse) => { setSelectedSession(session); setViewMode("reStockTake"); + setViewScope("picker"); }, []); const handleBackToList = useCallback(() => { @@ -51,27 +63,37 @@ const StockTakeTab: React.FC = () => { if (selectedSession) { return ( - {tabValue === 0 ? ( - viewMode === "reStockTake" ? ( - - ) : ( - - ) - ) : ( + {viewScope === "picker" && ( + tabValue === 0 ? ( + viewMode === "reStockTake" ? ( + + ) : ( + + ) + ) : null + )} + {viewScope === "approver-by-section" && tabValue === 1 && ( )} + {viewScope === "approver-all" && tabValue === 2 && ( + + )} { return ( - setTabValue(newValue)} sx={{ mb: 2 }}> + { + setTabValue(newValue); + if (newValue === 0) { + setViewScope("picker"); + } else if (newValue === 1) { + setViewScope("approver-by-section"); + } else { + setViewScope("approver-all"); + } + }} + sx={{ mb: 2 }} + > + - {tabValue === 0 ? ( + {tabValue === 0 && ( { + setViewScope("picker"); + handleCardClick(session); + }} onReStockTakeClick={handleReStockTakeClick} /> - ) : ( - + )} + {tabValue === 1 && ( + { + setViewScope("approver-by-section"); + handleCardClick(session); + }} + /> + )} + {tabValue === 2 && ( + )}