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 5 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
20 changes: 15 additions & 5 deletions backend/typescript/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,30 @@ model test {
}

model user {
id String @id @default(auto()) @map("_id") @db.ObjectId
id String @id @default(auto()) @map("_id") @db.ObjectId
authId String
email String
firstName String
lastName String
role Role
serviceRequests serviceRequest[]
signedUp volunteers_signed_up[]
}

model volunteers_signed_up {
id String @id @default(auto()) @map("_id") @db.ObjectId
request_id String
//request request @relation(fields: [user_id], references: [id])
user user @relation(fields: [user_id], references: [id])
user_id String @db.ObjectId
complete Boolean @default(false)
}

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?
Expand All @@ -43,4 +53,4 @@ enum Role {
enum ServiceRequestType {
SITE
KITCHEN
}
}
17 changes: 17 additions & 0 deletions backend/typescript/rest/userRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,21 @@ userRouter.delete("/", async (req, res) => {
.json({ error: "Must supply one of userId or email as query parameter." });
});

userRouter.post("/volunteer-signed-up", createUserDtoValidator, async (req, res) => {
try {
const { requestId, userId } = req.body

const newVolunteerSignedUp = await userService.createSignedUpVolunteers(
requestId,
userId,
);

// await authService.sendEmailVerificationLink(req.body.email);

res.status(201).json(newVolunteerSignedUp);
} catch (error: unknown) {
res.status(500).json({ error: getErrorMessage(error) });
}
});

export default userRouter;
20 changes: 20 additions & 0 deletions backend/typescript/services/implementations/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,26 @@ 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!

async createSignedUpVolunteer(
userId: string,
requestId: string,
): Promise<void> {
try {
const newSignedUpVolunteer = await prisma.volunteers_signed_up.create({
data: {
user_id: userId,
request_id: requestId
}
})
}
catch (error: unknown) {
Logger.error(`Failed to create user. Reason = ${getErrorMessage(error)}`);
throw error;
}

}

}

export default UserService;
12 changes: 12 additions & 0 deletions backend/typescript/services/interfaces/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ interface IUserService {
* @throws Error if user deletion fails
*/
deleteUserByEmail(email: string): Promise<void>;

/**
* Create a volunteer signed up \
* @param userId users ID
* @param requestId ID of request from volunteer
* @returns a UserDTO with the created user's information
* @throws Error if user creation fails
*/
createSignedUpVolunteer(
userId: string,
requestId: string,
): Promise<void>;
}

export default IUserService;