From c4dd6b01478adb136be4a40868614c9cf6021997 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 10 Jun 2025 11:10:43 +0800 Subject: [PATCH] feat: useEmailList + refresh --- src/hooks/useEmail.js | 12 +++++++++--- src/views/orders/components/MailBox.jsx | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hooks/useEmail.js b/src/hooks/useEmail.js index 4f19fb3..5033622 100644 --- a/src/hooks/useEmail.js +++ b/src/hooks/useEmail.js @@ -114,7 +114,7 @@ export const useEmailDetail = (mai_sn, data) => { } export const EmailBuilder = ({subject, content}) => { - return `${subject}${content}`; + return `${content}`; } export const useEmailList = (mailboxDirNode) => { @@ -122,6 +122,12 @@ export const useEmailList = (mailboxDirNode) => { const [mailList, setMailList] = useState([]) const [error, setError] = useState(null) const [isFreshData, setIsFreshData] = useState(false) + const [refreshTrigger, setRefreshTrigger] = useState(0); + + const refresh = useCallback(() => { + setRefreshTrigger(prev => prev + 1); + }, []); + const { OPI_SN: opi_sn, COLI_SN, VKey, VParent, ApplyDate, OrderSourceType, IsTrue } = mailboxDirNode const getMailList = useCallback(async () => { @@ -161,11 +167,11 @@ export const useEmailList = (mailboxDirNode) => { } finally { setLoading(false) } - }, [VKey]) + }, [VKey, refreshTrigger]) useEffect(() => { getMailList() }, [getMailList]) - return { loading, isFreshData, error, mailList } + return { loading, isFreshData, error, mailList, refresh } } diff --git a/src/views/orders/components/MailBox.jsx b/src/views/orders/components/MailBox.jsx index 7df2c7f..0726341 100644 --- a/src/views/orders/components/MailBox.jsx +++ b/src/views/orders/components/MailBox.jsx @@ -40,7 +40,7 @@ const MailBox = ({ mailboxDir, onMailItemClick, ...props}) => { ] const [form] = Form.useForm() - const { mailList, isLoading, error } = useEmailList(mailboxDir); + const { mailList, loading, error, refresh } = useEmailList(mailboxDir); const [pagination, setPagination] = useState({ current: 1, @@ -175,7 +175,7 @@ const MailBox = ({ mailboxDir, onMailItemClick, ...props}) => {