Skip to content

Commit

Permalink
Merge pull request #755 from Shelf-nu/bookings-bugs-fixes
Browse files Browse the repository at this point in the history
Bookings bugs fixes
  • Loading branch information
DonKoko authored Feb 19, 2024
2 parents 0d15baf + d746d8e commit 8cafe31
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 55 deletions.
22 changes: 11 additions & 11 deletions app/components/errors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ export const ErrorBoundryComponent = ({
}
} else if (error instanceof Error) {
return (
<>
<ErrorContent
title={title ? title : "Oops, something went wrong"}
message={
NODE_ENV === "development"
? error.message
: "Please try again and if the issue persists, contact support"
}
/>
{NODE_ENV === "development" ? <pre>{error.stack}</pre> : null}
</>
<ErrorContent
title={title ? title : "Oops, something went wrong"}
message={
NODE_ENV === "development" ? (
<pre>{error.message}</pre>
) : (
"Please try again and if the issue persists, contact support"
)
}
/>

);
} else {
return (
Expand Down
40 changes: 10 additions & 30 deletions app/emails/bookings-updates-template.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
Button,
Html,
Text,
Link,
Head,
render,
Container,
Expand All @@ -11,6 +9,7 @@ import {
import type { ClientHint } from "~/modules/booking/types";
import { getDateTimeFormatFromHints } from "~/utils/client-hints";
import { SERVER_URL } from "~/utils/env";
import { AdminFooter, UserFooter } from "./components/footers";
import { LogoForEmail } from "./logo";
import { styles } from "./styles";
import type { BookingForEmail } from "./types";
Expand All @@ -21,6 +20,7 @@ interface Props {
assetCount: number;
hints: ClientHint;
hideViewButton?: boolean;
isAdminEmail?: boolean;
}

export function BookingUpdatesEmailTemplate({
Expand All @@ -29,6 +29,7 @@ export function BookingUpdatesEmailTemplate({
hints,
assetCount,
hideViewButton = false,
isAdminEmail = false,
}: Props) {
const fromDate = getDateTimeFormatFromHints(hints, {
dateStyle: "short",
Expand Down Expand Up @@ -95,34 +96,11 @@ export function BookingUpdatesEmailTemplate({
</Button>
)}

<Text style={{ fontSize: "14px", color: "#344054" }}>
This email was sent to{" "}
<Link
style={{ color: "#EF6820" }}
href={`mailto:${booking.custodianUser!.email}`}
>
{booking.custodianUser!.email}
</Link>{" "}
because it is part of the workspace{" "}
<span style={{ color: "#101828", fontWeight: "600" }}>
"{booking.organization.name}"
</span>
. <br /> If you think you weren’t supposed to have received this email
please{" "}
<Link
style={{ color: "#344054", textDecoration: "underline" }}
href={`mailto:${booking.organization.owner.email}`}
>
contact the owner
</Link>{" "}
of the workspace.
</Text>
<Text
style={{ marginBottom: "32px", fontSize: "14px", color: "#344054" }}
>
{" "}
© 2024 Shelf.nu
</Text>
{isAdminEmail ? (
<AdminFooter booking={booking} />
) : (
<UserFooter booking={booking} />
)}
</Container>
</Html>
);
Expand All @@ -138,6 +116,7 @@ export const bookingUpdatesTemplateString = ({
assetCount,
hints,
hideViewButton = false,
isAdminEmail = false,
}: Props) =>
render(
<BookingUpdatesEmailTemplate
Expand All @@ -146,5 +125,6 @@ export const bookingUpdatesTemplateString = ({
assetCount={assetCount}
hints={hints}
hideViewButton={hideViewButton}
isAdminEmail={isAdminEmail}
/>
);
53 changes: 53 additions & 0 deletions app/emails/components/footers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Text, Link } from "@react-email/components";
import type { BookingForEmail } from "../types";

/** Footer used when sending normal user emails */
export const UserFooter = ({ booking }: { booking: BookingForEmail }) => (
<>
<Text style={{ fontSize: "14px", color: "#344054" }}>
This email was sent to{" "}
<Link
style={{ color: "#EF6820" }}
href={`mailto:${booking.custodianUser!.email}`}
>
{booking.custodianUser!.email}
</Link>{" "}
because it is part of the workspace{" "}
<span style={{ color: "#101828", fontWeight: "600" }}>
"{booking.organization.name}"
</span>
. <br /> If you think you weren’t supposed to have received this email
please{" "}
<Link
style={{ color: "#344054", textDecoration: "underline" }}
href={`mailto:${booking.organization.owner.email}`}
>
contact the owner
</Link>{" "}
of the workspace.
</Text>
<Text style={{ marginBottom: "32px", fontSize: "14px", color: "#344054" }}>
{" "}
© 2024 Shelf.nu
</Text>
</>
);

/** Footer used when sending admin user emails */
export const AdminFooter = ({ booking }: { booking: BookingForEmail }) => (
<>
<Text style={{ fontSize: "14px", color: "#344054" }}>
This email was sent to you because you are the OWNER or ADMIN of the
workspace{" "}
<span style={{ color: "#101828", fontWeight: "600" }}>
"{booking.organization.name}"
</span>
. <br /> If you think you weren’t supposed to have received this email
please contact support.
</Text>
<Text style={{ marginBottom: "32px", fontSize: "14px", color: "#344054" }}>
{" "}
© 2024 Shelf.nu
</Text>
</>
);
Loading

0 comments on commit 8cafe31

Please sign in to comment.