From 5bc7f0ab83ed310f7b95c1ca133f35a0d8b4cd24 Mon Sep 17 00:00:00 2001 From: Alan Ye <45558679+AlanYe-Dev@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:31:21 +0800 Subject: [PATCH 01/29] feat(clubInfo): check if the user is president --- server/api/cas/info/privilege.get.ts | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 server/api/cas/info/privilege.get.ts diff --git a/server/api/cas/info/privilege.get.ts b/server/api/cas/info/privilege.get.ts new file mode 100644 index 00000000..8847574b --- /dev/null +++ b/server/api/cas/info/privilege.get.ts @@ -0,0 +1,34 @@ +import { PrismaClient } from '@prisma/client' +import * as z from 'zod' + +const prisma = new PrismaClient() + +const requestSchema = z.object({ + clubId: z.number(), +}) + +export default eventHandler(async (event) => { + const { auth } = event.context + + if (!auth.userId) { + setResponseStatus(event, 403) + return + } + + const tsimsStudentId = (await prisma.user.findUnique({ + where: { + id: auth.userId, + }, + }))!.tsimsStudentId + + const requestBody = await readValidatedBody(event, body => requestSchema.parse(body)) + + const club = (await prisma.club.findFirst({ + where: { + id: requestBody.clubId, + presidentByTsimsStudentId: tsimsStudentId, + }, + })) + + return !!club +}) From 6b7d175975d8ece822042f1c72e0fdfd11547b64 Mon Sep 17 00:00:00 2001 From: Alan Ye <45558679+AlanYe-Dev@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:31:33 +0800 Subject: [PATCH 02/29] feat(clubInfo): add component `ViewClubInfo` --- components/custom/CAS/Info/ViewClubInfo.vue | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 components/custom/CAS/Info/ViewClubInfo.vue diff --git a/components/custom/CAS/Info/ViewClubInfo.vue b/components/custom/CAS/Info/ViewClubInfo.vue new file mode 100644 index 00000000..bcd51a42 --- /dev/null +++ b/components/custom/CAS/Info/ViewClubInfo.vue @@ -0,0 +1,53 @@ + + + From 09557f252e64634e381c6e61d9cf050feac72b3c Mon Sep 17 00:00:00 2001 From: Alan Ye <45558679+AlanYe-Dev@users.noreply.github.com> Date: Mon, 15 Apr 2024 19:31:47 +0800 Subject: [PATCH 03/29] feat(clubInfo): add edit page for club details --- pages/cas/clubs/[id]/edit.vue | 144 ++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 pages/cas/clubs/[id]/edit.vue diff --git a/pages/cas/clubs/[id]/edit.vue b/pages/cas/clubs/[id]/edit.vue new file mode 100644 index 00000000..33117fe3 --- /dev/null +++ b/pages/cas/clubs/[id]/edit.vue @@ -0,0 +1,144 @@ + + +