Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mentalcaries committed Oct 23, 2023
2 parents 89365ee + c283bb9 commit 55048b0
Showing 1 changed file with 24 additions and 6 deletions.
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

0 comments on commit 55048b0

Please sign in to comment.