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

Minor email fixes #130

Merged
merged 3 commits into from
Oct 3, 2023
Merged
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
30 changes: 24 additions & 6 deletions src/config/emailContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const CONTACT_MESSAGE_FIELDS: ContactMessageFields = {
email: 'Email: ',
requested_date: 'Requested Date: ',
requested_time: 'Requested Time: ',
appointment_type: 'Appointmet Type: ',
appointment_type: 'Appointment Type: ',
description: 'Description: ',
is_emergency: 'Is this an emergency? ',
};
Expand All @@ -27,12 +27,30 @@ export const generateEmailContent = (
practicePhone: string,
practiceWebsite: string,
) => {
delete data.practice_id;
const stringData = Object.entries(data).reduce((str: string, [key, val]) => {
return (str += `${CONTACT_MESSAGE_FIELDS[key]}: \n${val as string} \n\n`);
}, '');
const emailData = {
first_name: data.first_name,
last_name: data.last_name,
mobile_phone: data.mobile_phone,
email: data.email,
requested_date: data.requested_date!.toDateString(),
requested_time:
data.requested_time!.charAt(0).toUpperCase() +
data.requested_time!.slice(1),
appointment_type:
data.appointment_type!.charAt(0).toUpperCase() +
data.appointment_type!.slice(1),
description: data.description === '' ? 'None' : data.description,
is_emergency: data.is_emergency === true ? 'Yes' : 'No',
};

const htmlData = Object.entries(data).reduce((str, [key, val]) => {
const stringData = Object.entries(emailData).reduce(
(str: string, [key, val]) => {
return (str += `${CONTACT_MESSAGE_FIELDS[key]}: \n${val as string} \n\n`);
},
'',
);

const htmlData = Object.entries(emailData).reduce((str, [key, val]) => {
return (str += `<div style="padding: 5px 0;"><h3 class="form-heading" style="display: inline;">${
CONTACT_MESSAGE_FIELDS[key]
}</h3><p class="form-answer" style="display: inline;">${
Expand Down