From 94f82f75af31d4f438837f6e3b3d2258b302070b Mon Sep 17 00:00:00 2001 From: Sebastian Mendoza Date: Thu, 5 Oct 2023 19:28:37 -0400 Subject: [PATCH 01/25] testing pushing branch --- backend/typescript/prisma/schema.prisma | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index c9b9861..ebc6be3 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -12,11 +12,19 @@ model test { } model users { - id String @id @default(auto()) @map("_id") @db.ObjectId - v Int @map("__v") - authId String - email String - firstName String - lastName String - role String - } \ No newline at end of file + id String @id @default(auto()) @map("_id") @db.ObjectId + v Int @map("__v") + authId String + email String + firstName String + lastName String + role String +} + +model users_signed_up { + id String @id @default(auto()) @map("_id") @db.ObjectId + email String + firstName String + lastName String + adminID String +} From aac53ef98d1828f3abe292e7e048c8453a871ac9 Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Thu, 5 Oct 2023 19:40:02 -0400 Subject: [PATCH 02/25] [volunteer-signup-request] - added volunteer_signup model to prisma --- backend/typescript/prisma/schema.prisma | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index c9b9861..93facc7 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -12,11 +12,23 @@ model test { } model users { - id String @id @default(auto()) @map("_id") @db.ObjectId - v Int @map("__v") - authId String - email String - firstName String - lastName String - role String - } \ No newline at end of file + id String @id @default(auto()) @map("_id") @db.ObjectId + v Int @map("__v") + authId String + email String + firstName String + lastName String + role String +} + +model volunteer_signup { + id String @id @default(auto()) @map("_id") @db.ObjectId + v Int @map("__v") + authId String + email String + firstName String + lastName String + role String + admin_id String + status String +} From 07dc06f27581e895fc8b1c40b39a78dbc3f4fe4e Mon Sep 17 00:00:00 2001 From: ayush110 <67121244+ayush110@users.noreply.github.com> Date: Thu, 5 Oct 2023 20:33:23 -0400 Subject: [PATCH 03/25] init-commit --- backend/typescript/prisma/schema.prisma | 28 ++++++++++--------- backend/typescript/rest/userRoutes.ts | 17 +++++++++++ .../services/implementations/userService.ts | 20 +++++++++++++ .../services/interfaces/userService.ts | 12 ++++++++ 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index ebc6be3..6e5888b 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -12,19 +12,21 @@ model test { } model users { - id String @id @default(auto()) @map("_id") @db.ObjectId - v Int @map("__v") - authId String - email String - firstName String - lastName String - role String + id String @id @default(auto()) @map("_id") @db.ObjectId + v Int @map("__v") + authId String + email String + firstName String + lastName String + role String + volunteers_signed_up volunteers_signed_up[] } -model users_signed_up { - id String @id @default(auto()) @map("_id") @db.ObjectId - email String - firstName String - lastName String - adminID String +model volunteers_signed_up { + id String @id @default(auto()) @map("_id") @db.ObjectId + request_id String + //request request @relation(fields: [user_id], references: [id]) + user users @relation(fields: [user_id], references: [id]) + user_id String @db.ObjectId + complete Boolean @default(false) } diff --git a/backend/typescript/rest/userRoutes.ts b/backend/typescript/rest/userRoutes.ts index ddbcace..b191680 100644 --- a/backend/typescript/rest/userRoutes.ts +++ b/backend/typescript/rest/userRoutes.ts @@ -163,4 +163,21 @@ userRouter.delete("/", async (req, res) => { .json({ error: "Must supply one of userId or email as query parameter." }); }); +userRouter.post("/volunteer-signed-up", createUserDtoValidator, async (req, res) => { + try { + const { requestId, userId } = req.body + + const newVolunteerSignedUp = await userService.createSignedUpVolunteers( + requestId, + userId, + ); + + // await authService.sendEmailVerificationLink(req.body.email); + + res.status(201).json(newVolunteerSignedUp); + } catch (error: unknown) { + res.status(500).json({ error: getErrorMessage(error) }); + } +}); + export default userRouter; diff --git a/backend/typescript/services/implementations/userService.ts b/backend/typescript/services/implementations/userService.ts index 87a43d7..aa95193 100644 --- a/backend/typescript/services/implementations/userService.ts +++ b/backend/typescript/services/implementations/userService.ts @@ -346,6 +346,26 @@ class UserService implements IUserService { throw error; } } + + async createSignedUpVolunteer( + userId: string, + requestId: string, + ): Promise { + try { + const newSignedUpVolunteer = await prisma.volunteers_signed_up.create({ + data: { + userId, + requestId + } + }) + } + catch (error: unknown) { + Logger.error(`Failed to create user. Reason = ${getErrorMessage(error)}`); + throw error; + } + + } + } export default UserService; diff --git a/backend/typescript/services/interfaces/userService.ts b/backend/typescript/services/interfaces/userService.ts index 7b00d01..3fc855b 100644 --- a/backend/typescript/services/interfaces/userService.ts +++ b/backend/typescript/services/interfaces/userService.ts @@ -91,6 +91,18 @@ interface IUserService { * @throws Error if user deletion fails */ deleteUserByEmail(email: string): Promise; + + /** + * Create a volunteer signed up \ + * @param userId users ID + * @param requestId ID of request from volunteer + * @returns a UserDTO with the created user's information + * @throws Error if user creation fails + */ + createSignedUpVolunteer( + userId: string, + requestId: string, + ): Promise; } export default IUserService; From b6c78461e2b0c7d9047ef70075740644a99a2dd5 Mon Sep 17 00:00:00 2001 From: Yaser Date: Wed, 11 Oct 2023 22:42:10 -0400 Subject: [PATCH 04/25] Created volunteer sign up model --- .../models/volunteerSignUp.model.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 backend/typescript/models/volunteerSignUp.model.ts diff --git a/backend/typescript/models/volunteerSignUp.model.ts b/backend/typescript/models/volunteerSignUp.model.ts new file mode 100644 index 0000000..0f98e9c --- /dev/null +++ b/backend/typescript/models/volunteerSignUp.model.ts @@ -0,0 +1,42 @@ +import mongoose, { Schema, Document } from "mongoose"; + +import { Status } from "../types"; + +export interface VolunteerSignUp extends Document { + uuid: string; + firstName: string; + lastName: string; + email: string; + admin_id: string; + status: Status; +} + +const VolunteerSignUpSchema: Schema = new Schema({ + uuid: { + type: String, + required: true, + }, + firstName: { + type: String, + required: true, + }, + lastName: { + type: String, + required: true, + }, + email: { + type: String, + required: true, + }, + admin_id: { + type: String, + required: true, + }, + status: { + type: String, + required: true, + enum: ["Pending", "Accepted"], + }, +}); + +export default mongoose.model("VolunteerSignUp", VolunteerSignUpSchema); From 58d0fc214840936a71b234a1dbda3fe88c26f3e3 Mon Sep 17 00:00:00 2001 From: Yaser Date: Wed, 11 Oct 2023 22:43:16 -0400 Subject: [PATCH 05/25] Added Status type --- backend/typescript/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/typescript/types.ts b/backend/typescript/types.ts index 58de877..01ba938 100644 --- a/backend/typescript/types.ts +++ b/backend/typescript/types.ts @@ -1,5 +1,8 @@ export type Role = "User" | "Admin"; +export type Status = "Pending" | "Accepted"; + + export type Token = { accessToken: string; refreshToken: string; From 474c97c82f01df273093bf9cb9c7a777d0619173 Mon Sep 17 00:00:00 2001 From: Yaser Date: Wed, 11 Oct 2023 22:44:03 -0400 Subject: [PATCH 06/25] Added volunteer sign up schema --- backend/typescript/prisma/schema.prisma | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index c9b9861..14b7103 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -19,4 +19,14 @@ model users { firstName String lastName String role String - } \ No newline at end of file + } + +model volunteerSignUp { + id String @id @default(auto()) @map("_id") @db.ObjectId + uuid String + firstName String + lastName String + email String + admin_id String + status String +} \ No newline at end of file From c3274e7ece4f858189e8520c66fd36c42265798d Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Thu, 12 Oct 2023 15:00:33 -0400 Subject: [PATCH 07/25] minor fix to status type --- backend/typescript/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/typescript/types.ts b/backend/typescript/types.ts index 01ba938..7e82da6 100644 --- a/backend/typescript/types.ts +++ b/backend/typescript/types.ts @@ -1,6 +1,6 @@ export type Role = "User" | "Admin"; -export type Status = "Pending" | "Accepted"; +export type Status = "PENDING" | "ACCEPTED"; export type Token = { From e23e072b5a77036731964e28e7ceee1e936e07a9 Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Thu, 12 Oct 2023 15:05:59 -0400 Subject: [PATCH 08/25] Minor fix to prisma schema --- backend/typescript/prisma/schema.prisma | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index 93facc7..bd5ed02 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -21,14 +21,12 @@ model users { role String } -model volunteer_signup { +model volunteerSignUp { id String @id @default(auto()) @map("_id") @db.ObjectId v Int @map("__v") - authId String email String firstName String lastName String - role String admin_id String status String } From c3983b48a28e6181d34476156572abacbbde3a6b Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Thu, 12 Oct 2023 15:08:02 -0400 Subject: [PATCH 09/25] Minor fix to TS model --- backend/typescript/models/volunteerSignUp.model.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/backend/typescript/models/volunteerSignUp.model.ts b/backend/typescript/models/volunteerSignUp.model.ts index 0f98e9c..5a84436 100644 --- a/backend/typescript/models/volunteerSignUp.model.ts +++ b/backend/typescript/models/volunteerSignUp.model.ts @@ -3,7 +3,7 @@ import mongoose, { Schema, Document } from "mongoose"; import { Status } from "../types"; export interface VolunteerSignUp extends Document { - uuid: string; + id: string; firstName: string; lastName: string; email: string; @@ -12,10 +12,6 @@ export interface VolunteerSignUp extends Document { } const VolunteerSignUpSchema: Schema = new Schema({ - uuid: { - type: String, - required: true, - }, firstName: { type: String, required: true, @@ -35,7 +31,7 @@ const VolunteerSignUpSchema: Schema = new Schema({ status: { type: String, required: true, - enum: ["Pending", "Accepted"], + enum: ["PENDING", "ACCEPTED"], }, }); From 707a344051c7dc5d2e679daccb585a17b741fa61 Mon Sep 17 00:00:00 2001 From: Sebastian Mendoza Date: Sun, 15 Oct 2023 19:37:48 -0400 Subject: [PATCH 10/25] minor user service change --- backend/typescript/services/implementations/userService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/typescript/services/implementations/userService.ts b/backend/typescript/services/implementations/userService.ts index aa95193..3ea2880 100644 --- a/backend/typescript/services/implementations/userService.ts +++ b/backend/typescript/services/implementations/userService.ts @@ -354,8 +354,8 @@ class UserService implements IUserService { try { const newSignedUpVolunteer = await prisma.volunteers_signed_up.create({ data: { - userId, - requestId + user_id: userId, + request_id: requestId } }) } From bf6cc9951b4d394671f75631d9d668950c6dab8e Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Tue, 17 Oct 2023 20:58:26 -0400 Subject: [PATCH 11/25] Made admin_id a related field (to user id) --- backend/typescript/prisma/schema.prisma | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index 533b431..74711cd 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -12,13 +12,14 @@ model test { } model user { - id String @id @default(auto()) @map("_id") @db.ObjectId + id String @id @default(auto()) @map("_id") @db.ObjectId authId String email String firstName String lastName String role Role serviceRequests serviceRequest[] + volunteerSignUp volunteerSignUp[] } model serviceRequest { @@ -35,6 +36,17 @@ model serviceRequest { requestType ServiceRequestType } +model volunteerSignUp { + id String @id @default(auto()) @map("_id") @db.ObjectId + v Int @map("__v") + email String + firstName String + lastName String + admin user @relation(fields: [admin_id], references: [id]) + admin_id String @db.ObjectId + status String +} + enum Role { VOLUNTEER ADMIN From c69160573d0d302d0e03dabacfb8b26c6a1bf962 Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Tue, 17 Oct 2023 21:00:12 -0400 Subject: [PATCH 12/25] added status enum --- backend/typescript/prisma/schema.prisma | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index 74711cd..3634efe 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -44,7 +44,7 @@ model volunteerSignUp { lastName String admin user @relation(fields: [admin_id], references: [id]) admin_id String @db.ObjectId - status String + status Status } enum Role { @@ -56,3 +56,8 @@ enum ServiceRequestType { SITE KITCHEN } + +enum Status { + PENDING + ACCEPTED +} From 97154c10581ee2d039d7c487e48622c8e12f2cee Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Tue, 17 Oct 2023 21:01:15 -0400 Subject: [PATCH 13/25] Removed mongoose model for volunteer signup --- .../models/volunteerSignUp.model.ts | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 backend/typescript/models/volunteerSignUp.model.ts diff --git a/backend/typescript/models/volunteerSignUp.model.ts b/backend/typescript/models/volunteerSignUp.model.ts deleted file mode 100644 index 5a84436..0000000 --- a/backend/typescript/models/volunteerSignUp.model.ts +++ /dev/null @@ -1,38 +0,0 @@ -import mongoose, { Schema, Document } from "mongoose"; - -import { Status } from "../types"; - -export interface VolunteerSignUp extends Document { - id: string; - firstName: string; - lastName: string; - email: string; - admin_id: string; - status: Status; -} - -const VolunteerSignUpSchema: Schema = new Schema({ - firstName: { - type: String, - required: true, - }, - lastName: { - type: String, - required: true, - }, - email: { - type: String, - required: true, - }, - admin_id: { - type: String, - required: true, - }, - status: { - type: String, - required: true, - enum: ["PENDING", "ACCEPTED"], - }, -}); - -export default mongoose.model("VolunteerSignUp", VolunteerSignUpSchema); From 42eaad7c805b7a7ca5c5c06b14eee86f49c02d11 Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Tue, 17 Oct 2023 21:03:44 -0400 Subject: [PATCH 14/25] Removed unnecessary mongoose enum --- backend/typescript/types.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/typescript/types.ts b/backend/typescript/types.ts index 7e82da6..58de877 100644 --- a/backend/typescript/types.ts +++ b/backend/typescript/types.ts @@ -1,8 +1,5 @@ export type Role = "User" | "Admin"; -export type Status = "PENDING" | "ACCEPTED"; - - export type Token = { accessToken: string; refreshToken: string; From 4c7fa134b514ec482679bfb52233821ab59ad4e6 Mon Sep 17 00:00:00 2001 From: Vaaranan Yogalingam Date: Thu, 19 Oct 2023 20:08:01 -0400 Subject: [PATCH 15/25] Removed v attribute --- backend/typescript/prisma/schema.prisma | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index 3634efe..758867c 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -38,7 +38,6 @@ model serviceRequest { model volunteerSignUp { id String @id @default(auto()) @map("_id") @db.ObjectId - v Int @map("__v") email String firstName String lastName String From d6dcdf0b46ccd5a53bbb6efbc20535ffc159d0b1 Mon Sep 17 00:00:00 2001 From: Anmol Tyagi Date: Thu, 26 Oct 2023 19:26:59 -0400 Subject: [PATCH 16/25] changed model name --- backend/typescript/prisma/schema.prisma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index 758867c..f37497c 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -19,7 +19,7 @@ model user { lastName String role Role serviceRequests serviceRequest[] - volunteerSignUp volunteerSignUp[] + volunteerSignUp volunteerPlatformSignUp[] } model serviceRequest { @@ -36,7 +36,7 @@ model serviceRequest { requestType ServiceRequestType } -model volunteerSignUp { +model volunteerPlatformSignUp { id String @id @default(auto()) @map("_id") @db.ObjectId email String firstName String From 589e558d2a5910b1b771f5c7769c9f57ad93c38c Mon Sep 17 00:00:00 2001 From: Sebastian Mendoza Date: Thu, 5 Oct 2023 19:28:37 -0400 Subject: [PATCH 17/25] testing pushing branch --- backend/typescript/prisma/schema.prisma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index f37497c..0340b69 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -12,7 +12,7 @@ model test { } model user { - id String @id @default(auto()) @map("_id") @db.ObjectId + id String @id @default(auto()) @map("_id") @db.ObjectId authId String email String firstName String From f470ca176ebe6c3c841316c97b4231ce5f19c985 Mon Sep 17 00:00:00 2001 From: ayush110 <67121244+ayush110@users.noreply.github.com> Date: Thu, 5 Oct 2023 20:33:23 -0400 Subject: [PATCH 18/25] init-commit --- backend/typescript/rest/userRoutes.ts | 17 ++++++++++++++++ .../services/implementations/userService.ts | 20 +++++++++++++++++++ .../services/interfaces/userService.ts | 12 +++++++++++ 3 files changed, 49 insertions(+) diff --git a/backend/typescript/rest/userRoutes.ts b/backend/typescript/rest/userRoutes.ts index ddbcace..b191680 100644 --- a/backend/typescript/rest/userRoutes.ts +++ b/backend/typescript/rest/userRoutes.ts @@ -163,4 +163,21 @@ userRouter.delete("/", async (req, res) => { .json({ error: "Must supply one of userId or email as query parameter." }); }); +userRouter.post("/volunteer-signed-up", createUserDtoValidator, async (req, res) => { + try { + const { requestId, userId } = req.body + + const newVolunteerSignedUp = await userService.createSignedUpVolunteers( + requestId, + userId, + ); + + // await authService.sendEmailVerificationLink(req.body.email); + + res.status(201).json(newVolunteerSignedUp); + } catch (error: unknown) { + res.status(500).json({ error: getErrorMessage(error) }); + } +}); + export default userRouter; diff --git a/backend/typescript/services/implementations/userService.ts b/backend/typescript/services/implementations/userService.ts index 87a43d7..aa95193 100644 --- a/backend/typescript/services/implementations/userService.ts +++ b/backend/typescript/services/implementations/userService.ts @@ -346,6 +346,26 @@ class UserService implements IUserService { throw error; } } + + async createSignedUpVolunteer( + userId: string, + requestId: string, + ): Promise { + try { + const newSignedUpVolunteer = await prisma.volunteers_signed_up.create({ + data: { + userId, + requestId + } + }) + } + catch (error: unknown) { + Logger.error(`Failed to create user. Reason = ${getErrorMessage(error)}`); + throw error; + } + + } + } export default UserService; diff --git a/backend/typescript/services/interfaces/userService.ts b/backend/typescript/services/interfaces/userService.ts index 7b00d01..3fc855b 100644 --- a/backend/typescript/services/interfaces/userService.ts +++ b/backend/typescript/services/interfaces/userService.ts @@ -91,6 +91,18 @@ interface IUserService { * @throws Error if user deletion fails */ deleteUserByEmail(email: string): Promise; + + /** + * Create a volunteer signed up \ + * @param userId users ID + * @param requestId ID of request from volunteer + * @returns a UserDTO with the created user's information + * @throws Error if user creation fails + */ + createSignedUpVolunteer( + userId: string, + requestId: string, + ): Promise; } export default IUserService; From 23ade678e26ac1730d8b569f92dd8b9bff57c067 Mon Sep 17 00:00:00 2001 From: Sebastian Mendoza Date: Sun, 15 Oct 2023 19:37:48 -0400 Subject: [PATCH 19/25] minor user service change --- backend/typescript/services/implementations/userService.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/typescript/services/implementations/userService.ts b/backend/typescript/services/implementations/userService.ts index aa95193..3ea2880 100644 --- a/backend/typescript/services/implementations/userService.ts +++ b/backend/typescript/services/implementations/userService.ts @@ -354,8 +354,8 @@ class UserService implements IUserService { try { const newSignedUpVolunteer = await prisma.volunteers_signed_up.create({ data: { - userId, - requestId + user_id: userId, + request_id: requestId } }) } From feb0fedb22c2ea103b31f9a412c0d8bdd1b907ff Mon Sep 17 00:00:00 2001 From: Sebastian Mendoza Date: Fri, 27 Oct 2023 11:31:01 -0400 Subject: [PATCH 20/25] created post interface/implentation --- backend/typescript/prisma/schema.prisma | 34 ++++++++----- .../services/implementations/requestSignup.ts | 49 +++++++++++++++++++ .../services/implementations/userService.ts | 19 ------- .../services/interfaces/requestSignup.ts | 27 ++++++++++ 4 files changed, 99 insertions(+), 30 deletions(-) create mode 100644 backend/typescript/services/implementations/requestSignup.ts create mode 100644 backend/typescript/services/interfaces/requestSignup.ts diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index 0340b69..b3ec2c6 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -12,21 +12,32 @@ model test { } model user { - id String @id @default(auto()) @map("_id") @db.ObjectId - authId String - email String - firstName String - lastName String - role Role - serviceRequests serviceRequest[] - volunteerSignUp volunteerPlatformSignUp[] + id String @id @default(auto()) @map("_id") @db.ObjectId + authId String + email String + firstName String + lastName String + role Role + serviceRequests serviceRequest[] + volunteerRequestSignUp volunteerRequestSignUp[] + volunteerPlatformSignUp volunteerPlatformSignUp[] +} + +model volunteerRequestSignUp { + id String @id @default(auto()) @map("_id") @db.ObjectId + user user @relation(fields: [userId], references: [id]) + userId String @db.ObjectId + complete Boolean @default(false) + + serviceRequest serviceRequest @relation(fields: [serviceRequestId], references: [id]) + serviceRequestId String @db.ObjectId } model serviceRequest { - id String @id @default(auto()) @map("_id") @db.ObjectId + id String @id @default(auto()) @map("_id") @db.ObjectId requestName String - requester user @relation(fields: [requesterId], references: [id]) - requesterId String @db.ObjectId + requester user @relation(fields: [requesterId], references: [id]) + requesterId String @db.ObjectId location String shiftTime DateTime? description String? @@ -34,6 +45,7 @@ model serviceRequest { cookingMethod String? frequency String? requestType ServiceRequestType + volunteers volunteerRequestSignUp[] } model volunteerPlatformSignUp { diff --git a/backend/typescript/services/implementations/requestSignup.ts b/backend/typescript/services/implementations/requestSignup.ts new file mode 100644 index 0000000..bd40e8a --- /dev/null +++ b/backend/typescript/services/implementations/requestSignup.ts @@ -0,0 +1,49 @@ +import { Prisma, User, PrismaClient } from '@prisma/client'; +import IRequestSignup from '../interfaces/requestSignup'; +import prisma from "../../prisma"; +import logger from "../../utilities/logger"; +import { getErrorMessage } from "../../utilities/errorUtils"; + +const Logger = logger(__filename); + + +class RequestSignup implements IRequestSignup { + private prisma: PrismaClient; + + async getRequestSignup(userId: string): Promise { + const user = await this.prisma.user.findUnique({ + where: { + id: userId, + }, + }); + return user; + } + + async postVolunteerRequestSignup(userId: string): Promise { + try { + const newVolunteerRequestSignup = await prisma.volunteerRequestSignUp.create({ + data: { + userId: userId, + } + }) + + return newVolunteerRequestSignup; + } + catch (error: unknown) { + Logger.error(`Failed to create user. Reason = ${getErrorMessage(error)}`); + throw error; + } + } + + async editRequestSignup(userId: string, updatedData: Prisma.UserUpdateInput): Promise { + const updatedUser = await this.prisma.user.update({ + where: { + id: userId, + }, + data: updatedData, + }); + return updatedUser; + } +} + +export default RequestSignup; diff --git a/backend/typescript/services/implementations/userService.ts b/backend/typescript/services/implementations/userService.ts index 3ea2880..d69f911 100644 --- a/backend/typescript/services/implementations/userService.ts +++ b/backend/typescript/services/implementations/userService.ts @@ -347,25 +347,6 @@ class UserService implements IUserService { } } - async createSignedUpVolunteer( - userId: string, - requestId: string, - ): Promise { - try { - const newSignedUpVolunteer = await prisma.volunteers_signed_up.create({ - data: { - user_id: userId, - request_id: requestId - } - }) - } - catch (error: unknown) { - Logger.error(`Failed to create user. Reason = ${getErrorMessage(error)}`); - throw error; - } - - } - } export default UserService; diff --git a/backend/typescript/services/interfaces/requestSignup.ts b/backend/typescript/services/interfaces/requestSignup.ts new file mode 100644 index 0000000..f6ae5e3 --- /dev/null +++ b/backend/typescript/services/interfaces/requestSignup.ts @@ -0,0 +1,27 @@ +import { Prisma, UserCreateInput, UserUpdateInput } from '@prisma/client'; + +interface IRequestSignup { + /** + * Get user information by their unique ID. + * @param userId - The unique identifier of the user. + * @returns A promise that resolves to user data or null if not found. + */ + getRequestSignup(userId: string): Promise; + + /** + * Generate a volunteer shift signup request. + * @param userId - The unique identifier of the user associated with the request. + * @returns A promise that resolves to the newly generated request. + */ + postVolunteerRequestSignup(userID: string): Promise; + + /** + * Update user information based on their unique ID. + * @param userId - The unique identifier of the user to be updated. + * @param updatedData - The data to update the user's information. + * @returns A promise that resolves to the updated user. + */ + editRequestSignup(userId: string, updatedData: UserUpdateInput): Promise; +} + +export default IRequestSignup; From f58afe9ede45b001f5e5592abf9fe69e991b7e29 Mon Sep 17 00:00:00 2001 From: ayush110 <67121244+ayush110@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:49:14 -0400 Subject: [PATCH 21/25] rename implementation to service --- .../implementations/{requestSignup.ts => requestService.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename backend/typescript/services/implementations/{requestSignup.ts => requestService.ts} (100%) diff --git a/backend/typescript/services/implementations/requestSignup.ts b/backend/typescript/services/implementations/requestService.ts similarity index 100% rename from backend/typescript/services/implementations/requestSignup.ts rename to backend/typescript/services/implementations/requestService.ts From 265d3a9eff6bb50469ec4e63a24c268fbaa89c89 Mon Sep 17 00:00:00 2001 From: aaronzhang Date: Sun, 29 Oct 2023 16:45:51 -0400 Subject: [PATCH 22/25] feat: create RequestSignUp GET implentation --- .../implementations/requestService.ts | 24 +++++++++++++------ .../services/interfaces/requestSignup.ts | 6 ++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/backend/typescript/services/implementations/requestService.ts b/backend/typescript/services/implementations/requestService.ts index bd40e8a..2100a13 100644 --- a/backend/typescript/services/implementations/requestService.ts +++ b/backend/typescript/services/implementations/requestService.ts @@ -10,13 +10,23 @@ const Logger = logger(__filename); class RequestSignup implements IRequestSignup { private prisma: PrismaClient; - async getRequestSignup(userId: string): Promise { - const user = await this.prisma.user.findUnique({ - where: { - id: userId, - }, - }); - return user; + async getRequestSignup(requestId: string): Promise { + try { + const volunteerRequestSignUpData = await prisma.volunteerRequestSignUp.findUnique({ + where: { + id: requestId, + complete: true, + }, + include: { + user: true, + }, + }); + return volunteerRequestSignUpData; + } + catch (error: unknown) { + Logger.error(`Failed to get user. Reason = ${getErrorMessage(error)}`); + throw error; + } } async postVolunteerRequestSignup(userId: string): Promise { diff --git a/backend/typescript/services/interfaces/requestSignup.ts b/backend/typescript/services/interfaces/requestSignup.ts index f6ae5e3..a523ba7 100644 --- a/backend/typescript/services/interfaces/requestSignup.ts +++ b/backend/typescript/services/interfaces/requestSignup.ts @@ -2,9 +2,9 @@ import { Prisma, UserCreateInput, UserUpdateInput } from '@prisma/client'; interface IRequestSignup { /** - * Get user information by their unique ID. - * @param userId - The unique identifier of the user. - * @returns A promise that resolves to user data or null if not found. + * Get information for a volunteer signup reqeust by their unique ID. + * @param requestId - The unique identifier of the request. + * @returns A promise that resolves to request data or null if not found. */ getRequestSignup(userId: string): Promise; From 56a6ba5e22b0b8656987882429296b9860f133c1 Mon Sep 17 00:00:00 2001 From: aaronzhang Date: Sun, 29 Oct 2023 16:47:47 -0400 Subject: [PATCH 23/25] nit: error message change --- backend/typescript/services/implementations/requestService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/typescript/services/implementations/requestService.ts b/backend/typescript/services/implementations/requestService.ts index 2100a13..f13d6da 100644 --- a/backend/typescript/services/implementations/requestService.ts +++ b/backend/typescript/services/implementations/requestService.ts @@ -24,7 +24,7 @@ class RequestSignup implements IRequestSignup { return volunteerRequestSignUpData; } catch (error: unknown) { - Logger.error(`Failed to get user. Reason = ${getErrorMessage(error)}`); + Logger.error(`Failed to get request information. Reason = ${getErrorMessage(error)}`); throw error; } } From 9fb8cf8bdf0083769b52ed493c28ec49ae42d6f7 Mon Sep 17 00:00:00 2001 From: aaronzhang Date: Sun, 29 Oct 2023 19:55:22 -0400 Subject: [PATCH 24/25] fix: interface return type/parameters --- backend/typescript/services/interfaces/requestSignup.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/typescript/services/interfaces/requestSignup.ts b/backend/typescript/services/interfaces/requestSignup.ts index a523ba7..9068cba 100644 --- a/backend/typescript/services/interfaces/requestSignup.ts +++ b/backend/typescript/services/interfaces/requestSignup.ts @@ -2,11 +2,11 @@ import { Prisma, UserCreateInput, UserUpdateInput } from '@prisma/client'; interface IRequestSignup { /** - * Get information for a volunteer signup reqeust by their unique ID. + * Get information for a volunteer signup reqeust by its unique ID. * @param requestId - The unique identifier of the request. * @returns A promise that resolves to request data or null if not found. */ - getRequestSignup(userId: string): Promise; + getRequestSignup(requestId: string): Promise; /** * Generate a volunteer shift signup request. From 4754bbad7affde868e6efd6e95e81049a52cca42 Mon Sep 17 00:00:00 2001 From: Sebastian Mendoza Date: Sun, 29 Oct 2023 20:13:20 -0400 Subject: [PATCH 25/25] cleaned up docker errors --- backend/typescript/rest/userRoutes.ts | 17 ----------------- .../services/implementations/requestService.ts | 9 ++++----- .../{requestSignup.ts => requestService.ts} | 2 +- .../services/interfaces/userService.ts | 12 ------------ 4 files changed, 5 insertions(+), 35 deletions(-) rename backend/typescript/services/interfaces/{requestSignup.ts => requestService.ts} (91%) diff --git a/backend/typescript/rest/userRoutes.ts b/backend/typescript/rest/userRoutes.ts index b191680..ddbcace 100644 --- a/backend/typescript/rest/userRoutes.ts +++ b/backend/typescript/rest/userRoutes.ts @@ -163,21 +163,4 @@ userRouter.delete("/", async (req, res) => { .json({ error: "Must supply one of userId or email as query parameter." }); }); -userRouter.post("/volunteer-signed-up", createUserDtoValidator, async (req, res) => { - try { - const { requestId, userId } = req.body - - const newVolunteerSignedUp = await userService.createSignedUpVolunteers( - requestId, - userId, - ); - - // await authService.sendEmailVerificationLink(req.body.email); - - res.status(201).json(newVolunteerSignedUp); - } catch (error: unknown) { - res.status(500).json({ error: getErrorMessage(error) }); - } -}); - export default userRouter; diff --git a/backend/typescript/services/implementations/requestService.ts b/backend/typescript/services/implementations/requestService.ts index f13d6da..07594e0 100644 --- a/backend/typescript/services/implementations/requestService.ts +++ b/backend/typescript/services/implementations/requestService.ts @@ -1,5 +1,5 @@ -import { Prisma, User, PrismaClient } from '@prisma/client'; -import IRequestSignup from '../interfaces/requestSignup'; +import { Prisma, User } from '@prisma/client'; +import IRequestSignup from '../interfaces/requestService'; import prisma from "../../prisma"; import logger from "../../utilities/logger"; import { getErrorMessage } from "../../utilities/errorUtils"; @@ -8,9 +8,8 @@ const Logger = logger(__filename); class RequestSignup implements IRequestSignup { - private prisma: PrismaClient; - async getRequestSignup(requestId: string): Promise { + async getVolunteerRequestSignup(requestId: string): Promise { try { const volunteerRequestSignUpData = await prisma.volunteerRequestSignUp.findUnique({ where: { @@ -46,7 +45,7 @@ class RequestSignup implements IRequestSignup { } async editRequestSignup(userId: string, updatedData: Prisma.UserUpdateInput): Promise { - const updatedUser = await this.prisma.user.update({ + const updatedUser = await prisma.user.update({ where: { id: userId, }, diff --git a/backend/typescript/services/interfaces/requestSignup.ts b/backend/typescript/services/interfaces/requestService.ts similarity index 91% rename from backend/typescript/services/interfaces/requestSignup.ts rename to backend/typescript/services/interfaces/requestService.ts index 9068cba..81ecbe7 100644 --- a/backend/typescript/services/interfaces/requestSignup.ts +++ b/backend/typescript/services/interfaces/requestService.ts @@ -6,7 +6,7 @@ interface IRequestSignup { * @param requestId - The unique identifier of the request. * @returns A promise that resolves to request data or null if not found. */ - getRequestSignup(requestId: string): Promise; + getVolunteerRequestSignup(requestId: string): Promise; /** * Generate a volunteer shift signup request. diff --git a/backend/typescript/services/interfaces/userService.ts b/backend/typescript/services/interfaces/userService.ts index 3fc855b..7b00d01 100644 --- a/backend/typescript/services/interfaces/userService.ts +++ b/backend/typescript/services/interfaces/userService.ts @@ -91,18 +91,6 @@ interface IUserService { * @throws Error if user deletion fails */ deleteUserByEmail(email: string): Promise; - - /** - * Create a volunteer signed up \ - * @param userId users ID - * @param requestId ID of request from volunteer - * @returns a UserDTO with the created user's information - * @throws Error if user creation fails - */ - createSignedUpVolunteer( - userId: string, - requestId: string, - ): Promise; } export default IUserService;