-
Notifications
You must be signed in to change notification settings - Fork 0
[SSF-134]: Update FM Management Frontend #104
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?
Changes from all commits
320902d
ed330ef
16daa0f
0484af8
d6f6acf
ffea078
90cbe4a
ead7228
17a5fc5
d634048
b60bc35
635b89b
fd9bb33
1add714
e663e18
077d928
c94c88a
937192c
0e6b95b
840973c
0e7c727
baff8bb
5681568
0dbbd4f
e426266
33e509f
800c09b
2495521
6ec30bf
36608ed
f4b32a9
3c9e869
e2a858d
acfe838
9c0fd79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,12 +7,11 @@ import { | |
| Param, | ||
| NotFoundException, | ||
| ParseIntPipe, | ||
| BadRequestException, | ||
| } from '@nestjs/common'; | ||
| import { ApiBody } from '@nestjs/swagger'; | ||
| import { Donation } from './donations.entity'; | ||
| import { DonationService } from './donations.service'; | ||
| import { DonationStatus, RecurrenceEnum } from './types'; | ||
| import { RecurrenceEnum } from './types'; | ||
| import { CreateDonationDto } from './dtos/create-donation.dto'; | ||
|
|
||
| @Controller('donations') | ||
|
|
@@ -29,7 +28,14 @@ export class DonationsController { | |
| return this.donationService.getNumberOfDonations(); | ||
| } | ||
|
|
||
| @Get('/:donationId') | ||
| @Get('/by-fm-id/:foodManufacturerId') | ||
| async getDonationsByFoodManufacturer( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we can probably write controller tests |
||
| @Param('foodManufacturerId', ParseIntPipe) foodManufacturerId: number, | ||
| ): Promise<Donation[]> { | ||
| return this.donationService.getByFoodManufacturer(foodManufacturerId); | ||
| } | ||
|
|
||
| @Get('/by-donation-id/:donationId') | ||
| async getDonation( | ||
| @Param('donationId', ParseIntPipe) donationId: number, | ||
| ): Promise<Donation> { | ||
|
|
@@ -43,15 +49,6 @@ export class DonationsController { | |
| type: 'object', | ||
| properties: { | ||
| foodManufacturerId: { type: 'integer', example: 1 }, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE FOR PR Reviewer: We deleted this since it does not make sense to have either of these fields here in creating a donation. The status will always be the same, as will the date donated. |
||
| dateDonated: { | ||
| type: 'string', | ||
| format: 'date-time', | ||
| }, | ||
| status: { | ||
| type: 'string', | ||
| enum: Object.values(DonationStatus), | ||
| example: DonationStatus.AVAILABLE, | ||
| }, | ||
| totalItems: { type: 'integer', example: 100 }, | ||
| totalOz: { type: 'number', example: 100.5 }, | ||
| totalEstimatedValue: { type: 'number', example: 100.5 }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ export class DonationService { | |
| where: { donationId }, | ||
| relations: ['foodManufacturer'], | ||
| }); | ||
|
|
||
| if (!donation) { | ||
| throw new NotFoundException(`Donation ${donationId} not found`); | ||
| } | ||
|
|
@@ -39,6 +38,25 @@ export class DonationService { | |
| return this.repo.count(); | ||
| } | ||
|
|
||
| async getByFoodManufacturer(foodManufacturerId: number): Promise<Donation[]> { | ||
| validateId(foodManufacturerId, 'Food Manufacturer'); | ||
|
|
||
| const manufacturer = await this.manufacturerRepo.findOne({ | ||
| where: { foodManufacturerId: foodManufacturerId }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need two foodManufacturerId's here since they're named the same thing |
||
| }); | ||
|
|
||
| if (!manufacturer) { | ||
| throw new NotFoundException( | ||
| `Food Manufacturer ${foodManufacturerId} not found`, | ||
| ); | ||
| } | ||
|
|
||
| return this.repo.find({ | ||
| where: { foodManufacturer: { foodManufacturerId } }, | ||
| relations: ['foodManufacturer'], | ||
| }); | ||
| } | ||
|
|
||
| async create(donationData: CreateDonationDto): Promise<Donation> { | ||
| validateId(donationData.foodManufacturerId, 'Food Manufacturer'); | ||
| const manufacturer = await this.manufacturerRepo.findOne({ | ||
|
|
@@ -52,8 +70,8 @@ export class DonationService { | |
| } | ||
| const donation = this.repo.create({ | ||
| foodManufacturer: manufacturer, | ||
| dateDonated: donationData.dateDonated, | ||
| status: donationData.status, | ||
| dateDonated: new Date(), | ||
| status: DonationStatus.AVAILABLE, | ||
| totalItems: donationData.totalItems, | ||
| totalOz: donationData.totalOz, | ||
| totalEstimatedValue: donationData.totalEstimatedValue, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class AddFoodRescueToDonationItems1770679339809 | ||
| implements MigrationInterface | ||
| { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE donation_items | ||
| ADD COLUMN food_rescue boolean NOT NULL DEFAULT false | ||
| `); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE donation_items | ||
| DROP COLUMN food_rescue | ||
| `); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class RenameDonationMatchingStatus1771260403657 | ||
| implements MigrationInterface | ||
| { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE donations | ||
| ALTER COLUMN status DROP DEFAULT; | ||
|
|
||
| CREATE TYPE donations_status_enum_new AS ENUM ( | ||
| 'available', | ||
| 'matched', | ||
| 'fulfilled' | ||
| ); | ||
|
|
||
| ALTER TABLE donations | ||
| ALTER COLUMN status | ||
| TYPE donations_status_enum_new | ||
| USING ( | ||
| CASE | ||
| WHEN status = 'matching' | ||
| THEN 'matched' | ||
| ELSE status::text | ||
| END | ||
| )::donations_status_enum_new; | ||
|
|
||
| DROP TYPE donations_status_enum; | ||
|
|
||
| ALTER TYPE donations_status_enum_new | ||
| RENAME TO donations_status_enum; | ||
|
|
||
| ALTER TABLE donations | ||
| ALTER COLUMN status | ||
| SET DEFAULT 'available'; | ||
| `); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query(` | ||
| ALTER TABLE donations | ||
| ALTER COLUMN status DROP DEFAULT; | ||
|
|
||
| CREATE TYPE donations_status_enum_old AS ENUM ( | ||
| 'available', | ||
| 'matching', | ||
| 'fulfilled' | ||
| ); | ||
|
|
||
| ALTER TABLE donations | ||
| ALTER COLUMN status | ||
| TYPE donations_status_enum_old | ||
| USING ( | ||
| CASE | ||
| WHEN status = 'matched' | ||
| THEN 'matching' | ||
| ELSE status::text | ||
| END | ||
| )::donations_status_enum_old; | ||
|
|
||
| DROP TYPE donations_status_enum; | ||
|
|
||
| ALTER TYPE donations_status_enum_old | ||
| RENAME TO donations_status_enum; | ||
|
|
||
| ALTER TABLE donations | ||
| ALTER COLUMN status | ||
| SET DEFAULT 'available'; | ||
| `); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ import PantryPastOrders from '@containers/pantryPastOrders'; | |
| import Pantries from '@containers/pantries'; | ||
| import Orders from '@containers/orders'; | ||
| import PantryDashboard from '@containers/pantryDashboard'; | ||
| import submitFoodRequestFormModal from '@components/forms/requestFormModal'; | ||
| import { submitDeliveryConfirmationFormModal } from '@components/forms/deliveryConfirmationModal'; | ||
| import FormRequests from '@containers/formRequests'; | ||
| import PantryApplication from '@containers/pantryApplication'; | ||
|
|
@@ -22,6 +21,8 @@ import Homepage from '@containers/homepage'; | |
| import AdminOrderManagement from '@containers/adminOrderManagement'; | ||
| import { Amplify } from 'aws-amplify'; | ||
| import CognitoAuthConfig from './aws-exports'; | ||
| import { Button } from '@chakra-ui/react'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems to be some unnecessary imports |
||
| import FoodManufacturerDonationManagement from '@containers/foodManufacturerDonationManagement'; | ||
| import LoginPage from '@containers/loginPage'; | ||
| import SignupPage from '@containers/signupPage'; | ||
| import ForgotPasswordPage from '@containers/forgotPasswordPage'; | ||
|
|
@@ -153,10 +154,10 @@ const router = createBrowserRouter([ | |
| ), | ||
| }, | ||
| { | ||
| path: '/donation-management', | ||
| path: '/fm-donation-management', | ||
| element: ( | ||
| <ProtectedRoute> | ||
| <DonationManagement /> | ||
| <FoodManufacturerDonationManagement /> | ||
| </ProtectedRoute> | ||
| ), | ||
| }, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.