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

Seb/volunteer signed up model - all inclusive #11

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
94f82f7
testing pushing branch
sebmendoza Oct 5, 2023
aac53ef
[volunteer-signup-request] - added volunteer_signup model to prisma
vaaranan-y Oct 5, 2023
07dc06f
init-commit
ayush110 Oct 6, 2023
b6c7846
Created volunteer sign up model
ya5er Oct 12, 2023
58d0fc2
Added Status type
ya5er Oct 12, 2023
474c97c
Added volunteer sign up schema
ya5er Oct 12, 2023
21d5c0a
Merge branch 'vaaranan-yaser/create-volunteer-signup-request-model' o…
vaaranan-y Oct 12, 2023
c3274e7
minor fix to status type
vaaranan-y Oct 12, 2023
e23e072
Minor fix to prisma schema
vaaranan-y Oct 12, 2023
c3983b4
Minor fix to TS model
vaaranan-y Oct 12, 2023
707a344
minor user service change
sebmendoza Oct 15, 2023
51c4e6e
merge conflicts
sebmendoza Oct 15, 2023
462c97d
another merge conflict
sebmendoza Oct 15, 2023
3e2e234
Merge branch 'master' into vaaranan-yaser/create-volunteer-signup-req…
vaaranan-y Oct 18, 2023
bf6cc99
Made admin_id a related field (to user id)
vaaranan-y Oct 18, 2023
c691605
added status enum
vaaranan-y Oct 18, 2023
97154c1
Removed mongoose model for volunteer signup
vaaranan-y Oct 18, 2023
42eaad7
Removed unnecessary mongoose enum
vaaranan-y Oct 18, 2023
4c7fa13
Removed v attribute
vaaranan-y Oct 20, 2023
d6dcdf0
changed model name
anmoltyagi1 Oct 26, 2023
5a61cec
Merge pull request #7 from uwblueprint/vaaranan-yaser/create-voluntee…
anmoltyagi1 Oct 26, 2023
589e558
testing pushing branch
sebmendoza Oct 5, 2023
f470ca1
init-commit
ayush110 Oct 6, 2023
23ade67
minor user service change
sebmendoza Oct 15, 2023
feb0fed
created post interface/implentation
sebmendoza Oct 27, 2023
8a25664
Merge branch 'seb/volunteer-signed-up-model' of https://github.com/uw…
sebmendoza Oct 27, 2023
f58afe9
rename implementation to service
ayush110 Oct 27, 2023
265d3a9
feat: create RequestSignUp GET implentation
Oct 29, 2023
56a6ba5
nit: error message change
Oct 29, 2023
9fb8cf8
fix: interface return type/parameters
Oct 29, 2023
6268003
Merge pull request #15 from uwblueprint/aaron/get-volunteer-signed-up…
sebmendoza Oct 29, 2023
4754bba
cleaned up docker errors
sebmendoza Oct 30, 2023
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
50 changes: 39 additions & 11 deletions backend/typescript/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,50 @@ 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[]
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?
meal String?
cookingMethod String?
frequency String?
requestType ServiceRequestType
volunteers volunteerRequestSignUp[]
}

model volunteerPlatformSignUp {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String
firstName String
lastName String
admin user @relation(fields: [admin_id], references: [id])
admin_id String @db.ObjectId
status Status
}

enum Role {
Expand All @@ -43,4 +66,9 @@ enum Role {
enum ServiceRequestType {
SITE
KITCHEN
}
}

enum Status {
PENDING
ACCEPTED
}
58 changes: 58 additions & 0 deletions backend/typescript/services/implementations/requestService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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";

const Logger = logger(__filename);


class RequestSignup implements IRequestSignup {

async getVolunteerRequestSignup(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> {
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<User> {
const updatedUser = await prisma.user.update({
where: {
id: userId,
},
data: updatedData,
});
return updatedUser;
}
}

export default RequestSignup;
1 change: 1 addition & 0 deletions backend/typescript/services/implementations/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class UserService implements IUserService {
throw error;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take out empty line for linting!

}

export default UserService;
27 changes: 27 additions & 0 deletions backend/typescript/services/interfaces/requestService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Prisma, UserCreateInput, UserUpdateInput } from '@prisma/client';

interface IRequestSignup {
/**
* 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.
*/
getVolunteerRequestSignup(requestId: string): Promise<Prisma.volunteerRequestSignUp | null>;

/**
* 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<Prisma.volunteerRequestSignUp>;

/**
* 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<Prisma.User>;
}

export default IRequestSignup;