Skip to content

Commit

Permalink
Merge pull request #15 from uwblueprint/aaron/get-volunteer-signed-up…
Browse files Browse the repository at this point in the history
…-model

Aaron/get volunteer signed up model
  • Loading branch information
sebmendoza authored Oct 29, 2023
2 parents f58afe9 + 9fb8cf8 commit 6268003
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 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 request information. Reason = ${getErrorMessage(error)}`);
throw error;
}
}

async postVolunteerRequestSignup(userId: string): Promise<Prisma.volunteerRequestSignUp> {
Expand Down
8 changes: 4 additions & 4 deletions backend/typescript/services/interfaces/requestSignup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ 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 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<Prisma.User | null>;
getRequestSignup(requestId: string): Promise<Prisma.volunteerRequestSignUp | null>;

/**
* Generate a volunteer shift signup request.
Expand Down

0 comments on commit 6268003

Please sign in to comment.