From 320902dc439db431bbfb30a39114004f694af55e Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Tue, 3 Feb 2026 02:15:45 -0500 Subject: [PATCH 01/12] Added in recurring donations --- apps/backend/src/config/typeorm.ts | 2 + .../src/donations/donations.controller.ts | 32 +++++++++++- .../backend/src/donations/donations.entity.ts | 14 ++++- .../src/donations/donations.service.ts | 12 ++++- apps/backend/src/donations/types.ts | 7 +++ ...70080947285-AddDonationRecurranceFields.ts | 51 +++++++++++++++++++ apps/frontend/src/types/types.ts | 7 +++ 7 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts diff --git a/apps/backend/src/config/typeorm.ts b/apps/backend/src/config/typeorm.ts index 823846739..fb28a27ea 100644 --- a/apps/backend/src/config/typeorm.ts +++ b/apps/backend/src/config/typeorm.ts @@ -27,6 +27,7 @@ import { RemoveMultipleVolunteerTypes1764811878152 } from '../migrations/1764811 import { RemoveUnusedStatuses1764816885341 } from '../migrations/1764816885341-RemoveUnusedStatuses'; import { UpdatePantryFields1763762628431 } from '../migrations/1763762628431-UpdatePantryFields'; import { PopulateDummyData1768501812134 } from '../migrations/1768501812134-populateDummyData'; +import { AddDonationRecurranceFields1770080947285 } from '../migrations/1770080947285-AddDonationRecurranceFields'; const config = { type: 'postgres', @@ -67,6 +68,7 @@ const config = { RemoveMultipleVolunteerTypes1764811878152, RemoveUnusedStatuses1764816885341, PopulateDummyData1768501812134, + AddDonationRecurranceFields1770080947285, ], }; diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 6bcd2a7e8..92573bc6c 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -12,7 +12,7 @@ import { import { ApiBody } from '@nestjs/swagger'; import { Donation } from './donations.entity'; import { DonationService } from './donations.service'; -import { DonationStatus } from './types'; +import { DonationStatus, RecourranceEnum } from './types'; @Controller('donations') export class DonationsController { @@ -54,6 +54,20 @@ export class DonationsController { totalItems: { type: 'integer', example: 100 }, totalOz: { type: 'integer', example: 500 }, totalEstimatedValue: { type: 'integer', example: 1000 }, + recurrance: { + type: 'string', + enum: Object.values(RecourranceEnum), + example: RecourranceEnum.ONCE, + nullable: true, + }, + recurranceValue: { type: 'integer', example: 1, nullable: true }, + nextDonationDates: { + type: 'array', + items: { type: 'string', format: 'date-time' }, + example: ['2024-07-01T00:00:00Z', '2024-08-01T00:00:00Z'], + nullable: true, + }, + occurances: { type: 'integer', example: 2, nullable: true}, }, }, }) @@ -66,6 +80,10 @@ export class DonationsController { totalItems: number; totalOz: number; totalEstimatedValue: number; + recurrance: RecourranceEnum; + recurranceValue?: number; + nextDonationDates?: Date[]; + occurances?: number; }, ): Promise { if ( @@ -74,6 +92,14 @@ export class DonationsController { ) { throw new BadRequestException('Invalid status'); } + // If we got a recurrance, we should have all of these values + // The next donation dates should be a list of dates we will get from the frontend accordingly + if( + body.recurrance != RecourranceEnum.ONCE && + (!body.recurranceValue || !body.nextDonationDates || !body.occurances) + ) { + throw new BadRequestException('Recurrance details are incomplete'); + } return this.donationService.create( body.foodManufacturerId, body.dateDonated, @@ -81,6 +107,10 @@ export class DonationsController { body.totalItems, body.totalOz, body.totalEstimatedValue, + body.recurrance ?? RecourranceEnum.ONCE, + body.recurranceValue ?? null, + body.nextDonationDates ?? null, + body.occurances ?? null, ); } diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index 1c40a7c01..ef6c3bf77 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -7,7 +7,7 @@ import { ManyToOne, } from 'typeorm'; import { FoodManufacturer } from '../foodManufacturers/manufacturer.entity'; -import { DonationStatus } from './types'; +import { DonationStatus, RecourranceEnum } from './types'; @Entity('donations') export class Donation { @@ -44,4 +44,16 @@ export class Donation { @Column({ name: 'total_estimated_value', type: 'int', nullable: true }) totalEstimatedValue: number; + + @Column({ name: 'recurrance', type: 'enum', enum: RecourranceEnum, enumName: 'donation_recurrance_enum', default: RecourranceEnum.ONCE }) + recurrance: RecourranceEnum; + + @Column({ name: 'recurrance_value', type: 'int', nullable: true }) + recurranceValue: number; + + @Column({ name: 'next_donation_dates', type: 'timestamptz', array: true, nullable: true }) + nextDonationDates: Date[]; + + @Column({ name: 'occurances', type: 'int', nullable: true }) + occurances: number; } diff --git a/apps/backend/src/donations/donations.service.ts b/apps/backend/src/donations/donations.service.ts index 6afaaee4e..2a125ef4b 100644 --- a/apps/backend/src/donations/donations.service.ts +++ b/apps/backend/src/donations/donations.service.ts @@ -4,7 +4,7 @@ import { Repository } from 'typeorm'; import { Donation } from './donations.entity'; import { validateId } from '../utils/validation.utils'; import { FoodManufacturer } from '../foodManufacturers/manufacturer.entity'; -import { DonationStatus } from './types'; +import { DonationStatus, RecourranceEnum } from './types'; @Injectable() export class DonationService { @@ -45,7 +45,11 @@ export class DonationService { totalItems: number, totalOz: number, totalEstimatedValue: number, - ) { + recurrance: RecourranceEnum, + recurranceValue: number, + nextDonationDates: Date[] | null, + occurances: number | null, + ): Promise { validateId(foodManufacturerId, 'Food Manufacturer'); const manufacturer = await this.manufacturerRepo.findOne({ where: { foodManufacturerId }, @@ -63,6 +67,10 @@ export class DonationService { totalItems, totalOz, totalEstimatedValue, + recurrance, + recurranceValue, + nextDonationDates, + occurances, }); return this.repo.save(donation); diff --git a/apps/backend/src/donations/types.ts b/apps/backend/src/donations/types.ts index 163879870..42bd193d0 100644 --- a/apps/backend/src/donations/types.ts +++ b/apps/backend/src/donations/types.ts @@ -3,3 +3,10 @@ export enum DonationStatus { FULFILLED = 'fulfilled', MATCHING = 'matching', } + +export enum RecourranceEnum { + ONCE = 'once', + WEEKLY = 'weekly', + MONTHLY = 'monthly', + YEARLY = 'yearly', +} diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts new file mode 100644 index 000000000..f532830f6 --- /dev/null +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts @@ -0,0 +1,51 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddDonationRecurranceFields1770080947285 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + CREATE TYPE donation_recurrance_enum AS ENUM ( + 'once', + 'weekly', + 'monthly', + 'yearly' + ); + `); + + await queryRunner.query(` + ALTER TABLE donations + ADD COLUMN recurrance donation_recurrance_enum NOT NULL DEFAULT 'once', + ADD COLUMN recurrance_value INTEGER, + ADD COLUMN next_donation_dates TIMESTAMP WITH TIME ZONE[], + ADD COLUMN occurances INTEGER; + `); + + await queryRunner.query(` + ALTER TABLE donations + ADD CONSTRAINT recurrance_fields_not_null CHECK ( + (recurrance = 'once' + AND recurrance_value IS NULL + AND next_donation_dates IS NULL + AND occurances IS NULL) + OR + (recurrance != 'once' + AND recurrance_value IS NOT NULL + AND next_donation_dates IS NOT NULL + AND occurances IS NOT NULL) + ); + `); + } + + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` + ALTER TABLE donations + DROP CONSTRAINT recurrance_fields_not_null, + DROP COLUMN recurrance, + DROP COLUMN recurrance_value, + DROP COLUMN next_donation_dates, + DROP COLUMN occurances; + + DROP TYPE donation_recurrance_enum; + `); + } +} diff --git a/apps/frontend/src/types/types.ts b/apps/frontend/src/types/types.ts index eb98e3a22..e7c30f95d 100644 --- a/apps/frontend/src/types/types.ts +++ b/apps/frontend/src/types/types.ts @@ -103,6 +103,13 @@ export enum DonationStatus { MATCHING = 'matching', } +export enum RecourranceEnum { + ONCE = 'once', + WEEKLY = 'weekly', + MONTHLY = 'monthly', + YEARLY = 'yearly', +} + export interface Donation { donationId: number; dateDonated: string; From ed330ef4c0cedfe84f64e2b32c3b4bf38185c865 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Tue, 3 Feb 2026 02:20:38 -0500 Subject: [PATCH 02/12] prettier --- .../src/donations/donations.controller.ts | 4 +-- .../backend/src/donations/donations.entity.ts | 15 +++++++++-- ...70080947285-AddDonationRecurranceFields.ts | 25 ++++++++++--------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 92573bc6c..a62b627d1 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -67,7 +67,7 @@ export class DonationsController { example: ['2024-07-01T00:00:00Z', '2024-08-01T00:00:00Z'], nullable: true, }, - occurances: { type: 'integer', example: 2, nullable: true}, + occurances: { type: 'integer', example: 2, nullable: true }, }, }, }) @@ -94,7 +94,7 @@ export class DonationsController { } // If we got a recurrance, we should have all of these values // The next donation dates should be a list of dates we will get from the frontend accordingly - if( + if ( body.recurrance != RecourranceEnum.ONCE && (!body.recurranceValue || !body.nextDonationDates || !body.occurances) ) { diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index ef6c3bf77..588eb71a1 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -45,13 +45,24 @@ export class Donation { @Column({ name: 'total_estimated_value', type: 'int', nullable: true }) totalEstimatedValue: number; - @Column({ name: 'recurrance', type: 'enum', enum: RecourranceEnum, enumName: 'donation_recurrance_enum', default: RecourranceEnum.ONCE }) + @Column({ + name: 'recurrance', + type: 'enum', + enum: RecourranceEnum, + enumName: 'donation_recurrance_enum', + default: RecourranceEnum.ONCE, + }) recurrance: RecourranceEnum; @Column({ name: 'recurrance_value', type: 'int', nullable: true }) recurranceValue: number; - @Column({ name: 'next_donation_dates', type: 'timestamptz', array: true, nullable: true }) + @Column({ + name: 'next_donation_dates', + type: 'timestamptz', + array: true, + nullable: true, + }) nextDonationDates: Date[]; @Column({ name: 'occurances', type: 'int', nullable: true }) diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts index f532830f6..1f65f2576 100644 --- a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts @@ -1,8 +1,10 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; +import { MigrationInterface, QueryRunner } from 'typeorm'; -export class AddDonationRecurranceFields1770080947285 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` +export class AddDonationRecurranceFields1770080947285 + implements MigrationInterface +{ + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(` CREATE TYPE donation_recurrance_enum AS ENUM ( 'once', 'weekly', @@ -10,8 +12,8 @@ export class AddDonationRecurranceFields1770080947285 implements MigrationInterf 'yearly' ); `); - - await queryRunner.query(` + + await queryRunner.query(` ALTER TABLE donations ADD COLUMN recurrance donation_recurrance_enum NOT NULL DEFAULT 'once', ADD COLUMN recurrance_value INTEGER, @@ -19,7 +21,7 @@ export class AddDonationRecurranceFields1770080947285 implements MigrationInterf ADD COLUMN occurances INTEGER; `); - await queryRunner.query(` + await queryRunner.query(` ALTER TABLE donations ADD CONSTRAINT recurrance_fields_not_null CHECK ( (recurrance = 'once' @@ -33,11 +35,10 @@ export class AddDonationRecurranceFields1770080947285 implements MigrationInterf AND occurances IS NOT NULL) ); `); - } - + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(` ALTER TABLE donations DROP CONSTRAINT recurrance_fields_not_null, DROP COLUMN recurrance, @@ -47,5 +48,5 @@ export class AddDonationRecurranceFields1770080947285 implements MigrationInterf DROP TYPE donation_recurrance_enum; `); - } + } } From 16daa0f934200f61f5b743a9a89437b9d8d1b854 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Tue, 3 Feb 2026 17:30:29 -0500 Subject: [PATCH 03/12] Final commit --- apps/backend/src/donations/donations.controller.ts | 8 ++++---- apps/backend/src/donations/donations.entity.ts | 4 ++-- apps/backend/src/donations/donations.service.ts | 4 ++-- .../1770080947285-AddDonationRecurranceFields.ts | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index a62b627d1..36bc9d0d8 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -60,7 +60,7 @@ export class DonationsController { example: RecourranceEnum.ONCE, nullable: true, }, - recurranceValue: { type: 'integer', example: 1, nullable: true }, + recurranceFreq: { type: 'integer', example: 1, nullable: true }, nextDonationDates: { type: 'array', items: { type: 'string', format: 'date-time' }, @@ -81,7 +81,7 @@ export class DonationsController { totalOz: number; totalEstimatedValue: number; recurrance: RecourranceEnum; - recurranceValue?: number; + recurranceFreq?: number; nextDonationDates?: Date[]; occurances?: number; }, @@ -96,7 +96,7 @@ export class DonationsController { // The next donation dates should be a list of dates we will get from the frontend accordingly if ( body.recurrance != RecourranceEnum.ONCE && - (!body.recurranceValue || !body.nextDonationDates || !body.occurances) + (!body.recurranceFreq || !body.nextDonationDates || !body.occurances) ) { throw new BadRequestException('Recurrance details are incomplete'); } @@ -108,7 +108,7 @@ export class DonationsController { body.totalOz, body.totalEstimatedValue, body.recurrance ?? RecourranceEnum.ONCE, - body.recurranceValue ?? null, + body.recurranceFreq ?? null, body.nextDonationDates ?? null, body.occurances ?? null, ); diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index 588eb71a1..5d4749ff8 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -54,8 +54,8 @@ export class Donation { }) recurrance: RecourranceEnum; - @Column({ name: 'recurrance_value', type: 'int', nullable: true }) - recurranceValue: number; + @Column({ name: 'recurrance_freq', type: 'int', nullable: true }) + recurranceFreq: number; @Column({ name: 'next_donation_dates', diff --git a/apps/backend/src/donations/donations.service.ts b/apps/backend/src/donations/donations.service.ts index 2a125ef4b..e38459933 100644 --- a/apps/backend/src/donations/donations.service.ts +++ b/apps/backend/src/donations/donations.service.ts @@ -46,7 +46,7 @@ export class DonationService { totalOz: number, totalEstimatedValue: number, recurrance: RecourranceEnum, - recurranceValue: number, + recurranceFreq: number, nextDonationDates: Date[] | null, occurances: number | null, ): Promise { @@ -68,7 +68,7 @@ export class DonationService { totalOz, totalEstimatedValue, recurrance, - recurranceValue, + recurranceFreq, nextDonationDates, occurances, }); diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts index 1f65f2576..c9a28644e 100644 --- a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts @@ -16,7 +16,7 @@ export class AddDonationRecurranceFields1770080947285 await queryRunner.query(` ALTER TABLE donations ADD COLUMN recurrance donation_recurrance_enum NOT NULL DEFAULT 'once', - ADD COLUMN recurrance_value INTEGER, + ADD COLUMN recurrance_freq INTEGER, ADD COLUMN next_donation_dates TIMESTAMP WITH TIME ZONE[], ADD COLUMN occurances INTEGER; `); @@ -25,12 +25,12 @@ export class AddDonationRecurranceFields1770080947285 ALTER TABLE donations ADD CONSTRAINT recurrance_fields_not_null CHECK ( (recurrance = 'once' - AND recurrance_value IS NULL + AND recurrance_freq IS NULL AND next_donation_dates IS NULL AND occurances IS NULL) OR (recurrance != 'once' - AND recurrance_value IS NOT NULL + AND recurrance_freq IS NOT NULL AND next_donation_dates IS NOT NULL AND occurances IS NOT NULL) ); @@ -42,7 +42,7 @@ export class AddDonationRecurranceFields1770080947285 ALTER TABLE donations DROP CONSTRAINT recurrance_fields_not_null, DROP COLUMN recurrance, - DROP COLUMN recurrance_value, + DROP COLUMN recurrance_freq, DROP COLUMN next_donation_dates, DROP COLUMN occurances; From 0484af838dc85f9155beec2e05c3460744e32b51 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Tue, 3 Feb 2026 20:27:04 -0500 Subject: [PATCH 04/12] Final commit --- apps/backend/src/donations/donations.controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 36bc9d0d8..653ab8f53 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -107,7 +107,7 @@ export class DonationsController { body.totalItems, body.totalOz, body.totalEstimatedValue, - body.recurrance ?? RecourranceEnum.ONCE, + body.recurrance, body.recurranceFreq ?? null, body.nextDonationDates ?? null, body.occurances ?? null, From d6f6acf010471094cd95c845f94f9b1d9ee3360f Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Wed, 4 Feb 2026 20:55:03 -0500 Subject: [PATCH 05/12] Final commit --- apps/backend/src/config/typeorm.ts | 4 +-- .../src/donations/donations.controller.ts | 20 +++++++------- .../backend/src/donations/donations.entity.ts | 10 +++---- .../src/donations/donations.service.ts | 8 +++--- ...0080947285-AddDonationRecurrenceFields.ts} | 26 +++++++++---------- 5 files changed, 34 insertions(+), 34 deletions(-) rename apps/backend/src/migrations/{1770080947285-AddDonationRecurranceFields.ts => 1770080947285-AddDonationRecurrenceFields.ts} (62%) diff --git a/apps/backend/src/config/typeorm.ts b/apps/backend/src/config/typeorm.ts index fb28a27ea..9bb60358b 100644 --- a/apps/backend/src/config/typeorm.ts +++ b/apps/backend/src/config/typeorm.ts @@ -27,7 +27,7 @@ import { RemoveMultipleVolunteerTypes1764811878152 } from '../migrations/1764811 import { RemoveUnusedStatuses1764816885341 } from '../migrations/1764816885341-RemoveUnusedStatuses'; import { UpdatePantryFields1763762628431 } from '../migrations/1763762628431-UpdatePantryFields'; import { PopulateDummyData1768501812134 } from '../migrations/1768501812134-populateDummyData'; -import { AddDonationRecurranceFields1770080947285 } from '../migrations/1770080947285-AddDonationRecurranceFields'; +import { AddDonationRecurrenceFields1770080947285 } from '../migrations/1770080947285-AddDonationRecurrenceFields'; const config = { type: 'postgres', @@ -68,7 +68,7 @@ const config = { RemoveMultipleVolunteerTypes1764811878152, RemoveUnusedStatuses1764816885341, PopulateDummyData1768501812134, - AddDonationRecurranceFields1770080947285, + AddDonationRecurrenceFields1770080947285, ], }; diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 653ab8f53..1ca851066 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -54,13 +54,13 @@ export class DonationsController { totalItems: { type: 'integer', example: 100 }, totalOz: { type: 'integer', example: 500 }, totalEstimatedValue: { type: 'integer', example: 1000 }, - recurrance: { + recurrence: { type: 'string', enum: Object.values(RecourranceEnum), example: RecourranceEnum.ONCE, nullable: true, }, - recurranceFreq: { type: 'integer', example: 1, nullable: true }, + recurrenceFreq: { type: 'integer', example: 1, nullable: true }, nextDonationDates: { type: 'array', items: { type: 'string', format: 'date-time' }, @@ -80,8 +80,8 @@ export class DonationsController { totalItems: number; totalOz: number; totalEstimatedValue: number; - recurrance: RecourranceEnum; - recurranceFreq?: number; + recurrence: RecourranceEnum; + recurrenceFreq?: number; nextDonationDates?: Date[]; occurances?: number; }, @@ -92,13 +92,13 @@ export class DonationsController { ) { throw new BadRequestException('Invalid status'); } - // If we got a recurrance, we should have all of these values + // If we got a recurrence, we should have all of these values // The next donation dates should be a list of dates we will get from the frontend accordingly if ( - body.recurrance != RecourranceEnum.ONCE && - (!body.recurranceFreq || !body.nextDonationDates || !body.occurances) + body.recurrence != RecourranceEnum.ONCE && + (!body.recurrenceFreq || !body.nextDonationDates || !body.occurances) ) { - throw new BadRequestException('Recurrance details are incomplete'); + throw new BadRequestException('recurrence details are incomplete'); } return this.donationService.create( body.foodManufacturerId, @@ -107,8 +107,8 @@ export class DonationsController { body.totalItems, body.totalOz, body.totalEstimatedValue, - body.recurrance, - body.recurranceFreq ?? null, + body.recurrence, + body.recurrenceFreq ?? null, body.nextDonationDates ?? null, body.occurances ?? null, ); diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index 5d4749ff8..7a2f2ea83 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -46,16 +46,16 @@ export class Donation { totalEstimatedValue: number; @Column({ - name: 'recurrance', + name: 'recurrence', type: 'enum', enum: RecourranceEnum, - enumName: 'donation_recurrance_enum', + enumName: 'donation_recurrence_enum', default: RecourranceEnum.ONCE, }) - recurrance: RecourranceEnum; + recurrence: RecourranceEnum; - @Column({ name: 'recurrance_freq', type: 'int', nullable: true }) - recurranceFreq: number; + @Column({ name: 'recurrence_freq', type: 'int', nullable: true }) + recurrenceFreq: number; @Column({ name: 'next_donation_dates', diff --git a/apps/backend/src/donations/donations.service.ts b/apps/backend/src/donations/donations.service.ts index e38459933..86b6c8c29 100644 --- a/apps/backend/src/donations/donations.service.ts +++ b/apps/backend/src/donations/donations.service.ts @@ -45,8 +45,8 @@ export class DonationService { totalItems: number, totalOz: number, totalEstimatedValue: number, - recurrance: RecourranceEnum, - recurranceFreq: number, + recurrence: RecourranceEnum, + recurrenceFreq: number, nextDonationDates: Date[] | null, occurances: number | null, ): Promise { @@ -67,8 +67,8 @@ export class DonationService { totalItems, totalOz, totalEstimatedValue, - recurrance, - recurranceFreq, + recurrence, + recurrenceFreq, nextDonationDates, occurances, }); diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts similarity index 62% rename from apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts rename to apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts index c9a28644e..0fb35687d 100644 --- a/apps/backend/src/migrations/1770080947285-AddDonationRecurranceFields.ts +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts @@ -1,11 +1,11 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -export class AddDonationRecurranceFields1770080947285 +export class AddDonationRecurrenceFields1770080947285 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(` - CREATE TYPE donation_recurrance_enum AS ENUM ( + CREATE TYPE donation_recurrence_enum AS ENUM ( 'once', 'weekly', 'monthly', @@ -15,22 +15,22 @@ export class AddDonationRecurranceFields1770080947285 await queryRunner.query(` ALTER TABLE donations - ADD COLUMN recurrance donation_recurrance_enum NOT NULL DEFAULT 'once', - ADD COLUMN recurrance_freq INTEGER, + ADD COLUMN recurrence donation_recurrence_enum NOT NULL DEFAULT 'once', + ADD COLUMN recurrence_freq INTEGER, ADD COLUMN next_donation_dates TIMESTAMP WITH TIME ZONE[], ADD COLUMN occurances INTEGER; `); await queryRunner.query(` ALTER TABLE donations - ADD CONSTRAINT recurrance_fields_not_null CHECK ( - (recurrance = 'once' - AND recurrance_freq IS NULL + ADD CONSTRAINT recurrence_fields_not_null CHECK ( + (recurrence = 'once' + AND recurrence_freq IS NULL AND next_donation_dates IS NULL AND occurances IS NULL) OR - (recurrance != 'once' - AND recurrance_freq IS NOT NULL + (recurrence != 'once' + AND recurrence_freq IS NOT NULL AND next_donation_dates IS NOT NULL AND occurances IS NOT NULL) ); @@ -40,13 +40,13 @@ export class AddDonationRecurranceFields1770080947285 public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(` ALTER TABLE donations - DROP CONSTRAINT recurrance_fields_not_null, - DROP COLUMN recurrance, - DROP COLUMN recurrance_freq, + DROP CONSTRAINT recurrence_fields_not_null, + DROP COLUMN recurrence, + DROP COLUMN recurrence_freq, DROP COLUMN next_donation_dates, DROP COLUMN occurances; - DROP TYPE donation_recurrance_enum; + DROP TYPE donation_recurrence_enum; `); } } From ffea07841d16d865e5e18cba0f38666d37e43cce Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Wed, 4 Feb 2026 22:42:26 -0500 Subject: [PATCH 06/12] Final commit fr this time --- .../src/donations/donations.controller.ts | 18 +++++++++--------- apps/backend/src/donations/donations.entity.ts | 12 ++++++------ .../backend/src/donations/donations.service.ts | 8 ++++---- apps/backend/src/donations/types.ts | 2 +- ...770080947285-AddDonationRecurrenceFields.ts | 8 ++++---- apps/frontend/src/types/types.ts | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 1ca851066..513a496ec 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -12,7 +12,7 @@ import { import { ApiBody } from '@nestjs/swagger'; import { Donation } from './donations.entity'; import { DonationService } from './donations.service'; -import { DonationStatus, RecourranceEnum } from './types'; +import { DonationStatus, RecurrenceEnum } from './types'; @Controller('donations') export class DonationsController { @@ -56,8 +56,8 @@ export class DonationsController { totalEstimatedValue: { type: 'integer', example: 1000 }, recurrence: { type: 'string', - enum: Object.values(RecourranceEnum), - example: RecourranceEnum.ONCE, + enum: Object.values(RecurrenceEnum), + example: RecurrenceEnum.ONCE, nullable: true, }, recurrenceFreq: { type: 'integer', example: 1, nullable: true }, @@ -67,7 +67,7 @@ export class DonationsController { example: ['2024-07-01T00:00:00Z', '2024-08-01T00:00:00Z'], nullable: true, }, - occurances: { type: 'integer', example: 2, nullable: true }, + occurences: { type: 'integer', example: 2, nullable: true }, }, }, }) @@ -80,10 +80,10 @@ export class DonationsController { totalItems: number; totalOz: number; totalEstimatedValue: number; - recurrence: RecourranceEnum; + recurrence: RecurrenceEnum; recurrenceFreq?: number; nextDonationDates?: Date[]; - occurances?: number; + occurences?: number; }, ): Promise { if ( @@ -95,8 +95,8 @@ export class DonationsController { // If we got a recurrence, we should have all of these values // The next donation dates should be a list of dates we will get from the frontend accordingly if ( - body.recurrence != RecourranceEnum.ONCE && - (!body.recurrenceFreq || !body.nextDonationDates || !body.occurances) + body.recurrence != RecurrenceEnum.ONCE && + (!body.recurrenceFreq || !body.nextDonationDates || !body.occurences) ) { throw new BadRequestException('recurrence details are incomplete'); } @@ -110,7 +110,7 @@ export class DonationsController { body.recurrence, body.recurrenceFreq ?? null, body.nextDonationDates ?? null, - body.occurances ?? null, + body.occurences ?? null, ); } diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index 7a2f2ea83..0a75b7afb 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -7,7 +7,7 @@ import { ManyToOne, } from 'typeorm'; import { FoodManufacturer } from '../foodManufacturers/manufacturer.entity'; -import { DonationStatus, RecourranceEnum } from './types'; +import { DonationStatus, RecurrenceEnum } from './types'; @Entity('donations') export class Donation { @@ -48,11 +48,11 @@ export class Donation { @Column({ name: 'recurrence', type: 'enum', - enum: RecourranceEnum, + enum: RecurrenceEnum, enumName: 'donation_recurrence_enum', - default: RecourranceEnum.ONCE, + default: RecurrenceEnum.ONCE, }) - recurrence: RecourranceEnum; + recurrence: RecurrenceEnum; @Column({ name: 'recurrence_freq', type: 'int', nullable: true }) recurrenceFreq: number; @@ -65,6 +65,6 @@ export class Donation { }) nextDonationDates: Date[]; - @Column({ name: 'occurances', type: 'int', nullable: true }) - occurances: number; + @Column({ name: 'occurences', type: 'int', nullable: true }) + occurences: number; } diff --git a/apps/backend/src/donations/donations.service.ts b/apps/backend/src/donations/donations.service.ts index 86b6c8c29..6ed31ed23 100644 --- a/apps/backend/src/donations/donations.service.ts +++ b/apps/backend/src/donations/donations.service.ts @@ -4,7 +4,7 @@ import { Repository } from 'typeorm'; import { Donation } from './donations.entity'; import { validateId } from '../utils/validation.utils'; import { FoodManufacturer } from '../foodManufacturers/manufacturer.entity'; -import { DonationStatus, RecourranceEnum } from './types'; +import { DonationStatus, RecurrenceEnum } from './types'; @Injectable() export class DonationService { @@ -45,10 +45,10 @@ export class DonationService { totalItems: number, totalOz: number, totalEstimatedValue: number, - recurrence: RecourranceEnum, + recurrence: RecurrenceEnum, recurrenceFreq: number, nextDonationDates: Date[] | null, - occurances: number | null, + occurences: number | null, ): Promise { validateId(foodManufacturerId, 'Food Manufacturer'); const manufacturer = await this.manufacturerRepo.findOne({ @@ -70,7 +70,7 @@ export class DonationService { recurrence, recurrenceFreq, nextDonationDates, - occurances, + occurences, }); return this.repo.save(donation); diff --git a/apps/backend/src/donations/types.ts b/apps/backend/src/donations/types.ts index 42bd193d0..59a3cd4a8 100644 --- a/apps/backend/src/donations/types.ts +++ b/apps/backend/src/donations/types.ts @@ -4,7 +4,7 @@ export enum DonationStatus { MATCHING = 'matching', } -export enum RecourranceEnum { +export enum RecurrenceEnum { ONCE = 'once', WEEKLY = 'weekly', MONTHLY = 'monthly', diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts index 0fb35687d..d0d2b1cf7 100644 --- a/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts @@ -18,7 +18,7 @@ export class AddDonationRecurrenceFields1770080947285 ADD COLUMN recurrence donation_recurrence_enum NOT NULL DEFAULT 'once', ADD COLUMN recurrence_freq INTEGER, ADD COLUMN next_donation_dates TIMESTAMP WITH TIME ZONE[], - ADD COLUMN occurances INTEGER; + ADD COLUMN occurences INTEGER; `); await queryRunner.query(` @@ -27,12 +27,12 @@ export class AddDonationRecurrenceFields1770080947285 (recurrence = 'once' AND recurrence_freq IS NULL AND next_donation_dates IS NULL - AND occurances IS NULL) + AND occurences IS NULL) OR (recurrence != 'once' AND recurrence_freq IS NOT NULL AND next_donation_dates IS NOT NULL - AND occurances IS NOT NULL) + AND occurences IS NOT NULL) ); `); } @@ -44,7 +44,7 @@ export class AddDonationRecurrenceFields1770080947285 DROP COLUMN recurrence, DROP COLUMN recurrence_freq, DROP COLUMN next_donation_dates, - DROP COLUMN occurances; + DROP COLUMN occurences; DROP TYPE donation_recurrence_enum; `); diff --git a/apps/frontend/src/types/types.ts b/apps/frontend/src/types/types.ts index e7c30f95d..54b4626a6 100644 --- a/apps/frontend/src/types/types.ts +++ b/apps/frontend/src/types/types.ts @@ -103,7 +103,7 @@ export enum DonationStatus { MATCHING = 'matching', } -export enum RecourranceEnum { +export enum RecurrenceEnum { ONCE = 'once', WEEKLY = 'weekly', MONTHLY = 'monthly', From 90cbe4a904c495ccb94676fa46004fc6eb422338 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Thu, 5 Feb 2026 01:22:30 -0500 Subject: [PATCH 07/12] Fixed donation enum names --- apps/backend/src/donations/donations.controller.ts | 7 +++---- apps/backend/src/donations/donations.entity.ts | 4 ++-- apps/backend/src/donations/types.ts | 2 +- .../1770080947285-AddDonationRecurrenceFields.ts | 8 ++++---- apps/frontend/src/types/types.ts | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 513a496ec..0dd247c24 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -57,8 +57,7 @@ export class DonationsController { recurrence: { type: 'string', enum: Object.values(RecurrenceEnum), - example: RecurrenceEnum.ONCE, - nullable: true, + example: RecurrenceEnum.NONE, }, recurrenceFreq: { type: 'integer', example: 1, nullable: true }, nextDonationDates: { @@ -95,7 +94,7 @@ export class DonationsController { // If we got a recurrence, we should have all of these values // The next donation dates should be a list of dates we will get from the frontend accordingly if ( - body.recurrence != RecurrenceEnum.ONCE && + body.recurrence != RecurrenceEnum.NONE && (!body.recurrenceFreq || !body.nextDonationDates || !body.occurences) ) { throw new BadRequestException('recurrence details are incomplete'); @@ -108,7 +107,7 @@ export class DonationsController { body.totalOz, body.totalEstimatedValue, body.recurrence, - body.recurrenceFreq ?? null, + body.recurrenceFreq ?? 0, body.nextDonationDates ?? null, body.occurences ?? null, ); diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index 0a75b7afb..304869cfc 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -50,7 +50,7 @@ export class Donation { type: 'enum', enum: RecurrenceEnum, enumName: 'donation_recurrence_enum', - default: RecurrenceEnum.ONCE, + default: RecurrenceEnum.NONE, }) recurrence: RecurrenceEnum; @@ -66,5 +66,5 @@ export class Donation { nextDonationDates: Date[]; @Column({ name: 'occurences', type: 'int', nullable: true }) - occurences: number; + occurencesRemaining: number; } diff --git a/apps/backend/src/donations/types.ts b/apps/backend/src/donations/types.ts index 59a3cd4a8..cb63fda33 100644 --- a/apps/backend/src/donations/types.ts +++ b/apps/backend/src/donations/types.ts @@ -5,7 +5,7 @@ export enum DonationStatus { } export enum RecurrenceEnum { - ONCE = 'once', + NONE = 'none', WEEKLY = 'weekly', MONTHLY = 'monthly', YEARLY = 'yearly', diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts index d0d2b1cf7..8678852b0 100644 --- a/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts @@ -6,7 +6,7 @@ export class AddDonationRecurrenceFields1770080947285 public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(` CREATE TYPE donation_recurrence_enum AS ENUM ( - 'once', + 'none', 'weekly', 'monthly', 'yearly' @@ -15,7 +15,7 @@ export class AddDonationRecurrenceFields1770080947285 await queryRunner.query(` ALTER TABLE donations - ADD COLUMN recurrence donation_recurrence_enum NOT NULL DEFAULT 'once', + ADD COLUMN recurrence donation_recurrence_enum NOT NULL DEFAULT 'none', ADD COLUMN recurrence_freq INTEGER, ADD COLUMN next_donation_dates TIMESTAMP WITH TIME ZONE[], ADD COLUMN occurences INTEGER; @@ -24,12 +24,12 @@ export class AddDonationRecurrenceFields1770080947285 await queryRunner.query(` ALTER TABLE donations ADD CONSTRAINT recurrence_fields_not_null CHECK ( - (recurrence = 'once' + (recurrence = 'none' AND recurrence_freq IS NULL AND next_donation_dates IS NULL AND occurences IS NULL) OR - (recurrence != 'once' + (recurrence != 'none' AND recurrence_freq IS NOT NULL AND next_donation_dates IS NOT NULL AND occurences IS NOT NULL) diff --git a/apps/frontend/src/types/types.ts b/apps/frontend/src/types/types.ts index 54b4626a6..46540c550 100644 --- a/apps/frontend/src/types/types.ts +++ b/apps/frontend/src/types/types.ts @@ -104,7 +104,7 @@ export enum DonationStatus { } export enum RecurrenceEnum { - ONCE = 'once', + NONE = 'none', WEEKLY = 'weekly', MONTHLY = 'monthly', YEARLY = 'yearly', From 17a5fc5ff8aadd1af359e8677e808f85f9afc478 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Fri, 6 Feb 2026 00:29:01 -0500 Subject: [PATCH 08/12] prettier --- apps/backend/src/donations/donations.controller.ts | 4 +++- apps/frontend/src/components/forms/requestDetailsModal.tsx | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 4a262af77..22631ea86 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -95,7 +95,9 @@ export class DonationsController { // The next donation dates should be a list of dates we will get from the frontend accordingly if ( body.recurrence != RecurrenceEnum.NONE && - (!body.recurrenceFreq || !body.nextDonationDates || !body.occurencesRemaining) + (!body.recurrenceFreq || + !body.nextDonationDates || + !body.occurencesRemaining) ) { throw new BadRequestException('recurrence details are incomplete'); } diff --git a/apps/frontend/src/components/forms/requestDetailsModal.tsx b/apps/frontend/src/components/forms/requestDetailsModal.tsx index 3c46cb858..5a63830da 100644 --- a/apps/frontend/src/components/forms/requestDetailsModal.tsx +++ b/apps/frontend/src/components/forms/requestDetailsModal.tsx @@ -284,7 +284,12 @@ const RequestDetailsModal: React.FC = ({ mx={3} /> - + {item.quantity} From d6340480586435cb6aa1716addbc1e7852c7ff8c Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Fri, 6 Feb 2026 10:33:59 -0500 Subject: [PATCH 09/12] Review comments --- apps/backend/src/donations/donations.controller.ts | 6 +++--- apps/backend/src/donations/donations.service.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 22631ea86..3bae1c907 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -109,9 +109,9 @@ export class DonationsController { body.totalOz, body.totalEstimatedValue, body.recurrence, - body.recurrenceFreq ?? 0, - body.nextDonationDates ?? null, - body.occurencesRemaining ?? null, + body.recurrenceFreq, + body.nextDonationDates, + body.occurencesRemaining, ); } diff --git a/apps/backend/src/donations/donations.service.ts b/apps/backend/src/donations/donations.service.ts index eebe29c2c..d2cbffaf4 100644 --- a/apps/backend/src/donations/donations.service.ts +++ b/apps/backend/src/donations/donations.service.ts @@ -46,9 +46,9 @@ export class DonationService { totalOz: number, totalEstimatedValue: number, recurrence: RecurrenceEnum, - recurrenceFreq: number | null, - nextDonationDates: Date[] | null, - occurencesRemaining: number | null, + recurrenceFreq: number | undefined, + nextDonationDates: Date[] | undefined, + occurencesRemaining: number | undefined, ): Promise { validateId(foodManufacturerId, 'Food Manufacturer'); const manufacturer = await this.manufacturerRepo.findOne({ From b60bc353b7071963038491049655a0dcd554a5e4 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Fri, 6 Feb 2026 10:52:06 -0500 Subject: [PATCH 10/12] Final commit --- .yarn/releases/yarn-1.22.19.cjs | 50 +++++++++---------- .../src/donations/donations.controller.ts | 8 +-- .../backend/src/donations/donations.entity.ts | 6 +-- .../src/donations/donations.service.ts | 4 +- ...70080947285-AddDonationRecurrenceFields.ts | 8 +-- apps/frontend/src/types/types.ts | 2 +- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.yarn/releases/yarn-1.22.19.cjs b/.yarn/releases/yarn-1.22.19.cjs index bca1f214f..a084ffc5d 100644 --- a/.yarn/releases/yarn-1.22.19.cjs +++ b/.yarn/releases/yarn-1.22.19.cjs @@ -36549,7 +36549,7 @@ module.exports = { escapeQuotes: escapeQuotes, equal: __webpack_require__(272), ucs2length: __webpack_require__(654), - varOccurences: varOccurences, + varoccurrences: varoccurrences, varReplace: varReplace, cleanUpCode: cleanUpCode, finalCleanUpCode: finalCleanUpCode, @@ -36659,7 +36659,7 @@ function escapeQuotes(str) { } -function varOccurences(str, dataVar) { +function varoccurrences(str, dataVar) { dataVar += '[^0-9]'; var matches = str.match(new RegExp(dataVar, 'g')); return matches ? matches.length : 0; @@ -98196,18 +98196,18 @@ class PackageHoister { const visited = new Map(); - const occurences = {}; + const occurrences = {}; - // visitor to be used inside add() to mark occurences of packages + // visitor to be used inside add() to mark occurrences of packages const visitAdd = (pkg, ancestry, pattern) => { - const versions = occurences[pkg.name] = occurences[pkg.name] || {}; + const versions = occurrences[pkg.name] = occurrences[pkg.name] || {}; const version = versions[pkg.version] = versions[pkg.version] || { - occurences: new Set(), + occurrences: new Set(), pattern }; if (ancestry.length) { - version.occurences.add(ancestry[ancestry.length - 1]); + version.occurrences.add(ancestry[ancestry.length - 1]); } }; @@ -98290,7 +98290,7 @@ class PackageHoister { add(pattern, [], []); } - for (var _iterator9 = Object.keys(occurences).sort(), _isArray9 = Array.isArray(_iterator9), _i9 = 0, _iterator9 = _isArray9 ? _iterator9 : _iterator9[Symbol.iterator]();;) { + for (var _iterator9 = Object.keys(occurrences).sort(), _isArray9 = Array.isArray(_iterator9), _i9 = 0, _iterator9 = _isArray9 ? _iterator9 : _iterator9[Symbol.iterator]();;) { var _ref10; if (_isArray9) { @@ -98304,8 +98304,8 @@ class PackageHoister { const packageName = _ref10; - const versionOccurences = occurences[packageName]; - const versions = Object.keys(versionOccurences); + const versionoccurrences = occurrences[packageName]; + const versions = Object.keys(versionoccurrences); if (versions.length === 1) { // only one package type so we'll hoist this to the top anyway @@ -98324,7 +98324,7 @@ class PackageHoister { let mostOccurenceCount; let mostOccurencePattern; - for (var _iterator10 = Object.keys(versionOccurences).sort(), _isArray10 = Array.isArray(_iterator10), _i10 = 0, _iterator10 = _isArray10 ? _iterator10 : _iterator10[Symbol.iterator]();;) { + for (var _iterator10 = Object.keys(versionoccurrences).sort(), _isArray10 = Array.isArray(_iterator10), _i10 = 0, _iterator10 = _isArray10 ? _iterator10 : _iterator10[Symbol.iterator]();;) { var _ref11; if (_isArray10) { @@ -98337,11 +98337,11 @@ class PackageHoister { } const version = _ref11; - var _versionOccurences$ve = versionOccurences[version]; - const occurences = _versionOccurences$ve.occurences, - pattern = _versionOccurences$ve.pattern; + var _versionoccurrences$ve = versionoccurrences[version]; + const occurrences = _versionoccurrences$ve.occurrences, + pattern = _versionoccurrences$ve.pattern; - const occurenceCount = occurences.size; + const occurenceCount = occurrences.size; if (!mostOccurenceCount || occurenceCount > mostOccurenceCount) { mostOccurenceCount = occurenceCount; @@ -112183,7 +112183,7 @@ module.exports = function generate_contains(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $idx; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -112949,7 +112949,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $i; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -112972,7 +112972,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $idx; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -112996,7 +112996,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $idx; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -113498,7 +113498,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $key; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -113514,7 +113514,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $key; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -113555,7 +113555,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey); var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { $code = it.util.varReplace($code, $nextData, $passData); var $useData = $passData; } else { @@ -113661,7 +113661,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $key; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -113707,7 +113707,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { $it.dataPathArr[$dataNxt] = $key; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; @@ -113868,7 +113868,7 @@ module.exports = function generate_propertyNames(it, $keyword, $ruleType) { it.compositeRule = $it.compositeRule = true; var $code = it.validate($it); $it.baseId = $currentBaseId; - if (it.util.varOccurences($code, $nextData) < 2) { + if (it.util.varoccurrences($code, $nextData) < 2) { out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' '; } else { out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' '; diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index 3bae1c907..c4d5f701a 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -66,7 +66,7 @@ export class DonationsController { example: ['2024-07-01T00:00:00Z', '2024-08-01T00:00:00Z'], nullable: true, }, - occurencesRemaining: { type: 'integer', example: 2, nullable: true }, + occurrencesRemaining: { type: 'integer', example: 2, nullable: true }, }, }, }) @@ -82,7 +82,7 @@ export class DonationsController { recurrence: RecurrenceEnum; recurrenceFreq?: number; nextDonationDates?: Date[]; - occurencesRemaining?: number; + occurrencesRemaining?: number; }, ): Promise { if ( @@ -97,7 +97,7 @@ export class DonationsController { body.recurrence != RecurrenceEnum.NONE && (!body.recurrenceFreq || !body.nextDonationDates || - !body.occurencesRemaining) + !body.occurrencesRemaining) ) { throw new BadRequestException('recurrence details are incomplete'); } @@ -111,7 +111,7 @@ export class DonationsController { body.recurrence, body.recurrenceFreq, body.nextDonationDates, - body.occurencesRemaining, + body.occurrencesRemaining, ); } diff --git a/apps/backend/src/donations/donations.entity.ts b/apps/backend/src/donations/donations.entity.ts index db45bd2f3..a4c58388b 100644 --- a/apps/backend/src/donations/donations.entity.ts +++ b/apps/backend/src/donations/donations.entity.ts @@ -52,7 +52,7 @@ export class Donation { enumName: 'donation_recurrence_enum', default: RecurrenceEnum.NONE, }) - recurrence: RecurrenceEnum; + recurrence!: RecurrenceEnum; @Column({ name: 'recurrence_freq', type: 'int', nullable: true }) recurrenceFreq: number; @@ -65,6 +65,6 @@ export class Donation { }) nextDonationDates: Date[]; - @Column({ name: 'occurences_remaining', type: 'int', nullable: true }) - occurencesRemaining: number; + @Column({ name: 'occurrences_remaining', type: 'int', nullable: true }) + occurrencesRemaining: number; } diff --git a/apps/backend/src/donations/donations.service.ts b/apps/backend/src/donations/donations.service.ts index d2cbffaf4..46e9c6476 100644 --- a/apps/backend/src/donations/donations.service.ts +++ b/apps/backend/src/donations/donations.service.ts @@ -48,7 +48,7 @@ export class DonationService { recurrence: RecurrenceEnum, recurrenceFreq: number | undefined, nextDonationDates: Date[] | undefined, - occurencesRemaining: number | undefined, + occurrencesRemaining: number | undefined, ): Promise { validateId(foodManufacturerId, 'Food Manufacturer'); const manufacturer = await this.manufacturerRepo.findOne({ @@ -70,7 +70,7 @@ export class DonationService { recurrence, recurrenceFreq, nextDonationDates, - occurencesRemaining, + occurrencesRemaining, }); return this.repo.save(donation); diff --git a/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts index 9a1ccfebd..25c286223 100644 --- a/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts +++ b/apps/backend/src/migrations/1770080947285-AddDonationRecurrenceFields.ts @@ -18,7 +18,7 @@ export class AddDonationRecurrenceFields1770080947285 ADD COLUMN recurrence donation_recurrence_enum NOT NULL DEFAULT 'none', ADD COLUMN recurrence_freq INTEGER, ADD COLUMN next_donation_dates TIMESTAMP WITH TIME ZONE[], - ADD COLUMN occurences_remaining INTEGER; + ADD COLUMN occurrences_remaining INTEGER; `); await queryRunner.query(` @@ -27,12 +27,12 @@ export class AddDonationRecurrenceFields1770080947285 (recurrence = 'none' AND recurrence_freq IS NULL AND next_donation_dates IS NULL - AND occurences_remaining IS NULL) + AND occurrences_remaining IS NULL) OR (recurrence != 'none' AND recurrence_freq IS NOT NULL AND next_donation_dates IS NOT NULL - AND occurences_remaining IS NOT NULL) + AND occurrences_remaining IS NOT NULL) ); `); } @@ -44,7 +44,7 @@ export class AddDonationRecurrenceFields1770080947285 DROP COLUMN recurrence, DROP COLUMN recurrence_freq, DROP COLUMN next_donation_dates, - DROP COLUMN occurences_remaining; + DROP COLUMN occurrences_remaining; DROP TYPE donation_recurrence_enum; `); diff --git a/apps/frontend/src/types/types.ts b/apps/frontend/src/types/types.ts index 59156cafa..e69fe93da 100644 --- a/apps/frontend/src/types/types.ts +++ b/apps/frontend/src/types/types.ts @@ -121,7 +121,7 @@ export interface Donation { recurrence: RecurrenceEnum; recurrenceFreq?: number; nextDonationDates?: string[]; - occurencesRemaining?: number; + occurrencesRemaining?: number; } export interface DonationItem { From 635b89b7113d4f7e01e4495b14db02145b92e013 Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Fri, 6 Feb 2026 11:12:32 -0500 Subject: [PATCH 11/12] Final commit fr this time --- .../src/donations/donations.controller.ts | 16 ++---- .../src/donations/dtos/create-donation.dto.ts | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 apps/backend/src/donations/dtos/create-donation.dto.ts diff --git a/apps/backend/src/donations/donations.controller.ts b/apps/backend/src/donations/donations.controller.ts index c4d5f701a..3adca4f8b 100644 --- a/apps/backend/src/donations/donations.controller.ts +++ b/apps/backend/src/donations/donations.controller.ts @@ -13,6 +13,7 @@ import { ApiBody } from '@nestjs/swagger'; import { Donation } from './donations.entity'; import { DonationService } from './donations.service'; import { DonationStatus, RecurrenceEnum } from './types'; +import { CreateDonationDto } from './dtos/create-donation.dto'; @Controller('donations') export class DonationsController { @@ -72,18 +73,7 @@ export class DonationsController { }) async createDonation( @Body() - body: { - foodManufacturerId: number; - dateDonated: Date; - status: DonationStatus; - totalItems: number; - totalOz: number; - totalEstimatedValue: number; - recurrence: RecurrenceEnum; - recurrenceFreq?: number; - nextDonationDates?: Date[]; - occurrencesRemaining?: number; - }, + body: CreateDonationDto, ): Promise { if ( body.status && @@ -104,7 +94,7 @@ export class DonationsController { return this.donationService.create( body.foodManufacturerId, body.dateDonated, - body.status ?? DonationStatus.AVAILABLE, + body.status, body.totalItems, body.totalOz, body.totalEstimatedValue, diff --git a/apps/backend/src/donations/dtos/create-donation.dto.ts b/apps/backend/src/donations/dtos/create-donation.dto.ts new file mode 100644 index 000000000..095e145ac --- /dev/null +++ b/apps/backend/src/donations/dtos/create-donation.dto.ts @@ -0,0 +1,50 @@ +import { ArrayNotEmpty, IsArray, IsDate, IsEnum, IsNotEmpty, IsNumber, IsOptional, Min } from "class-validator"; +import { DonationStatus, RecurrenceEnum } from "../types"; +import { Type } from "class-transformer"; + +export class CreateDonationDto { + @IsNumber() + @Min(1) + foodManufacturerId: number; + + @Type(() => Date) + @IsDate() + @IsNotEmpty() + dateDonated: Date; + + @IsNotEmpty() + @IsEnum(DonationStatus) + status: DonationStatus; + + @IsNumber() + @Min(1) + totalItems: number; + + @IsNumber({ maxDecimalPlaces: 2 }) + @Min(0.01) + totalOz: number; + + @IsNumber({ maxDecimalPlaces: 2 }) + @Min(0.01) + totalEstimatedValue: number; + + @IsEnum(RecurrenceEnum) + recurrence: RecurrenceEnum; + + @IsNumber() + @IsOptional() + @Min(1) + recurrenceFreq?: number; + + @Type(() => Date) + @IsArray() + @ArrayNotEmpty() + @IsDate({ each: true }) + @IsOptional() + nextDonationDates?: Date[]; + + @IsNumber() + @IsOptional() + @Min(1) + occurrencesRemaining?: number; +} \ No newline at end of file From fd9bb3391e1ea308e858da925a5c5df2bcd7ac8e Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Fri, 6 Feb 2026 11:12:51 -0500 Subject: [PATCH 12/12] prettier --- .../src/donations/dtos/create-donation.dto.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/backend/src/donations/dtos/create-donation.dto.ts b/apps/backend/src/donations/dtos/create-donation.dto.ts index 095e145ac..a708fb7b5 100644 --- a/apps/backend/src/donations/dtos/create-donation.dto.ts +++ b/apps/backend/src/donations/dtos/create-donation.dto.ts @@ -1,6 +1,15 @@ -import { ArrayNotEmpty, IsArray, IsDate, IsEnum, IsNotEmpty, IsNumber, IsOptional, Min } from "class-validator"; -import { DonationStatus, RecurrenceEnum } from "../types"; -import { Type } from "class-transformer"; +import { + ArrayNotEmpty, + IsArray, + IsDate, + IsEnum, + IsNotEmpty, + IsNumber, + IsOptional, + Min, +} from 'class-validator'; +import { DonationStatus, RecurrenceEnum } from '../types'; +import { Type } from 'class-transformer'; export class CreateDonationDto { @IsNumber() @@ -47,4 +56,4 @@ export class CreateDonationDto { @IsOptional() @Min(1) occurrencesRemaining?: number; -} \ No newline at end of file +}