From 265d3a9eff6bb50469ec4e63a24c268fbaa89c89 Mon Sep 17 00:00:00 2001 From: aaronzhang Date: Sun, 29 Oct 2023 16:45:51 -0400 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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.