Skip to content

Commit f0b9a1f

Browse files
Merge pull request #3148 from OneCommunityGlobal/Shraddha-fix-send-out-emails-from-send-emails-tab
Shraddha Shahari - Fix the inability to send out emails from send emails tab
2 parents a90555d + ef90049 commit f0b9a1f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/components/Announcements/index.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function Announcements({ title, email }) {
1414
const [emailContent, setEmailContent] = useState('');
1515
const [headerContent, setHeaderContent] = useState('');
1616
const [showEditor, setShowEditor] = useState(true); // State to control rendering of the editor
17-
const tinymce = useRef(null);
17+
const [isFileUploaded, setIsFileUploaded] = useState(false);
1818

1919
useEffect(() => {
2020
// Toggle the showEditor state to force re-render when dark mode changes
@@ -123,6 +123,8 @@ function Announcements({ title, email }) {
123123

124124
const addImageToEmailContent = e => {
125125
const imageFile = document.querySelector('input[type="file"]').files[0];
126+
setIsFileUploaded(true);
127+
126128
convertImageToBase64(imageFile, base64Image => {
127129
const imageTag = `<img src="${base64Image}" alt="Header Image" style="width: 100%; max-width: 100%; height: auto;">`;
128130
setHeaderContent(prevContent => `${imageTag}${prevContent}`);
@@ -149,7 +151,13 @@ function Announcements({ title, email }) {
149151
return;
150152
}
151153

152-
const invalidEmails = emailList.filter(e => !validateEmail(e.trim()));
154+
if (!isFileUploaded) {
155+
toast.error('Error: Please upload a file.');
156+
return;
157+
}
158+
159+
const invalidEmails = emailList.filter(email => !validateEmail(email.trim()));
160+
153161

154162
if (invalidEmails.length > 0) {
155163
toast.error(`Error: Invalid email addresses: ${invalidEmails.join(', ')}`);

0 commit comments

Comments
 (0)