From c66b68fa395a8ed9fd29c6bd00b883f9a08ae06b Mon Sep 17 00:00:00 2001 From: Ronni Skansing Date: Fri, 21 Nov 2025 16:46:39 +0100 Subject: [PATCH] fix make campaign recipient action texts more clear. Added copy recipient email Signed-off-by: Ronni Skansing --- .../src/routes/campaign/[id]/+page.svelte | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/frontend/src/routes/campaign/[id]/+page.svelte b/frontend/src/routes/campaign/[id]/+page.svelte index 1321a76..8371cd7 100644 --- a/frontend/src/routes/campaign/[id]/+page.svelte +++ b/frontend/src/routes/campaign/[id]/+page.svelte @@ -350,7 +350,7 @@ }; /** @param {string} campaignRecipientID */ - const onClickCopyEmail = async (campaignRecipientID) => { + const onClickCopyEmailContent = async (campaignRecipientID) => { try { const res = await api.campaign.getEmail(campaignRecipientID); if (!res.success) { @@ -365,15 +365,25 @@ }) ]; await navigator.clipboard.write(data); - addToast('Email copied to clipboard', 'Success'); + addToast('Email content copied to clipboard', 'Success'); } catch (e) { // handle missing template part if (e.includes('has no')) { addToast('Campaign template is incomplete', 'Error'); } else { - addToast('Failed to copy email', 'Error'); + addToast('Failed to copy email content', 'Error'); } - console.error('failed to copy email to clipboard', e); + console.error('failed to copy email content to clipboard', e); + } + }; + + /** @param {string} email */ + const onClickCopyEmail = async (email) => { + try { + await navigator.clipboard.writeText(email); + addToast('Email copied to clipboard', 'Success'); + } catch (e) { + addToast('Failed to copy email', 'Error'); } }; @@ -516,11 +526,6 @@ setAsSentRecipient = null; }; - // helper function to get appropriate messaging based on sender type - const getMessageType = () => { - return campaign.template?.email ? 'email' : 'message'; - }; - const onConfirmSendMessage = async () => { try { showIsLoading(); @@ -530,19 +535,15 @@ if (!res.success) { throw res.error; } - const messageType = getMessageType(); - const message = isResend - ? `${messageType.charAt(0).toUpperCase() + messageType.slice(1)} sent again successfully` - : `${messageType.charAt(0).toUpperCase() + messageType.slice(1)} sent successfully`; - addToast(message, 'Success'); + addToast('Message Sent', 'Success'); await setCampaign(); await getEvents(); await refreshCampaignRecipients(); closeSendMessageModal(); return { success: true }; } catch (e) { - addToast(`Failed to send ${getMessageType()}`, 'Error'); - console.error(`failed to send ${getMessageType()}`, e); + addToast(`Failed to send message}`, 'Error'); + console.error(`failed to send message`, e); throw e; } finally { hideIsLoading(); @@ -1662,9 +1663,13 @@ onClickCopyEmail(recp.id)} + on:click={() => onClickCopyEmailContent(recp.id)} + /> + onClickCopyEmail(recp?.recipient?.email)} /> openEventsModal(recp.recipientID)} /> showSendMessageModal(recp.id, recp.recipient)} disabled={!!campaign.closedAt || recp.cancelledAt} /> {#if !campaign.sendStartAt} onClickSetEmailSent(recp.id, recp.recipient)} disabled={!!campaign.closedAt || recp.cancelledAt} @@ -2089,7 +2094,7 @@ @@ -2099,8 +2104,8 @@ {#if recipient}

{recipient.sentAt - ? `Are you sure you want to send the campaign ${getMessageType()} again to:` - : `Are you sure you want to send the campaign ${getMessageType()} to:`} + ? `Are you sure you want to send the campaign message again to:` + : `Are you sure you want to send the campaign message to:`}

{sendMessageRecipient.name}

@@ -2121,7 +2126,7 @@