Skip to content

Commit

Permalink
git: merge in main
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampiiiii committed May 9, 2024
2 parents 6e3f8b1 + 2c93d74 commit de61c7b
Show file tree
Hide file tree
Showing 15 changed files with 1,202 additions and 1,011 deletions.
22 changes: 15 additions & 7 deletions apps/anvil/src/email/email.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Injectable, Logger } from "@nestjs/common";
import { InjectQueue } from "@nestjs/bull";
import type { Location } from "@ignis/types/sign_in";
import type { Location, QueueEntry } from "@ignis/types/sign_in";
import type { PartialUser } from "@ignis/types/users";
import { InjectQueue } from "@nestjs/bull";
import { Injectable, Logger } from "@nestjs/common";
import { Queue } from "bull";
import { render } from "jsx-email";
import { z } from "zod";
import { SendEmailSchema } from "./dto/send-email.dto";
import Queued from "./templates/queued";
import { Unqueued } from "./templates/unqueued";
import { WelcomeEmail } from "./templates/welcome";
import { z } from "zod";

@Injectable()
export class EmailService {
Expand Down Expand Up @@ -49,9 +50,16 @@ export class EmailService {
});
}

async sendUnqueuedEmail(recipient: PartialUser, location: Location) {
await this.sendHtml(Unqueued({ ...recipient, location }), {
recipients: [`${recipient.email}@sheffield.ac.uk`],
async sendUnqueuedEmail(place: QueueEntry, location: Location) {
await this.sendHtml(Unqueued({ ...place, location }), {
recipients: [`${place.user.email}@sheffield.ac.uk`],
subject: `Your place in the iForge ${location}`,
});
}

async sendQueuedEmail(place: QueueEntry, location: Location) {
await this.sendHtml(Queued({ ...place, location }), {
recipients: [`${place.user.email}@sheffield.ac.uk`],
subject: `Your place in the iForge ${location}`,
});
}
Expand Down
36 changes: 36 additions & 0 deletions apps/anvil/src/email/templates/queued.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Location, QueueEntry } from "@ignis/types/sign_in";
import { Container, Hr, Text } from "jsx-email";
import * as React from "react";
import { Email } from "../components/heading";
import { Link } from "../components/link";

export function Queued({ id = "0000-0000-0000-0000", location = "{location}" }: QueueEntry & { location: Location }) {
return (
<Email
preview="You're in the queue for the iForge"
title="iForge queue request received"
heading={`You're in the queue for the iForge ${location} is available`}
>
<Hr />
<Container>
<Text>
Please sign in in the next 15 minutes (by{" "}
{new Date(new Date().getTime() + 1000 * 60 * 15).toLocaleTimeString()}
). Otherwise, your place will be given to the next person in the queue.
</Text>

<Text className="text-xs! text-center text-gray-500">
If you no longer require your place please{" "}
<Link
href={`https://iforge.sheffield.ac.uk/${location}/queue/delete/${id}`} // FIXME this doesn't exist yet
>
click here
</Link>{" "}
to cancel.
</Text>
</Container>
</Email>
);
}

export default Queued;
14 changes: 5 additions & 9 deletions apps/anvil/src/email/templates/unqueued.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { Text, Hr, Container } from "jsx-email";
import { QueueEntry } from "@ignis/types/sign_in";
import { Container, Hr, Text } from "jsx-email";
import * as React from "react";
import { Email } from "../components/heading";
import { Link } from "../components/link";
import type { PartialUser } from "@ignis/types/users";

export function Unqueued({
id = "0000-0000-0000-0000",
location = "{location}",
}: PartialUser & { location: string }) {
export function Unqueued({ id = "0000-0000-0000-0000", location = "{location}" }: QueueEntry & { location: string }) {
return (
<Email
preview="You're able to sign in to the iForge"
Expand All @@ -19,14 +16,13 @@ export function Unqueued({
<Text>
Please sign in in the next 15 minutes (by{" "}
{new Date(new Date().getTime() + 1000 * 60 * 15).toLocaleTimeString()}
). Otherwise, your place will be given to the next person in the
queue.
). Otherwise, your place will be given to the next person in the queue.
</Text>

<Text className="text-xs! text-center text-gray-500">
If you no longer require your place please{" "}
<Link
href={`https://iforge.sheffield.ac.uk/${location}/queue/remove/${id}`} // FIXME this doesn't exist yet
href={`https://iforge.sheffield.ac.uk/${location}/queue/delete/${id}`} // FIXME this doesn't exist yet
>
click here
</Link>{" "}
Expand Down
Loading

0 comments on commit de61c7b

Please sign in to comment.