+
To: {managerName || managerEmail || 'No recipient set'}
{sendSuccess && ( -+
✓ Gratitude sent successfully!
)}{action.action}
+{action.action}
{action.byDate && (
Due by: {action.byDate}
@@ -152,17 +152,17 @@ const GratitudeModal: React.FC
- ${username} would like to share the following statements with you: -
- `; - - publicStatements.forEach((entry) => { - html += ` -- ${entry.atoms.subject} ${getVerbName(entry.atoms.verb)} ${entry.atoms.object} -
- `; - - // Add actions if they exist - if (entry.actions && entry.actions.length > 0) { - const pendingActions = entry.actions.filter( - (action) => !action.completed - ); - - if (pendingActions.length > 0) { - html += `Actions:
-- This email was sent from the Lift application. -
- `; - - return html; - }; - const handleSendEmail = async () => { try { setIsSending(true); @@ -88,28 +33,28 @@ const ShareEmailModal: React.FC<{ onClose: () => void }> = ({ onClose }) => { if (!managerEmail || managerEmail.trim() === '') { throw new Error( - 'Manager email is not set. Please set a manager email first.' + 'Manager email is not set. Please set a manager email first in your User Data.' + ); + } + + if (!data.userEmail) { + throw new Error( + 'Your email address is not available. Please try signing out and signing in again with magic link.' ); } - const emailPayload: Email = { - from: 'notifications@lift-app.com', // This should be your app's email - to: [managerEmail], - subject: `${username} would like to share statements with you`, - html: generateEmailHtml(), - }; + // Send the user's email to the backend, which will retrieve the user's statements + // and send them to the manager email address stored in the user's profile + await shareStatements(data.userEmail); - await sendEmail(emailPayload); setSendSuccess(true); - - // Automatically close after successful send setTimeout(() => onClose(), 2000); } catch (error) { - console.error('Failed to send email:', error); + console.error('Failed to share statements:', error); setSendError( typeof error === 'object' && error !== null && 'message' in error ? (error as Error).message - : 'Failed to send email. Please try again later.' + : 'Failed to share statements. Please try again later.' ); } finally { setIsSending(false); @@ -118,143 +63,133 @@ const ShareEmailModal: React.FC<{ onClose: () => void }> = ({ onClose }) => { return ( <> - {isPrivacyModalOpen &&