Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send email feature #4

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
638fccb
Corrected npm start command in README.md for local development
mayura-andrew Jan 2, 2024
04537ab
Merge branch 'sef-global:main' into main
mayura-andrew Jan 4, 2024
638ec27
Fixed README
mayura-andrew Jan 4, 2024
0a2cddf
Merge branch 'sef-global:main' into main
mayura-andrew Jan 9, 2024
335507c
Fixed Facebook icon in nav bar and Apply button issue
mayura-andrew Jan 9, 2024
f6fea0b
Fixed Apply button and See more button used TailwindCSS
mayura-andrew Jan 10, 2024
92a661b
Backend API URL Problem
mayura-andrew Jan 10, 2024
32595c8
Fixed Apply button and See more buttons (Removed template iterals)
mayura-andrew Jan 11, 2024
c26820e
Connect with Backend API
mayura-andrew Jan 11, 2024
1e5b97f
added \
mayura-andrew Jan 11, 2024
a9666e9
Added environment variable to connect backend api
mayura-andrew Jan 11, 2024
dfc7028
Fixed typos in README
mayura-andrew Jan 11, 2024
4f86fd0
added .end to .gitignore
mayura-andrew Jan 11, 2024
0bf8c9f
Merge branch 'main' into main
mayura-andrew Jan 11, 2024
5fc0a50
fixed typos in example.env file
mayura-andrew Jan 11, 2024
c07988c
changed API_URL setup
mayura-andrew Jan 11, 2024
0516513
Fixed example.env
mayura-andrew Jan 11, 2024
2459152
Stop tracking .env file
mayura-andrew Jan 12, 2024
46118e6
fixed "Become a menter" button using Tailwind
mayura-andrew Jan 13, 2024
4df0cda
Merge branch 'sef-global:main' into main
mayura-andrew Jan 13, 2024
16c2662
Fixed that "Become a Mentor" button issue in MenuDrawer
mayura-andrew Jan 13, 2024
66bfb48
Fixed LoginModal mobile responsiveness
mayura-andrew Jan 14, 2024
ad14b9e
Merge branch 'sef-global:main' into main
mayura-andrew Jan 16, 2024
0e1b085
Merge branch 'sef-global:main' into main
mayura-andrew Jan 31, 2024
f543b33
Google OAuth integerate
mayura-andrew Feb 1, 2024
a4ff0c1
Implemented Google Sign-in button
mayura-andrew Feb 2, 2024
a989437
Merge branch 'sef-global:main' into main
mayura-andrew Feb 8, 2024
c26d3d6
changed tailwind css
mayura-andrew Feb 11, 2024
3f64ffd
Merge branch 'sef-global:main' into main
mayura-andrew Mar 26, 2024
f5105ab
Success stories container Buttons Color Changed
mayura-andrew Mar 30, 2024
ef1d995
Button's color changed (Success stories container)
mayura-andrew Mar 30, 2024
9219890
Merge branch 'sef-global:main' into main
mayura-andrew Apr 28, 2024
0dd1a0e
implement draft email feature
mayura-andrew Apr 29, 2024
76c7d7d
added response message to email sending comp
mayura-andrew Apr 29, 2024
5223149
Added overflow to Email Component
mayura-andrew Apr 29, 2024
9457d2b
added loading spinner to send button
mayura-andrew May 3, 2024
0240806
Implement API Check BTN
mayura-andrew May 12, 2024
0e152ad
Added EmailAPI URLs
mayura-andrew May 12, 2024
6b7e0c0
removed iconempty.png
mayura-andrew May 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_API_URL=http://localhost:3000/api
VITE_EMAILAPI_URL=https://64.227.135.79/
43 changes: 43 additions & 0 deletions src/components/Dashboard/scenes/Emails/CheckButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// CheckButton.tsx
import React from 'react';

interface CheckButtonProps {
isLoading: boolean;
checkApiStatus: () => void;
}
const CheckButton: React.FC<CheckButtonProps> = ({
isLoading,
checkApiStatus,
}) => (
<button
onClick={checkApiStatus}
className="text-black focus:ring-opacity-50 font-bold py-0.5 px-1 text-xs items-center ml-2"
>
{isLoading ? (
<svg
className="animate-spin ml-1 mr-1 h-5 w-5 text-black"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
></circle>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
</svg>
) : (
'Check'
)}
</button>
);

export default CheckButton;
127 changes: 127 additions & 0 deletions src/components/Dashboard/scenes/Emails/EmailHistory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import React, { useEffect, useState, useCallback } from 'react';
import axios from 'axios';
import { useQuery } from '@tanstack/react-query';
import { EMAILAPI_URL } from '../../../../constants';

interface Email {
recipients: string;
subject: string;
status: string;
opened: boolean;
sentTime: string;
}

const EmailHistory: React.FC<{ refreshCount: number }> = ({ refreshCount }) => {
const [emails, setEmails] = useState<Email[]>([]);
const [isLoading, setIsLoading] = useState(false);

const fetchEmails = useCallback(() => {
setIsLoading(true);
setTimeout(() => {
axios
.get(`${EMAILAPI_URL}/api/v1/sent`)
.then((response) => {
setEmails(
Array.isArray(response.data.emails) ? response.data.emails : []
);
setIsLoading(false);
})
.catch((error) => {
console.error('Error:', error);
setIsLoading(false);
});
}, 1000);
}, []);
useEffect(() => {
fetchEmails();
}, [fetchEmails, refreshCount]);

return (
<div className="container mx-auto p-4 bg-white max-h-[800px] overflow-y-auto min-h-full min-w-full">
<div className="flex flex-col items-center justify-center">
<p className="text-2xl font-bold mb-4">History</p>
<button
onClick={fetchEmails}
className="px-8 py-1 m-3 text-white bg-red-300 rounded hover:bg-red-500 focus:outline-none focus:ring-2 focus:ring-red-600 focus:ring-opacity-50 flex justify-center items-center"
>
{isLoading ? 'Refreshing...' : 'Refresh'}
</button>
{isLoading ? (
<div className="flex justify-center items-center h-64">
<>
<svg
aria-hidden="true"
className="inline w-8 h-8 text-gray-200 animate-spin fill-blue-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span className="sr-only">Loading...</span>
</>
</div>
) : emails.length === 0 ? (
<div className="flex flex-col items-center justify-center space-y-4">
<span role="img" aria-label="empty mailbox" className="text-6xl">
📭
</span>
<p className="text-lg text-gray-600">No mails</p>
</div>
) : (
<table className="min-w-full divide-y divide-gray-200 shadow-sm rounded-lg overflow-hidden">
<thead className="bg-gray-50">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Recipient
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Subject
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Opened
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Sent Time
</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{emails.map((email, index) => (
<tr key={index}>
<td className="px-6 py-4 whitespace-nowrap">
{email.recipients}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{email.subject}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{email.status}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{email.opened}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{new Date(email.sentTime).toLocaleString()}
</td>
</tr>
))}
</tbody>
</table>
)}
</div>
</div>
);
};

export default EmailHistory;
184 changes: 184 additions & 0 deletions src/components/Dashboard/scenes/Emails/EmailTemplate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// EmailTemplate.tsx
import React from 'react';

interface EmailTemplateProps {
subject: string;
body: string;
recipient: string;
}

const EmailTemplate: React.FC<EmailTemplateProps> = ({
subject,
body,
select,
}) => {
return (
<div
dangerouslySetInnerHTML={{
__html: `
<div role="article" aria-roledescription="email" lang="en" style="
text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
background-color: #ffffff;
">
<div role="article" aria-roledescription="email" lang="en" style="
text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
background-color: #ffffff;
">
<table role="presentation" style="width: 100%; border: none; border-spacing: 0">
<tr>
<td align="center" style="padding: 0">
<table role="presentation" style="
width: 94%;
max-width: 600px;
border: none;
border-spacing: 0;
text-align: left;
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 22px;
color: #363636;
">
<tr>
<td style="
padding: 40px 30px 30px 30px;
text-align: center;
font-size: 24px;
font-weight: bold;
">
<a href="https://sefglobal.org/" style="text-decoration: none"><img src="https://sefglobal.org/assets/img/brand/logo.png" width="165" style="
width: 80%;
max-width: 165px;
height: auto;
border: none;
text-decoration: none;
color: #ffffff;
"/></a>
</td>
</tr>
<tr>
<td style="
padding: 35px 30px 11px 30px;
font-size: 0;
background-color: #ffffff;
border-bottom: 1px solid #f0f0f5;
border-color: rgba(201, 201, 207, 0.35);
">
<div class="col-lge" style="
display: inline-block;
width: 100%;
min-width: 100%;
vertical-align: top;
padding-bottom: 20px;
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 22px;
color: #363636;
">
<p style="margin-top: 0; margin-bottom: 22px">
${subject}
</p>
<p style="margin-top: 0; margin-bottom: 22px">
Dear ${select},
</p>
<p style="margin-top: 0; margin-bottom: 22px">
${body}
</p>
<p style="margin-top: 0; margin-bottom: 18px">
Best regards,<br/>
ScholarX Team,<br/>
Sustainable Education Foundation.
</p>
<p style="margin: 0" th:if="">
<a href="https://scholarx.sefglobal.org/" style="
background: #1890ff;
text-decoration: none;
padding: 10px 25px;
color: #ffffff;
border-radius: 4px;
display: inline-block;
mso-padding-alt: 0;
text-underline-color: #1890ff;
">
<span style="mso-text-raise: 10pt; font-weight: bold">View Dashboard</span>
</a>
<a href="https://join.slack.com/t/sefheadquarters/shared_invite/zt-1jwub1lpd-RXYAMG46qXRUhOGZ7u_ewg" style="
background: #6dca65;
text-decoration: none;
padding: 10px 25px;
color: #ffffff;
border-radius: 4px;
display: inline-block;
mso-padding-alt: 0;
text-underline-color: #6dca65;
">
<span style="mso-text-raise: 10pt; font-weight: bold">Join our Slack</span>
</a>
</p>
</div>
</td>
</tr>
<tr>
<td style="
padding: 30px;
text-align: center;
font-size: 12px;
background-color: #f0f2f5;
color: #cccccc;
">
<p style="margin: 0 0 8px 0">
<a href="https://www.facebook.com/sustainableeducationfoundation"
style="text-decoration: none">
<img
src="https://img.icons8.com/material-outlined/192/000000/facebook-f.png"
alt="facebook-icon"
height="40"
width="40"
style="display: inline-block; opacity: 0.35;">
</a>
<a href="https://twitter.com/goasksef" style="text-decoration: none">
<img
src="https://img.icons8.com/ios-filled/150/000000/twitter.png"
alt="facebook-icon"
height="35"
width="35"
style="display: inline-block; opacity: 0.35;">
</a>
<a href="https://www.linkedin.com/company/sefglobal/" style="text-decoration: none">
<img
src="https://img.icons8.com/windows/128/000000/linkedin-2.png"
alt="facebook-icon"
height="40"
width="40"
style="display: inline-block; opacity: 0.35;">
</a>
<a href="https://www.instagram.com/sefglobal/" style="text-decoration: none">
<img
src="https://img.icons8.com/material-outlined/192/000000/instagram-new--v1.png"
alt="facebook-icon"
height="40"
width="40"
style="display: inline-block; opacity: 0.35;">
</a>
</p>
<p style="margin: 0; font-size: 14px; line-height: 20px">
&copy; Sustainable Education Foundation - SEF 2024
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
`,
}}
/>
);
};

export default EmailTemplate;
Loading