diff --git a/src/components/step_one_tab/step_one_tab.tsx b/src/components/step_one_tab/step_one_tab.tsx index 2788cccd1..167f0c9a4 100644 --- a/src/components/step_one_tab/step_one_tab.tsx +++ b/src/components/step_one_tab/step_one_tab.tsx @@ -33,7 +33,8 @@ const StepOneTab = () => { const { t } = useTranslation('common'); const { cameraScannerVisibilityHandler, toastHandler } = useGlobalCtx(); const { selectedCompany } = useUserCtx(); - const { OCRList, OCRListStatus, updateOCRListHandler, selectOCRHandler } = useAccountingCtx(); + const { OCRList, OCRListStatus, updateOCRListHandler, selectOCRHandler, deleteOCRHandler } = + useAccountingCtx(); // Info: (20240809 - Shirley) disabled for now , 分頁功能在 alpha release 還沒實作 // eslint-disable-next-line @typescript-eslint/no-unused-vars const [currentFilePage, setCurrentFilePage] = useState(1); @@ -114,6 +115,7 @@ const StepOneTab = () => { closeable: true, }); } else if (success) { + deleteOCRHandler(aichResultId); toastHandler({ id: `deleteUnprocessedOCR-${code}`, /* Info: (20240805 - Anna) 將上傳憑證的吐司通知翻譯 */ diff --git a/src/contexts/accounting_context.tsx b/src/contexts/accounting_context.tsx index 47de93d3e..1a2b43fd0 100644 --- a/src/contexts/accounting_context.tsx +++ b/src/contexts/accounting_context.tsx @@ -56,6 +56,7 @@ interface IAccountingContext { OCRList: IOCR[]; OCRListStatus: { listSuccess: boolean | undefined; listCode: string | undefined }; updateOCRListHandler: (companyId: number | undefined, update: boolean) => void; + deleteOCRHandler: (aichId: string) => void; accountList: IAccount[]; getAccountListHandler: ( companyId: number, @@ -122,6 +123,7 @@ const initialAccountingContext: IAccountingContext = { OCRList: [], OCRListStatus: { listSuccess: undefined, listCode: undefined }, updateOCRListHandler: () => {}, + deleteOCRHandler: () => {}, accountList: [], getAccountListHandler: () => {}, getAIStatusHandler: () => {}, @@ -285,6 +287,13 @@ export const AccountingProvider = ({ children }: IAccountingProvider) => { } }; + const deleteOCRHandler = (aichId: string) => { + setOCRList((prev) => { + const rs = prev.filter((ocr) => ocr.aichResultId !== aichId); + return rs; + }); + }; + useEffect(() => { if (accountSuccess && accountTitleList) { setAccountList(accountTitleList.data); @@ -566,6 +575,7 @@ export const AccountingProvider = ({ children }: IAccountingProvider) => { OCRList, OCRListStatus, updateOCRListHandler, + deleteOCRHandler, accountList, getAccountListHandler, getAIStatusHandler,