Skip to content

Commit 91dc5d9

Browse files
committed
fix: remove imports list
1 parent 52edb4f commit 91dc5d9

File tree

7 files changed

+136
-5
lines changed

7 files changed

+136
-5
lines changed

collection/app/(app)/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { auth } from "@/auth";
22
import { getAcademicYear } from "@/lib/config";
33
import { getAcademicYearsInDB } from "@/lib/crud/academic-year";
4-
import { getImportList } from "@/lib/crud/importCsv";
4+
// import { getImportList } from "@/lib/crud/importCsv";
55
import { Stack, Title } from "@mantine/core";
66
import { redirect } from "next/navigation";
77
import React from "react";
@@ -18,7 +18,7 @@ export default async function Index() {
1818
const currentAcademicYear = await getAcademicYear();
1919
const academicYears = await getAcademicYearsInDB();
2020

21-
const imports = await getImportList();
21+
// const imports = await getImportList();
2222

2323
return (
2424
<Stack gap="lg">
@@ -27,7 +27,7 @@ export default async function Index() {
2727
currentAcademicYear={currentAcademicYear}
2828
validAcaemicYears={academicYears}
2929
/>
30-
<ImportsList imports={imports} />
30+
{/* <ImportsList imports={imports} /> */}
3131
</Stack>
3232
);
3333
}

collection/emails/getDucks.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Outputs a JSON file with the students who have not collected their merch, for use by the mailmerge tool
3+
* to send a reminder to these people.
4+
*
5+
* Created with co-pilot.
6+
*/
7+
import { PrismaClient } from "@prisma/client";
8+
// Load .env file ".env"
9+
import dotenv from "dotenv";
10+
import fs from "fs/promises";
11+
12+
dotenv.config();
13+
14+
const prisma = new PrismaClient();
15+
16+
interface OutputRecord {
17+
to: string;
18+
name: string;
19+
shortcode: string;
20+
subject: string;
21+
cid: string;
22+
orderid: number;
23+
quantity: number;
24+
}
25+
26+
async function getUncollectedPeople() {
27+
const uncollectedOrders = await prisma.variant.findFirst({
28+
where: {
29+
RootItem: {
30+
name: "Duck T-Shirt (White)",
31+
},
32+
variantName: "S (36\")",
33+
},
34+
include: {
35+
OrderItem: {
36+
include: {
37+
Order: {
38+
include: {
39+
ImperialStudent: true,
40+
},
41+
},
42+
},
43+
},
44+
}
45+
})
46+
47+
const outputRecords: OutputRecord[] = [];
48+
49+
const studentMap = new Map<string, OutputRecord>();
50+
51+
if (!uncollectedOrders) {
52+
console.error("No uncollected orders found");
53+
return;
54+
}
55+
56+
for (const orderItem of uncollectedOrders.OrderItem) {
57+
const student = orderItem.Order.ImperialStudent;
58+
const studentKey = student.email;
59+
60+
if (orderItem.collected) {
61+
console.log(`Skipping ${studentKey} as already collected`);
62+
continue;
63+
}
64+
65+
if (!studentMap.has(studentKey)) {
66+
studentMap.set(studentKey, {
67+
to: student.email,
68+
name: `${student.firstName} ${student.lastName}`,
69+
shortcode: student.shortcode,
70+
//itemsToCollect: [],
71+
subject: `Information about the Duck T-Shirt (Small) you ordered`,
72+
cid: student.cid,
73+
orderid: orderItem.orderId,
74+
quantity: orderItem.quantity,
75+
});
76+
}
77+
78+
}
79+
80+
outputRecords.push(...studentMap.values());
81+
82+
await fs.writeFile("data/duck-refund.json", JSON.stringify(outputRecords, null, 2));
83+
}
84+
85+
getUncollectedPeople()
86+
.catch((e) => {
87+
console.error(e);
88+
})
89+
.finally(async () => {
90+
await prisma.$disconnect();
91+
});

collection/emails/getUncollectedPeople.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async function getUncollectedPeople() {
6464
name: `${student.firstName} ${student.lastName}`,
6565
shortcode: student.shortcode,
6666
itemsToCollect: [],
67-
subject: "Collect your remaining DoCSoc Summer Merch",
67+
subject: `FINAL CALL: Collect your DoCSoc${student.shortcode.endsWith("24") ? " (Freshers) " : " "}Merchandise`,
6868
});
6969
}
7070

@@ -78,7 +78,7 @@ async function getUncollectedPeople() {
7878

7979
outputRecords.push(...studentMap.values());
8080

81-
await fs.writeFile("data/reminders.json", JSON.stringify(outputRecords, null, 2));
81+
await fs.writeFile("data/reminders-03.11.24.json", JSON.stringify(outputRecords, null, 2));
8282
}
8383

8484
getUncollectedPeople()

collection/emails/run-duck.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# docsoc-mailmerge generate nunjucks ./data/duck-refund.json templates/duck.njk --name=duck -s json -o output
2+
docsoc-mailmerge send ./output/duck

collection/emails/run-reminder.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# docsoc-mailmerge generate nunjucks ./data/reminders-03.11.24.json templates/reminder-final.njk --name=reminder-final -s json -o output
2+
docsoc-mailmerge send ./output/reminder-final
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Dear {{ name }} ({{ shortcode }}),
2+
3+
We are writing to you because you recently purchased a Duck T-Shirt (Small) from the Union Shop, and are yet to collect it.
4+
5+
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.
6+
7+
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.
8+
9+
The refund should process in 2 weeks - if not, please let us know.
10+
11+
Our apologies for any inconvenience this might have caused you.
12+
13+
Kind regards,
14+
DoCSoc Committee.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Hi {{ name }},
2+
3+
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:
4+
{% for item in itemsToCollect %}
5+
- {{ item.rootitem }} {{ item.variant }} x{{ item.quantity }} {% endfor %}
6+
7+
(note that the above includes freshers' merchandise automatically if you are a 1st year)
8+
9+
Please note that uncollected merch may not be refunded after the last collection.
10+
11+
Please collect your merch at **one of our last collection dates**:
12+
- Monday 4th Nov, 4:15pm-6pm, Huxley 315
13+
- Friday 8th Nov, 3pm-5pm, Huxley 315 (changed from earlier announcement)
14+
15+
**Merchandise will no longer be available for collection after these dates.**
16+
17+
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.
18+
19+
If you have already collected your merch, didn’t buy any merch or otherwise believe this email was sent incorrectly, please let us know!
20+
21+
Kind regards,
22+
DoCSoc Committee.

0 commit comments

Comments
 (0)