diff --git a/collection/app/(app)/page.tsx b/collection/app/(app)/page.tsx
index 401c4ce..01baba0 100644
--- a/collection/app/(app)/page.tsx
+++ b/collection/app/(app)/page.tsx
@@ -1,7 +1,7 @@
import { auth } from "@/auth";
import { getAcademicYear } from "@/lib/config";
import { getAcademicYearsInDB } from "@/lib/crud/academic-year";
-import { getImportList } from "@/lib/crud/importCsv";
+// import { getImportList } from "@/lib/crud/importCsv";
import { Stack, Title } from "@mantine/core";
import { redirect } from "next/navigation";
import React from "react";
@@ -18,7 +18,7 @@ export default async function Index() {
const currentAcademicYear = await getAcademicYear();
const academicYears = await getAcademicYearsInDB();
- const imports = await getImportList();
+ // const imports = await getImportList();
return (
@@ -27,7 +27,7 @@ export default async function Index() {
currentAcademicYear={currentAcademicYear}
validAcaemicYears={academicYears}
/>
-
+ {/* */}
);
}
diff --git a/collection/emails/getDucks.ts b/collection/emails/getDucks.ts
new file mode 100644
index 0000000..cebcd60
--- /dev/null
+++ b/collection/emails/getDucks.ts
@@ -0,0 +1,91 @@
+/**
+ * Outputs a JSON file with the students who have not collected their merch, for use by the mailmerge tool
+ * to send a reminder to these people.
+ *
+ * Created with co-pilot.
+ */
+import { PrismaClient } from "@prisma/client";
+// Load .env file ".env"
+import dotenv from "dotenv";
+import fs from "fs/promises";
+
+dotenv.config();
+
+const prisma = new PrismaClient();
+
+interface OutputRecord {
+ to: string;
+ name: string;
+ shortcode: string;
+ subject: string;
+ cid: string;
+ orderid: number;
+ quantity: number;
+}
+
+async function getUncollectedPeople() {
+ const uncollectedOrders = await prisma.variant.findFirst({
+ where: {
+ RootItem: {
+ name: "Duck T-Shirt (White)",
+ },
+ variantName: "S (36\")",
+ },
+ include: {
+ OrderItem: {
+ include: {
+ Order: {
+ include: {
+ ImperialStudent: true,
+ },
+ },
+ },
+ },
+ }
+ })
+
+ const outputRecords: OutputRecord[] = [];
+
+ const studentMap = new Map();
+
+ if (!uncollectedOrders) {
+ console.error("No uncollected orders found");
+ return;
+ }
+
+ for (const orderItem of uncollectedOrders.OrderItem) {
+ const student = orderItem.Order.ImperialStudent;
+ const studentKey = student.email;
+
+ if (orderItem.collected) {
+ console.log(`Skipping ${studentKey} as already collected`);
+ continue;
+ }
+
+ if (!studentMap.has(studentKey)) {
+ studentMap.set(studentKey, {
+ to: student.email,
+ name: `${student.firstName} ${student.lastName}`,
+ shortcode: student.shortcode,
+ //itemsToCollect: [],
+ subject: `Information about the Duck T-Shirt (Small) you ordered`,
+ cid: student.cid,
+ orderid: orderItem.orderId,
+ quantity: orderItem.quantity,
+ });
+ }
+
+ }
+
+ outputRecords.push(...studentMap.values());
+
+ await fs.writeFile("data/duck-refund.json", JSON.stringify(outputRecords, null, 2));
+}
+
+getUncollectedPeople()
+ .catch((e) => {
+ console.error(e);
+ })
+ .finally(async () => {
+ await prisma.$disconnect();
+ });
diff --git a/collection/emails/getUncollectedPeople.ts b/collection/emails/getUncollectedPeople.ts
index 3819dab..566125a 100644
--- a/collection/emails/getUncollectedPeople.ts
+++ b/collection/emails/getUncollectedPeople.ts
@@ -64,7 +64,7 @@ async function getUncollectedPeople() {
name: `${student.firstName} ${student.lastName}`,
shortcode: student.shortcode,
itemsToCollect: [],
- subject: "Collect your remaining DoCSoc Summer Merch",
+ subject: `FINAL CALL: Collect your DoCSoc${student.shortcode.endsWith("24") ? " (Freshers) " : " "}Merchandise`,
});
}
@@ -78,7 +78,7 @@ async function getUncollectedPeople() {
outputRecords.push(...studentMap.values());
- await fs.writeFile("data/reminders.json", JSON.stringify(outputRecords, null, 2));
+ await fs.writeFile("data/reminders-03.11.24.json", JSON.stringify(outputRecords, null, 2));
}
getUncollectedPeople()
diff --git a/collection/emails/run-duck.sh b/collection/emails/run-duck.sh
new file mode 100755
index 0000000..02670d3
--- /dev/null
+++ b/collection/emails/run-duck.sh
@@ -0,0 +1,2 @@
+# docsoc-mailmerge generate nunjucks ./data/duck-refund.json templates/duck.njk --name=duck -s json -o output
+docsoc-mailmerge send ./output/duck
\ No newline at end of file
diff --git a/collection/emails/run-reminder.sh b/collection/emails/run-reminder.sh
new file mode 100755
index 0000000..6e8d040
--- /dev/null
+++ b/collection/emails/run-reminder.sh
@@ -0,0 +1,2 @@
+# docsoc-mailmerge generate nunjucks ./data/reminders-03.11.24.json templates/reminder-final.njk --name=reminder-final -s json -o output
+docsoc-mailmerge send ./output/reminder-final
\ No newline at end of file
diff --git a/collection/emails/templates/duck.njk b/collection/emails/templates/duck.njk
new file mode 100644
index 0000000..6d92733
--- /dev/null
+++ b/collection/emails/templates/duck.njk
@@ -0,0 +1,14 @@
+Dear {{ name }} ({{ shortcode }}),
+
+We are writing to you because you recently purchased a Duck T-Shirt (Small) from the Union Shop, and are yet to collect it.
+
+Unfortunately, we must regret to inform you that we do not have enough t-shirts to fulfil your order, due to an error when counting stock.
+
+As such, we are unable to provide you with the t-shirt you ordered. We are very sorry for this mistake, and we will be refunding you the full amount you paid for the t-shirt.
+
+The refund should process in 2 weeks - if not, please let us know.
+
+Our apologies for any inconvenience this might have caused you.
+
+Kind regards,
+DoCSoc Committee.
\ No newline at end of file
diff --git a/collection/emails/templates/reminder-final.njk b/collection/emails/templates/reminder-final.njk
new file mode 100644
index 0000000..e06ebed
--- /dev/null
+++ b/collection/emails/templates/reminder-final.njk
@@ -0,0 +1,22 @@
+Hi {{ name }},
+
+You are yet to collect the following DoCSoc merchandise that you bought from the Union Shop, either in this academic year or last academic year:
+{% for item in itemsToCollect %}
+- {{ item.rootitem }} {{ item.variant }} x{{ item.quantity }} {% endfor %}
+
+(note that the above includes freshers' merchandise automatically if you are a 1st year)
+
+Please note that uncollected merch may not be refunded after the last collection.
+
+Please collect your merch at **one of our last collection dates**:
+- Monday 4th Nov, 4:15pm-6pm, Huxley 315
+- Friday 8th Nov, 3pm-5pm, Huxley 315 (changed from earlier announcement)
+
+**Merchandise will no longer be available for collection after these dates.**
+
+If you are unable to collect your merch, please let us know before the last collection. You can also arrange for a friend to collect your merch on your behalf, so long as you provide us with their shortcode in advance by replying to this email.
+
+If you have already collected your merch, didn’t buy any merch or otherwise believe this email was sent incorrectly, please let us know!
+
+Kind regards,
+DoCSoc Committee.
\ No newline at end of file