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