From 320902dc439db431bbfb30a39114004f694af55e Mon Sep 17 00:00:00 2001 From: Dalton Burkhart Date: Tue, 3 Feb 2026 02:15:45 -0500 Subject: [PATCH 1/7] 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 82384673..fb28a27e 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 6bcd2a7e..92573bc6 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 1c40a7c0..ef6c3bf7 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 6afaaee4..2a125ef4 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 16387987..42bd193d 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 00000000..f532830f --- /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 eb98e3a2..e7c30f95 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 2/7] 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 92573bc6..a62b627d 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 ef6c3bf7..588eb71a 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 f532830f..1f65f257 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 3/7] 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 a62b627d..36bc9d0d 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 588eb71a..5d4749ff 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 2a125ef4..e3845993 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 1f65f257..c9a28644 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 4/7] 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 36bc9d0d..653ab8f5 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 5/7] 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 fb28a27e..9bb60358 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 653ab8f5..1ca85106 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 5d4749ff..7a2f2ea8 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 e3845993..86b6c8c2 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 c9a28644..0fb35687 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 6/7] 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 1ca85106..513a496e 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 7a2f2ea8..0a75b7af 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 86b6c8c2..6ed31ed2 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 42bd193d..59a3cd4a 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 0fb35687..d0d2b1cf 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 e7c30f95..54b4626a 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 7/7] 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 513a496e..0dd247c2 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 0a75b7af..304869cf 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 59a3cd4a..cb63fda3 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 d0d2b1cf..8678852b 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 54b4626a..46540c55 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',