Skip to content

Commit

Permalink
feat: create RequestSignUp GET implentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronzhang committed Oct 29, 2023
1 parent f58afe9 commit 265d3a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
24 changes: 17 additions & 7 deletions backend/typescript/services/implementations/requestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ const Logger = logger(__filename);
class RequestSignup implements IRequestSignup {
private prisma: PrismaClient;

async getRequestSignup(userId: string): Promise<User | null> {
const user = await this.prisma.user.findUnique({
where: {
id: userId,
},
});
return user;
async getRequestSignup(requestId: string): Promise<Prisma.volunteerRequestSignUp | null> {
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<Prisma.volunteerRequestSignUp> {
Expand Down
6 changes: 3 additions & 3 deletions backend/typescript/services/interfaces/requestSignup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Prisma.User | null>;

Expand Down

0 comments on commit 265d3a9

Please sign in to comment.