diff --git a/src/app/[practiceCode]/book/page.tsx b/src/app/[practiceCode]/book/page.tsx index 7ab8d3a..bdcb618 100644 --- a/src/app/[practiceCode]/book/page.tsx +++ b/src/app/[practiceCode]/book/page.tsx @@ -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 ( @@ -93,6 +93,7 @@ export default async function Appointment({ practiceCity={city} practicePhone={phone!} practiceWebsite={website!} + practiceEmail={email as string} /> { const [, startTransition] = useTransition(); const [createdAppointment, setCreatedAppointment] = @@ -147,6 +149,7 @@ const AppointmentForm = ({ practiceCity, practicePhone, practiceWebsite, + practiceEmail, ) .then(() => { toast({ diff --git a/src/components/actions.ts b/src/components/actions.ts index aa865d0..66ce365 100644 --- a/src/components/actions.ts +++ b/src/components/actions.ts @@ -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'; @@ -56,6 +57,7 @@ export const emailHandler = async ( practiceCity: string, practicePhone: string, practiceWebsite: string, + practiceEmail: string, ) => { try { await transporter.sendMail({ @@ -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.'); diff --git a/src/config/emailContent.ts b/src/config/emailContent.ts index 20d2a9e..b728f91 100644 --- a/src/config/emailContent.ts +++ b/src/config/emailContent.ts @@ -104,3 +104,11 @@ export const generateConfirmationEmailContent = ( }

}${practice.name!} logo

Appointment Confirmation Information

${htmlData}
`, }; }; +export const generatePracticeNotificationEmail = (practiceEmail: string) => { + return { + to: practiceEmail, + subject: `New Appointment Request`, + text: 'You have a new appointment!', + html: `

Hi there!

An appointment has been requested via your Connectient booking page. Please login to your Dashboard to contact the patient!

- The Connectient Team

Connectient logo
`, + }; +};