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

Dj/feature/practice notifications #131

Merged
merged 3 commits into from
Dec 29, 2023
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
3 changes: 2 additions & 1 deletion src/app/[practiceCode]/book/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default async function Appointment({

if (!data || data?.length < 1) redirect('/');

const [{ id, name, logo, street_address, city, phone, website }] =
const [{ id, name, logo, street_address, city, phone, website, email }] =
data as Practice[];

return (
Expand All @@ -93,6 +93,7 @@ export default async function Appointment({
practiceCity={city}
practicePhone={phone!}
practiceWebsite={website!}
practiceEmail={email as string}
/>
<AppointmentFooter
name={name}
Expand Down
3 changes: 3 additions & 0 deletions src/components/AppointmentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type PracticeInfo = {
practiceCity: string;
practicePhone: string;
practiceWebsite: string;
practiceEmail: string;
};

const AppointmentForm = ({
Expand All @@ -89,6 +90,7 @@ const AppointmentForm = ({
practiceCity,
practicePhone,
practiceWebsite,
practiceEmail,
}: PracticeInfo) => {
const [, startTransition] = useTransition();
const [createdAppointment, setCreatedAppointment] =
Expand Down Expand Up @@ -147,6 +149,7 @@ const AppointmentForm = ({
practiceCity,
practicePhone,
practiceWebsite,
practiceEmail,
)
.then(() => {
toast({
Expand Down
6 changes: 6 additions & 0 deletions src/components/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { transporter, mailOptions } from '@/config/nodemailer';
import {
generateConfirmationEmailContent,
generateEmailContent,
generatePracticeNotificationEmail,
} from '@/config/emailContent';
import ConfirmationEmailData from '@/types/ConfirmationEmailData';
import PracticeEmailData from '@/types/PracticeEmailData';
Expand Down Expand Up @@ -56,6 +57,7 @@ export const emailHandler = async (
practiceCity: string,
practicePhone: string,
practiceWebsite: string,
practiceEmail: string,
) => {
try {
await transporter.sendMail({
Expand All @@ -70,6 +72,10 @@ export const emailHandler = async (
practiceWebsite,
),
});
await transporter.sendMail({
...mailOptions,
...generatePracticeNotificationEmail(practiceEmail),
});
return appointmentData;
} catch (error) {
throw new Error('Failed to send request email.');
Expand Down
8 changes: 8 additions & 0 deletions src/config/emailContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,11 @@ export const generateConfirmationEmailContent = (
}</p>}<img alt="${practice.name!} logo"src=${practice.logo!} style=width:200px></div><table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td class=section-padding style="padding:10px 15px 30px 15px"align=center bgcolor=#ffffff><table border=0 cellpadding=0 cellspacing=0 width=100% class=responsive-table style=max-width:500px><tr><td><table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td><table border=0 cellpadding=0 cellspacing=0 width=100%><tr><td class="message-content padding"style=padding:0;font-size:16px;line-height:25px;color:#232323><h2>Appointment Confirmation Information</h2><div class=form-container>${htmlData}</div></table></table></table></table>`,
};
};
export const generatePracticeNotificationEmail = (practiceEmail: string) => {
return {
to: practiceEmail,
subject: `New Appointment Request`,
text: 'You have a new appointment!',
html: `<!doctypehtml><title></title><meta charset=utf-8><meta content="width=device-width,initial-scale=1"name=viewport><meta content="IE=edge"http-equiv=X-UA-Compatible><style>a,body,table,td{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}table{border-collapse:collapse!important}body{height:100%!important;margin:0!important;padding:0!important;width:100%!important}@media screen and (max-width:525px){.wrapper{width:100%!important;max-width:100%!important}.responsive-table{width:100%!important}.padding{padding:10px 5% 15px 5%!important}.section-padding{padding:0 15px 50px 15px!important}}.form-container{margin-bottom:24px;padding:20px;border:1px dashed #ccc}.form-heading{color:#2a2a2a;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight:400;text-align:left;line-height:20px;font-size:14px;margin:0 0 8px;padding:0}.form-answer{color:#2a2a2a;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight:300;text-align:left;line-height:20px;font-size:1.2rem;margin:0 0 24px;padding:0}div[style*='margin: 16px 0;']{margin:0!important}</style><body style=margin:0!important;padding:0!important;background:#fff><div style=display:none;font-size:1px;color:#fefefe;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden></div><div style="margin:20px 50px;font-size:0.9rem"><p>Hi there!<p>An appointment has been requested via your Connectient booking page. Please login to your <a href="https://connectient.co/admin/login" target="_blank">Dashboard</a> to contact the patient!<p style=margin:24px 0px>- The Connectient Team</p><img alt="Connectient logo"src="https://vvlzpciuhggoletuwmqf.supabase.co/storage/v1/object/public/Practice%20Media/connectient-logo.png" style=width:200px></div>`,
};
};