Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
320902d
Added in recurring donations
dburkhart07 Feb 3, 2026
ed330ef
prettier
dburkhart07 Feb 3, 2026
16daa0f
Final commit
dburkhart07 Feb 3, 2026
0484af8
Final commit
dburkhart07 Feb 4, 2026
d6f6acf
Final commit
dburkhart07 Feb 5, 2026
ffea078
Final commit fr this time
dburkhart07 Feb 5, 2026
90cbe4a
Fixed donation enum names
dburkhart07 Feb 5, 2026
ead7228
Merged main and made changes
dburkhart07 Feb 6, 2026
17a5fc5
prettier
dburkhart07 Feb 6, 2026
d634048
Review comments
dburkhart07 Feb 6, 2026
b60bc35
Final commit
dburkhart07 Feb 6, 2026
635b89b
Final commit fr this time
dburkhart07 Feb 6, 2026
fd9bb33
prettier
dburkhart07 Feb 6, 2026
1add714
Some more review comments
dburkhart07 Feb 7, 2026
e663e18
More comments
dburkhart07 Feb 7, 2026
077d928
More changes!!
dburkhart07 Feb 8, 2026
c94c88a
Added in main yarn configurations
dburkhart07 Feb 8, 2026
937192c
Final commit
dburkhart07 Feb 10, 2026
0e6b95b
prettier
dburkhart07 Feb 10, 2026
840973c
Fixed selected days text logic
dburkhart07 Feb 10, 2026
0e7c727
prettier
dburkhart07 Feb 11, 2026
baff8bb
merged main
dburkhart07 Feb 13, 2026
5681568
Merged main
dburkhart07 Feb 15, 2026
0dbbd4f
Implemented changes
dburkhart07 Feb 16, 2026
e426266
prettier
dburkhart07 Feb 16, 2026
33e509f
Fixed backend
dburkhart07 Feb 16, 2026
800c09b
prettier
dburkhart07 Feb 16, 2026
2495521
potential fix to mac issue
dburkhart07 Feb 16, 2026
6ec30bf
Fixed small issue in order service tests
dburkhart07 Feb 16, 2026
36608ed
so many review comments help
dburkhart07 Feb 17, 2026
f4b32a9
i forgot prettier
dburkhart07 Feb 17, 2026
3c9e869
Merged main
dburkhart07 Feb 18, 2026
e2a858d
Merged main
dburkhart07 Feb 18, 2026
acfe838
Merged main
dburkhart07 Feb 18, 2026
9c0fd79
Fixed width
dburkhart07 Feb 18, 2026
74036f1
amy changes
dburkhart07 Feb 19, 2026
fbb1e9a
Added frontend testing procedure for new function
dburkhart07 Feb 19, 2026
dadba87
Moved all logic around to backend
dburkhart07 Feb 20, 2026
107fea2
yipppee hooray more changes
dburkhart07 Feb 20, 2026
c116f60
sorry amy i forgot ab these :/
dburkhart07 Feb 20, 2026
e7dc2e7
Final commit praying
dburkhart07 Feb 21, 2026
01f5f5a
Merged main
dburkhart07 Feb 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/backend/src/config/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import { UpdatePantryFields1763762628431 } from '../migrations/1763762628431-Upd
import { PopulateDummyData1768501812134 } from '../migrations/1768501812134-populateDummyData';
import { RemovePantryFromOrders1769316004958 } from '../migrations/1769316004958-RemovePantryFromOrders';
import { AddDonationRecurrenceFields1770080947285 } from '../migrations/1770080947285-AddDonationRecurrenceFields';
import { AddFoodRescueToDonationItems1770679339809 } from '../migrations/1770679339809-AddFoodRescueToDonationItems';
import { UpdateManufacturerEntity1768680807820 } from '../migrations/1768680807820-UpdateManufacturerEntity';
import { AddUserPoolId1769189327767 } from '../migrations/1769189327767-AddUserPoolId';
import { UpdateOrderEntity1769990652833 } from '../migrations/1769990652833-UpdateOrderEntity';
import { RenameDonationMatchingStatus1771260403657 } from '../migrations/1771260403657-RenameDonationMatchingStatus';

const schemaMigrations = [
User1725726359198,
Expand Down Expand Up @@ -59,9 +61,11 @@ const schemaMigrations = [
PopulateDummyData1768501812134,
RemovePantryFromOrders1769316004958,
AddDonationRecurrenceFields1770080947285,
AddFoodRescueToDonationItems1770679339809,
UpdateManufacturerEntity1768680807820,
AddUserPoolId1769189327767,
UpdateOrderEntity1769990652833,
RenameDonationMatchingStatus1771260403657,
];

export default schemaMigrations;
23 changes: 13 additions & 10 deletions apps/backend/src/donationItems/donationItems.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ import { FoodType } from './types';
@Entity('donation_items')
export class DonationItem {
@PrimaryGeneratedColumn({ name: 'item_id' })
itemId: number;
itemId!: number;

@Column({ name: 'donation_id', type: 'int' })
donationId: number;
donationId!: number;

@ManyToOne(() => Donation, { nullable: false })
@JoinColumn({ name: 'donation_id', referencedColumnName: 'donationId' })
donation: Donation;
donation!: Donation;

@Column({ name: 'item_name', type: 'varchar', length: 255 })
itemName: string;
itemName!: string;

@Column({ name: 'quantity', type: 'int' })
quantity: number;
quantity!: number;

@Column({ name: 'reserved_quantity', type: 'int', default: 0 })
reservedQuantity: number;
reservedQuantity!: number;

@Column({ name: 'oz_per_item', type: 'int', nullable: true })
ozPerItem: number;
ozPerItem?: number;

@Column({ name: 'estimated_value', type: 'int', nullable: true })
estimatedValue: number;
estimatedValue?: number;

@Column({
name: 'food_type',
Expand All @@ -44,8 +44,11 @@ export class DonationItem {
enumName: 'food_type_enum',
nullable: true,
})
foodType: FoodType;
foodType?: FoodType;

@OneToMany(() => Allocation, (allocation) => allocation.item)
allocations: Allocation[];
allocations!: Allocation[];

@Column({ name: 'food_rescue', type: 'boolean', default: false })
foodRescue!: boolean;
}
14 changes: 14 additions & 0 deletions apps/backend/src/donations/donations.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DonationService } from './donations.service';
import { DonationsController } from './donations.controller';
import { Test, TestingModule } from '@nestjs/testing';
import { mock } from 'jest-mock-extended';
import { Donation } from './donations.entity';

const mockDonationService = mock<DonationService>();

Expand Down Expand Up @@ -38,4 +39,17 @@ describe('DonationsController', () => {
expect(mockDonationService.getNumberOfDonations).toHaveBeenCalled();
});
});

describe('GET /:donationId', () => {
it('should return a donation for a given donation ID', async () => {
const mockDonation: Partial<Donation> = { donationId: 1 };

mockDonationService.findOne.mockResolvedValue(mockDonation as Donation);

const result = await controller.getDonation(1);

expect(result).toBe(mockDonation);
expect(mockDonationService.findOne).toHaveBeenCalledWith(1);
});
});
});
27 changes: 12 additions & 15 deletions apps/backend/src/donations/donations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
Param,
NotFoundException,
ParseIntPipe,
BadRequestException,
} from '@nestjs/common';
import { ApiBody } from '@nestjs/swagger';
import { Donation } from './donations.entity';
import { DonationService } from './donations.service';
import { DonationStatus, RecurrenceEnum } from './types';
import { RecurrenceEnum } from './types';
import { CreateDonationDto } from './dtos/create-donation.dto';

@Controller('donations')
Expand Down Expand Up @@ -43,15 +42,6 @@ export class DonationsController {
type: 'object',
properties: {
foodManufacturerId: { type: 'integer', example: 1 },
dateDonated: {
type: 'string',
format: 'date-time',
},
status: {
type: 'string',
enum: Object.values(DonationStatus),
example: DonationStatus.AVAILABLE,
},
totalItems: { type: 'integer', example: 100 },
totalOz: { type: 'number', example: 100.5 },
totalEstimatedValue: { type: 'number', example: 100.5 },
Expand All @@ -61,11 +51,18 @@ export class DonationsController {
example: RecurrenceEnum.NONE,
},
recurrenceFreq: { 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'],
repeatOnDays: {
type: 'object',
nullable: true,
properties: {
Sunday: { type: 'boolean', example: false },
Monday: { type: 'boolean', example: true },
Tuesday: { type: 'boolean', example: false },
Wednesday: { type: 'boolean', example: false },
Thursday: { type: 'boolean', example: false },
Friday: { type: 'boolean', example: false },
Saturday: { type: 'boolean', example: false },
},
},
occurrencesRemaining: { type: 'integer', example: 2, nullable: true },
},
Expand Down
7 changes: 1 addition & 6 deletions apps/backend/src/donations/donations.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { Donation } from './donations.entity';
import { DonationService } from './donations.service';
import { DonationsController } from './donations.controller';
import { ManufacturerModule } from '../foodManufacturers/manufacturer.module';
import { AuthModule } from '../auth/auth.module';
import { FoodManufacturer } from '../foodManufacturers/manufacturers.entity';
import { DonationsSchedulerService } from './donations.scheduler';

@Module({
imports: [
TypeOrmModule.forFeature([Donation, FoodManufacturer]),
ManufacturerModule,
AuthModule,
],
imports: [TypeOrmModule.forFeature([Donation, FoodManufacturer]), AuthModule],
controllers: [DonationsController],
providers: [DonationService, DonationsSchedulerService],
})
Expand Down
Loading