-
Notifications
You must be signed in to change notification settings - Fork 0
SSF 97 pantry management backend #76
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
base: main
Are you sure you want to change the base?
Conversation
|
See slack comment |
313c63d to
2577fbe
Compare
2577fbe to
265bad6
Compare
dburkhart07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these initial changes, also see message I sent you.
| yarn-error.log | ||
| testem.log | ||
| /typings | ||
| .nx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here? Can we get rid of it?
| pantries?: Pantry[]; | ||
| } | ||
|
|
||
| export interface UserDto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be deleted either I dont think.
…com/Code-4-Community/ssf into sk/SSF-97-pantry-management-backend
…k/SSF-97-pantry-management-backend
…com/Code-4-Community/ssf into sk/SSF-97-pantry-management-backend
dburkhart07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few initial things. Also, I do not see the second half of the ticket requirement to make a new endpoint for this: Add a new endpoint to overwrite the set of volunteers assigned to a pantry with a new set of volunteers for intended use case
apps/backend/src/pantries/types.ts
Outdated
| email: string; | ||
| phone: string; | ||
| }; | ||
| refrigeratedDonation: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the enum
apps/backend/src/pantries/types.ts
Outdated
| }; | ||
| refrigeratedDonation: string; | ||
| allergenClients: string; | ||
| status: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| } | ||
|
|
||
|
|
||
| async getApprovedPantriesWithVolunteers(): Promise<ApprovedPantryResponse[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in the type.ts file, this will need to change too.
| return this.pantriesService.getPendingPantries(); | ||
| } | ||
|
|
||
| @Get('/approved') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should write a test for this as well.
…com/Code-4-Community/ssf into sk/SSF-97-pantry-management-backend
dburkhart07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few other small things and it should be good.
apps/backend/src/pantries/types.ts
Outdated
| export interface ApprovedPantryResponse { | ||
| pantryId: number; | ||
| pantryName: string; | ||
| address: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this a bit clearer and call it shippingAddress
apps/backend/src/pantries/types.ts
Outdated
| activities?: Activity[]; | ||
| allergenFreeItemsInStock?: string; | ||
| needMoreAllergenFreeOptions?: string; | ||
| subscriptionToNewsletter: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are the things I think that this should have (referencing the application DTO):
contactFirstName, contactLastName, contactEmail, contactPhone, shippingAddressLine1, shippingAddressCity, shippingAddressZip, shippingAddressCountry (if provided), pantryName, allergenClients, restrictions, refridgeratedDonation, reserveFoodForAllergic, reservatinoExplanation (if provided), dedicatedAllergenFriendly, clientVisitFrequency, identifyAllergensConfidence, serveAllergicChildren, activities, activitiesComments, itemsInStock, needMoreOptions, and newsletterSubscription.
All of these should match the type that they come in from the pantry-application.dto. For optional fields, make sure they also match, as well as the names should match exactly what is in the dto.
dburkhart07
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more small things. Can you also fix both tests that are currently failing? I think one of these comments should fix one of them.
| async getApprovedPantriesWithVolunteers(): Promise<ApprovedPantryResponse[]> { | ||
| const pantries = await this.repo.find({ | ||
| where: { status: PantryStatus.APPROVED }, | ||
| relations: ['pantryUser', 'volunteers'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't need volunteers now since it is not being used.
|
|
||
| describe('getApprovedPantries', () => { | ||
| it('should return approved pantries with volunteers', async () => { | ||
| const mockApprovedPantries: ApprovedPantryResponse[] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be rewritten to be what the new response format.
| @Put('/:pantryId/volunteers') | ||
| async updatePantryVolunteers( | ||
| @Param('pantryId', ParseIntPipe) pantryId: number, | ||
| @Body() volunteerIds: number[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting an issue with volunteerIds.forEach not being a function. I would suggest looking at this specific line here, perhaps the body is not being parsed properly?
ℹ️ Issue 97
Closes 97
📝 Description
Added a new endpoint (getApprovedPantries) to return all information necessary for the pantry management frontend about pantries with 'approved' status - includes assigned volunteers.
Added a second new endpoint (updatePantryVolunteers) to overwrite the set of volunteers assigned to a pantry with a new set of volunteers.
Added a type file for pantries and included ApprovedPantryResponse and AssignedVolunteer types.
Added a controller test for each endpoint.
✔️ Verification
Tested both endpoints using curl. Made sure GET endpoint retrieved all approved pantries with assigned volunteers, and that the PUT endpoint overwrites volunteer assignments successfully.