From 63bbcff4967c63462a437d5303356d106c89ef65 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Mon, 27 Oct 2025 14:07:23 +0800 Subject: [PATCH] test email sender --- .../components/delivery-method/index.tsx | 3 ++ .../delivery-method/method-item.tsx | 4 +++ .../delivery-method/test-email-sender.tsx | 29 ++++++++++++++++--- .../workflow/nodes/human-input/panel.tsx | 1 + web/service/use-workflow.ts | 7 +++++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/index.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/index.tsx index d33c6ed7e9..f6ed08c896 100644 --- a/web/app/components/workflow/nodes/human-input/components/delivery-method/index.tsx +++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/index.tsx @@ -13,6 +13,7 @@ import type { const i18nPrefix = 'workflow.nodes.humanInput' type Props = { + nodeId: string value: DeliveryMethod[] nodesOutputVars?: NodeOutPutVar[] availableNodes?: Node[] @@ -20,6 +21,7 @@ type Props = { } const DeliveryMethodForm: React.FC = ({ + nodeId, value, nodesOutputVars, availableNodes, @@ -69,6 +71,7 @@ const DeliveryMethodForm: React.FC = ({
{value.map((method, index) => ( = ({ + nodeId, method, nodesOutputVars, availableNodes, @@ -134,6 +136,8 @@ const DeliveryMethodItem: React.FC = ({ )} {showTestEmailModal && ( void onConfirm: (data: any) => void @@ -60,6 +64,8 @@ const getOriginVar = (valueSelector: string[], list: NodeOutPutVar[]) => { } const EmailSenderModal = ({ + nodeId, + deliveryId, isShow, onClose, onConfirm, @@ -69,6 +75,8 @@ const EmailSenderModal = ({ }: EmailConfigureModalProps) => { const { t } = useTranslation() const { userProfile, currentWorkspace } = useAppContext() + const appDetail = useAppStore(state => state.appDetail) + const { mutateAsync: testEmailSender } = useTestEmailSender() const debugEnabled = !!config?.debug_mode const onlyWholeTeam = config?.recipients?.whole_workspace && (!config?.recipients?.items || config?.recipients?.items.length === 0) @@ -123,6 +131,7 @@ const EmailSenderModal = ({ const [inputs, setInputs] = useState>({}) const [collapsed, setCollapsed] = useState(true) + const [sendingEmail, setSendingEmail] = useState(false) const [done, setDone] = useState(false) const handleValueChange = (variable: string, v: string) => { @@ -132,10 +141,20 @@ const EmailSenderModal = ({ }) } - const handleConfirm = useCallback(() => { - // TODO send api - setDone(true) - }, [onConfirm]) + const handleConfirm = useCallback(async () => { + setSendingEmail(true) + try { + await testEmailSender({ + appID: appDetail?.id || '', + nodeID: nodeId, + deliveryID: deliveryId, + }) + setDone(true) + } + finally { + setSendingEmail(false) + } + }, [appDetail, onConfirm, nodeId, deliveryId, testEmailSender]) if (done) { return ( @@ -302,6 +321,8 @@ const EmailSenderModal = ({