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

Custom Mail Completed #212

Merged
merged 2 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22,594 changes: 22,464 additions & 130 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-html-email": "^3.0.0",
"react-icons": "^4.4.0",
"react-lottie": "^1.2.3",
"react-router": "^6.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/Components/Animation/Animation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
border: none;
outline: none;
position: absolute;
cursor: pointer;
gap: 0.6rem;
bottom: -20px;
z-index: 2;
Expand Down
62 changes: 62 additions & 0 deletions src/Components/ConfirmEmail/ConfirmEmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function ConfirmEmail({ request,status }) {
return (
<>
<div>
<p>
Hi {request.sender}
{" , "}{" "}
</p>
<p
style={{
paddingLeft: "1.5rem",
}}
>
<b>{request.receiver}</b> has{" "}
<b>{status === "accepted" && "ACCEPTED"}</b>
<b>{status === "declined" && "DECLINED"}</b> your{" "}
<b>{request.type === "invite" ? "INVITE" : "REQUEST"}</b> to join
their team for the project{" "}
<i>
<a
href={`https://iedc-collab-frontend.pages.dev/${request.project_id}`}
target="_blank"
rel="noreferrer"
>
{request.project}
</a>
</i>
</p>
<br />
<div>
<p>
To view more details , Vist{" "}
<a
href="https://www.iedc-collab-frontend.pages.dev"
target="_blank"
rel="noreferrer"
>
https://www.iedc-collab-frontend.pages.dev
</a>
</p>
</div>
<br />
<p>Thank You</p>
<br />
<p>Regards</p>
<p>IEDC MEC Collab Team</p>
<br />
<p>
NOTE : This is an auto generated email.Please DO NOT REPLY to this
mail.
</p>
<p>
<i>
For any queries please visit{" "}
<a href="https://www.iedcmec.in">https://www.iedcmec.in</a>
</i>
</p>
</div>
</>
);
}
export default ConfirmEmail;
84 changes: 84 additions & 0 deletions src/Components/Email/Email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
function Email({ request }) {
return (
<>
<div>
<p>
Hi {request.receiver}
{" , "}{" "}
</p>
<p
style={{
paddingLeft: "1.5rem",
}}
>
<b>{request.sender}</b> has{" "}
<b>{request.type === "invite" ? "INVITED" : "REQUESTED"}</b> you to
join their team for the project{" "}
<i>
<a
href={`https://iedc-collab-frontend.pages.dev/${request.project_id}`}
target="_blank"
rel="noreferrer"
>
{request.project}
</a>
</i>
</p>
<br />
<p
style={{
paddingLeft: "1.5rem",
}}
>
<b>Message : </b>{" "}
<p
style={{
paddingLeft: "1.5rem",
}}
>
{request.message}
</p>
</p>
<p
style={{
paddingLeft: "1.5rem",
}}
>
{"- "}
<b>{request.sender}</b>
</p>
<br />
<div>
<p>
To view more details and to accept/decline the{" "}
{request.type === "invite" ? "invite" : "request"} , Vist{" "}
<a
href="https://iedc-collab-frontend.pages.dev"
target="_blank"
rel="noreferrer"
>
https://iedc-collab-frontend.pages.dev
</a>
</p>
</div>
<br />
<p>Thank You</p>
<br />
<p>Regards</p>
<p>IEDC MEC Collab Team</p>
<br />
<p>
NOTE : This is an auto generated email.Please DO NOT REPLY to this
mail.
</p>
<p>
<i>
For any queries please visit{" "}
<a href="https://iedcmec.in">https://iedcmec.in</a>
</i>
</p>
</div>
</>
);
}
export default Email;
39 changes: 17 additions & 22 deletions src/Components/InviteToProjectModal/InviteToProjectModal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import Button from "react-bootstrap/Button";
import "./InviteToProjectModal.scss";
import { emailUrl } from "../../Utils/urls";
Expand All @@ -8,7 +7,7 @@ import triangle_3 from "../../assets/triangle_3.svg";
import triangle_4 from "../../assets/triangle_4.svg";
import axios from "axios";
import { useContext, useEffect, useState } from "react";
import '../JoinTeamModal/JoinTeamModal.scss'
import "../JoinTeamModal/JoinTeamModal.scss";
// import {
// getProjects,
// } from "../../Firebase/firebase";
Expand All @@ -21,19 +20,24 @@ import {
MenuItem,
Select,
ThemeProvider,
useMediaQuery,
} from "@mui/material";
import { sendInvite } from "../../Firebase/firebase";
import { toast } from "react-toastify";
import { ProjectContext } from "../../contexts/ProjectContext";
import { RiCloseLine } from "react-icons/ri";
import { IoPaperPlaneSharp } from "react-icons/io5";
import { useTheme } from "@emotion/react";
import Email from "../Email/Email";
import { renderEmail } from "react-html-email";

const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
// const [projects, setProjects] = useState([]);
const [project, setProject] = useState("");
const { projects, fetchRequests } = useContext(ProjectContext);
const [listProjects, setListProjects] = useState([]);
const [message, setMessage] = useState("");
const fullScreen = useMediaQuery(useTheme().breakpoints.down("sm"));
const theme = createTheme({
components: {
MuiOutlinedInput: {
Expand Down Expand Up @@ -61,20 +65,11 @@ const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
},
});
async function handleSubmit() {
try {
await axios.post(emailUrl, {
toEmail: selectedUser.email,
subject: `Invite to ${project.name} from IEDC Collab`,
content: message,
});
} catch (err) {
console.log(err);
}

let data = {
sender: user.displayName,
sender_id: user.uid,
sender_email: user.email,
sender_img: user.photoURL,
reciever_email: selectedUser.email,
receiver: selectedUser.name,
reciever_img:
Expand All @@ -91,6 +86,12 @@ const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
toast("Invite Sent Successfully");
fetchRequests();
});
await axios.post(emailUrl, {
toEmail: selectedUser.email,
subject: `Invite to join project ${project.name} from IEDC Collab`,
// content: message,
content: renderEmail(<Email request={data} />),
});
}

const getWorks = async () => {
Expand Down Expand Up @@ -125,13 +126,8 @@ const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
<Dialog
onClose={props.handleClose}
open={props.open}
PaperProps={{
sx: {
width: "95vw",
position: "absolute",
},
}}
fullWidth={true}
fullScreen={fullScreen}
maxWidth="md"
className="invite-to-project-modal"
>
Expand All @@ -150,7 +146,6 @@ const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
<FormControl>
<InputLabel
id="demo-simple-select-label"

style={{
fontWeight: "400",
fontSize: "17px",
Expand All @@ -161,11 +156,11 @@ const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
Select Project
</InputLabel>
<Select
className="invite-project-name__label"
className="invite-project-name__label"
style={{
fontWeight: "400",
fontSize: "17px",

lineHeight: "26px",
color: " #622308",
}}
Expand Down Expand Up @@ -196,7 +191,7 @@ const InviteToProjectModal = ({ user, selectedUser, ...props }) => {
<p className="message__label">Message</p>
<textarea
className="message__text"
style={{whiteSpace: "pre-wrap"}}
style={{ whiteSpace: "pre-wrap" }}
onChange={(e) => setMessage(e.target.value)}
></textarea>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
padding-inline: 10px;
}

#message__text {
.message__text {
border: 1px solid #9e0000;
border-radius: 10px;
background-color: inherit;
Expand Down
38 changes: 18 additions & 20 deletions src/Components/JoinTeamModal/JoinTeamModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,16 @@ import { toast } from "react-toastify";
import { ProjectContext } from "../../contexts/ProjectContext";
import { RiCloseLine } from "react-icons/ri";
import { IoPaperPlaneSharp } from "react-icons/io5";
import { Dialog, DialogContent } from "@mui/material";
import { Dialog, DialogContent, useMediaQuery, useTheme } from "@mui/material";
import { renderEmail } from "react-html-email";
import Email from "../Email/Email";

const JoinTeamModal = ({ user, project, ...props }) => {
const [message, setMessage] = useState("");
const fullScreen = useMediaQuery(useTheme().breakpoints.down("sm"));
const { fetchRequests } = useContext(ProjectContext);

const onSubmit = async () => {
try {
await axios.post(
"https://w2e9j471i2.execute-api.ap-south-1.amazonaws.com/dev/send-email",
{
toEmail: project.leaderEmail,
subject: `Request to Join Team of ${project.name} from IEDC Collab`,
content: message,
}
);
} catch (err) {
console.log(err);
}
let data = {
sender: user.displayName,
sender_id: user.uid,
Expand All @@ -48,18 +39,25 @@ const JoinTeamModal = ({ user, project, ...props }) => {
fetchRequests();
toast("Request Sent Successfully");
});
try {
await axios.post(
"https://w2e9j471i2.execute-api.ap-south-1.amazonaws.com/dev/send-email",
{
toEmail: project.leaderEmail,
subject: `Request to Join Team of ${project.name} from IEDC Collab`,
content: renderEmail(<Email request={data} />),
}
);
} catch (err) {
console.log(err);
}
};
return (
<>
<Dialog
onClose={props.handleClose}
open={props.open}
PaperProps={{
sx: {
width: "95vw",
position: "absolute",
},
}}
fullScreen={fullScreen}
fullWidth={true}
maxWidth="md"
className="join-team-modal"
Expand Down Expand Up @@ -105,7 +103,7 @@ const JoinTeamModal = ({ user, project, ...props }) => {
<p className="message__label">Message</p>
<textarea
className="message__text"
style={{whiteSpace: "pre-wrap"}}
style={{ whiteSpace: "pre-wrap" }}
onChange={(e) => setMessage(e.target.value)}
></textarea>
</div>
Expand Down
Loading