chore: booking verification token and booking rejection logic from email (#16324)

Co-authored-by: Omar López <[email protected]>
This commit is contained in:
Anik Dhabal BabuandOmar López authored and GitHub committed 2024-09-21 02:25:27 +00:00
1 parent 76a2773688
commit 1a60afad7a
19 files changed
+362 -8

No files matched your search

@@ -0,0 +1,90 @@
export const BookingConfirmationForm = (props: { action: string; children: React.ReactNode }) => {
return (
<form action={props.action} method="POST" target="_blank">
{props.children}
<p
style={{
display: "inline-block",
background: "#FFFFFF",
border: "",
color: "#ffffff",
fontFamily: "Roboto, Helvetica, sans-serif",
fontSize: "0.875rem",
fontWeight: 500,
lineHeight: "1rem",
margin: 0,
textDecoration: "none",
textTransform: "none",
padding: "0.625rem 0",
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
msoPaddingAlt: "0px",
borderRadius: "6px",
boxSizing: "border-box",
height: "2.25rem",
width: "100%",
}}>
<label
style={{
color: "#3e3e3e",
fontFamily: "Roboto, Helvetica, sans-serif",
fontSize: "0.875rem",
fontWeight: 500,
lineHeight: "1rem",
textAlign: "left",
whiteSpace: "pre-wrap",
display: "block",
}}>
Reason for rejection &nbsp;
<small>(Optional)</small>
</label>
<textarea
name="reason"
placeholder="Why are you rejecting?"
style={{
appearance: "none",
backgroundColor: "rgb(255, 255, 255)",
borderBottomColor: "rgb(209, 213, 219)",
borderBottomLeftRadius: "6px",
borderBottomRightRadius: "6px",
borderBottomStyle: "solid",
borderBottomWidth: "1px",
borderLeftColor: "rgb(209, 213, 219)",
borderLeftStyle: "solid",
borderLeftWidth: "1px",
borderRightColor: "rgb(209, 213, 219)",
borderRightStyle: "solid",
borderRightWidth: "1px",
borderTopColor: "rgb(209, 213, 219)",
borderTopLeftRadius: "6px",
borderTopRightRadius: "6px",
borderTopStyle: "solid",
borderTopWidth: "1px",
boxSizing: "border-box",
color: "rgb(56, 66, 82)",
display: "block",
fontSize: "14px",
lineHeight: "20px",
marginBottom: "16px",
marginLeft: "0px",
marginRight: "0px",
marginTop: "8px",
paddingBottom: "8px",
paddingLeft: "12px",
paddingRight: "12px",
paddingTop: "8px",
resize: "vertical",
scrollbarColor: "auto",
scrollbarWidth: "auto",
tabSize: 4,
textAlign: "start",
visibility: "visible",
width: "100%",
maxWidth: 550,
}}
rows={3}
/>
</p>
</form>
);
};
@@ -2,7 +2,7 @@ import { CallToActionIcon } from "./CallToActionIcon";
export const CallToAction = (props: {
label: string;
href: string;
href?: string;
secondary?: boolean;
startIconName?: string;
endIconName?: string;
@@ -24,6 +24,9 @@ export const CallToAction = (props: {
return `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`;
};
const El = href ? "a" : "button";
const restProps = href ? { href, target: "_blank" } : { type: "submit" };
return (
<p
style={{
@@ -46,7 +49,8 @@ export const CallToAction = (props: {
boxSizing: "border-box",
height: "2.25rem",
}}>
<a
{/* @ts-expect-error shared props between href and button */}
<El
style={{
color: secondary ? "#292929" : "#FFFFFF",
textDecoration: "none",
@@ -54,9 +58,16 @@ export const CallToAction = (props: {
alignItems: "center",
justifyContent: "center",
margin: "auto",
appearance: "none",
background: "transparent",
border: "none",
padding: 0,
fontSize: "inherit",
fontWeight: 500,
lineHeight: "1rem",
cursor: "pointer",
}}
href={href}
target="_blank"
{...restProps}
rel="noreferrer">
{startIconName && (
<CallToActionIcon
@@ -69,7 +80,7 @@ export const CallToAction = (props: {
)}
{label}
{endIconName && <CallToActionIcon iconName={endIconName} />}
</a>
</El>
</p>
);
};
@@ -1,5 +1,7 @@
import BaseTable from "./BaseTable";
export const CallToActionTable = (props: { children: React.ReactNode }) => (
<table>
<BaseTable border="0" style={{ verticalAlign: "top" }} width="100%">
<tbody>
<tr>
<td
@@ -18,5 +20,5 @@ export const CallToActionTable = (props: { children: React.ReactNode }) => (
</td>
</tr>
</tbody>
</table>
</BaseTable>
);
+1
View File
@@ -1,4 +1,5 @@
export { BaseEmailHtml } from "./BaseEmailHtml";
export { BookingConfirmationForm } from "./BookingConfirmationForm";
export { V2BaseEmailHtml } from "./V2BaseEmailHtml";
export { CallToAction } from "./CallToAction";
export { CallToActionTable } from "./CallToActionTable";
@@ -0,0 +1,43 @@
import { WEBAPP_URL } from "@calcom/lib/constants";
import { CallToAction, Separator, CallToActionTable, BookingConfirmationForm } from "../components";
import { OrganizerScheduledEmail } from "./OrganizerScheduledEmail";
export const OrganizerRequestEmailV2 = (props: React.ComponentProps<typeof OrganizerScheduledEmail>) => {
const { uid } = props.calEvent;
const userId = props.calEvent.organizer.id;
const token = props.calEvent.oneTimePassword;
//TODO: We should switch to using org domain if available
const actionHref = `${WEBAPP_URL}/api/verify-booking-token/?token=${token}&userId=${userId}&bookingUid=${uid}`;
return (
<OrganizerScheduledEmail
title={
props.title || props.calEvent.recurringEvent?.count
? "event_awaiting_approval_recurring"
: "event_awaiting_approval"
}
subtitle={<>{props.calEvent.organizer.language.translate("someone_requested_an_event")}</>}
headerType="calendarCircle"
subject="event_awaiting_approval_subject"
callToAction={
<BookingConfirmationForm action={`${actionHref}&action=reject`}>
<CallToActionTable>
<CallToAction
label={props.calEvent.organizer.language.translate("confirm")}
href={`${actionHref}&action=accept`}
startIconName="confirmIcon"
/>
<Separator />
<CallToAction
label={props.calEvent.organizer.language.translate("reject")}
// href={`${actionHref}&action=reject`}
startIconName="rejectIcon"
secondary
/>
</CallToActionTable>
</BookingConfirmationForm>
}
{...props}
/>
);
};
+1
View File
@@ -15,6 +15,7 @@ export { OrganizerCancelledEmail } from "./OrganizerCancelledEmail";
export { OrganizerLocationChangeEmail } from "./OrganizerLocationChangeEmail";
export { OrganizerPaymentRefundFailedEmail } from "./OrganizerPaymentRefundFailedEmail";
export { OrganizerRequestEmail } from "./OrganizerRequestEmail";
export { OrganizerRequestEmailV2 } from "./OrganizerRequestEmailV2";
export { OrganizerRequestReminderEmail } from "./OrganizerRequestReminderEmail";
export { OrganizerRequestedToRescheduleEmail } from "./OrganizerRequestedToRescheduleEmail";
export { OrganizerRescheduledEmail } from "./OrganizerRescheduledEmail";