Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aaron/get volunteer signed up model #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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