|
|
|
@@ -13,6 +13,11 @@ import { |
|
|
|
TablePagination, |
|
|
|
Grid, |
|
|
|
LinearProgress, |
|
|
|
Dialog, |
|
|
|
DialogTitle, |
|
|
|
DialogContent, |
|
|
|
DialogContentText, |
|
|
|
DialogActions, |
|
|
|
} from "@mui/material"; |
|
|
|
import { useState, useCallback, useEffect } from "react"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
@@ -41,7 +46,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ onCardClick, onReStockT |
|
|
|
const [stockTakeSessions, setStockTakeSessions] = useState<AllPickedStockTakeListReponse[]>([]); |
|
|
|
const [page, setPage] = useState(0); |
|
|
|
const [creating, setCreating] = useState(false); |
|
|
|
|
|
|
|
const [openConfirmDialog, setOpenConfirmDialog] = useState(false); |
|
|
|
const fetchStockTakeSessions = useCallback(async () => { |
|
|
|
setLoading(true); |
|
|
|
try { |
|
|
|
@@ -64,6 +69,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ onCardClick, onReStockT |
|
|
|
const paged = stockTakeSessions.slice(startIdx, startIdx + PER_PAGE); |
|
|
|
|
|
|
|
const handleCreateStockTake = useCallback(async () => { |
|
|
|
setOpenConfirmDialog(false); |
|
|
|
setCreating(true); |
|
|
|
try { |
|
|
|
const result = await createStockTakeForSections(); |
|
|
|
@@ -177,7 +183,7 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ onCardClick, onReStockT |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
color="primary" |
|
|
|
onClick={handleCreateStockTake} |
|
|
|
onClick={() => setOpenConfirmDialog(true)} |
|
|
|
disabled={creating} |
|
|
|
> |
|
|
|
{creating ? <CircularProgress size={20} /> : t("Create Stock Take for All Sections")} |
|
|
|
@@ -263,6 +269,33 @@ const PickerCardList: React.FC<PickerCardListProps> = ({ onCardClick, onReStockT |
|
|
|
rowsPerPageOptions={[PER_PAGE]} |
|
|
|
/> |
|
|
|
)} |
|
|
|
{/* Create Stock Take 確認 Dialog */} |
|
|
|
<Dialog |
|
|
|
open={openConfirmDialog} |
|
|
|
onClose={() => setOpenConfirmDialog(false)} |
|
|
|
maxWidth="xs" |
|
|
|
fullWidth |
|
|
|
> |
|
|
|
<DialogTitle>{t("Create Stock Take for All Sections")}</DialogTitle> |
|
|
|
<DialogContent> |
|
|
|
<DialogContentText> |
|
|
|
{t("Confirm create stock take for all sections?")} |
|
|
|
</DialogContentText> |
|
|
|
</DialogContent> |
|
|
|
<DialogActions> |
|
|
|
<Button onClick={() => setOpenConfirmDialog(false)}> |
|
|
|
{t("Cancel")} |
|
|
|
</Button> |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
color="primary" |
|
|
|
onClick={handleCreateStockTake} |
|
|
|
disabled={creating} |
|
|
|
> |
|
|
|
{creating ? <CircularProgress size={20} /> : t("Confirm")} |
|
|
|
</Button> |
|
|
|
</DialogActions> |
|
|
|
</Dialog> |
|
|
|
</Box> |
|
|
|
); |
|
|
|
}; |
|
|
|
|