Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions apps/backend/src/config/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { MakeFoodRescueRequired1773889925002 } from '../migrations/1773889925002
import { AddDonationItemConfirmation1774140453305 } from '../migrations/1774140453305-AddDonationItemConfirmation';
import { DonationItemsOnDeleteCascade1774214910101 } from '../migrations/1774214910101-DonationItemsOnDeleteCascade';
import { OrdersVolunteerActions1774883880543 } from '../migrations/1774883880543-OrdersVolunteerActions';
import { UpdatePantryFMApplicationInfo1780913024514 } from '../migrations/1780913024514-UpdatePantryFMApplicationInfo';

const schemaMigrations = [
User1725726359198,
Expand Down Expand Up @@ -86,6 +87,7 @@ const schemaMigrations = [
AddDonationItemConfirmation1774140453305,
DonationItemsOnDeleteCascade1774214910101,
OrdersVolunteerActions1774883880543,
UpdatePantryFMApplicationInfo1780913024514,
];

export default schemaMigrations;
10 changes: 6 additions & 4 deletions apps/backend/src/donations/donations.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,12 @@ describe('DonationService', () => {
expect(d.foodManufacturer).toBeDefined();
});

const firstDonation = donations[0];
expect(firstDonation.status).toBe(DonationStatus.MATCHED);
expect(firstDonation.foodManufacturer.foodManufacturerId).toBe(2);
expect(firstDonation.recurrence).toBe(RecurrenceEnum.NONE);
const matchedDonation = donations.find(
(d) => d.status === DonationStatus.MATCHED,
);
expect(matchedDonation).toBeDefined();
expect(matchedDonation?.foodManufacturer.foodManufacturerId).toBe(2);
expect(matchedDonation?.recurrence).toBe(RecurrenceEnum.NONE);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Length,
MaxLength,
} from 'class-validator';
import { Allergen, DonateWastedFood, ManufacturerAttribute } from '../types';
import { Allergen, DonateWastedFood } from '../types';

export class FoodManufacturerApplicationDto {
@IsString()
Expand Down Expand Up @@ -84,9 +84,6 @@ export class FoodManufacturerApplicationDto {
@IsBoolean()
productsGlutenFree!: boolean;

@IsBoolean()
productsContainSulfites!: boolean;

@IsString()
@IsNotEmpty()
productsSustainableExplanation!: string;
Expand All @@ -97,16 +94,8 @@ export class FoodManufacturerApplicationDto {
@IsEnum(DonateWastedFood)
donateWastedFood!: DonateWastedFood;

@IsOptional()
@IsEnum(ManufacturerAttribute)
manufacturerAttribute?: ManufacturerAttribute;

@IsOptional()
@IsString()
@IsNotEmpty()
additionalComments?: string;

@IsOptional()
@IsBoolean()
newsletterSubscription?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Length,
MaxLength,
} from 'class-validator';
import { Allergen, DonateWastedFood, ManufacturerAttribute } from '../types';
import { Allergen, DonateWastedFood } from '../types';

export class UpdateFoodManufacturerApplicationDto {
@IsOptional()
Expand Down Expand Up @@ -69,10 +69,6 @@ export class UpdateFoodManufacturerApplicationDto {
@IsBoolean()
productsGlutenFree?: boolean;

@IsOptional()
@IsBoolean()
productsContainSulfites?: boolean;

@IsOptional()
@IsString()
@IsNotEmpty()
Expand All @@ -86,16 +82,8 @@ export class UpdateFoodManufacturerApplicationDto {
@IsEnum(DonateWastedFood)
donateWastedFood?: DonateWastedFood;

@IsOptional()
@IsEnum(ManufacturerAttribute)
manufacturerAttribute?: ManufacturerAttribute;

@IsOptional()
@IsString()
@IsNotEmpty()
additionalComments?: string;

@IsOptional()
@IsBoolean()
newsletterSubscription?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ describe('FoodManufacturersController', () => {
unlistedProductAllergens: [Allergen.EGG],
facilityFreeAllergens: [Allergen.EGG],
productsGlutenFree: true,
productsContainSulfites: false,
productsSustainableExplanation: 'We use eco-friendly packaging.',
inKindDonations: true,
donateWastedFood: DonateWastedFood.SOMETIMES,
Expand Down
16 changes: 1 addition & 15 deletions apps/backend/src/foodManufacturers/manufacturers.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FoodManufacturersService } from './manufacturers.service';
import { FoodManufacturer } from './manufacturers.entity';
import { FoodManufacturerApplicationDto } from './dtos/manufacturer-application.dto';
import { ApiBody } from '@nestjs/swagger';
import { Allergen, DonateWastedFood, ManufacturerAttribute } from './types';
import { Allergen, DonateWastedFood } from './types';
import { Public } from '../auth/public.decorator';
import { UpdateFoodManufacturerApplicationDto } from './dtos/update-manufacturer-application.dto';
import { Roles } from '../auth/roles.decorator';
Expand Down Expand Up @@ -155,10 +155,6 @@ export class FoodManufacturersController {
type: 'boolean',
example: true,
},
productsContainSulfites: {
type: 'boolean',
example: false,
},
productsSustainableExplanation: {
type: 'string',
example: 'Our products are environmentally conscious.',
Expand All @@ -172,19 +168,10 @@ export class FoodManufacturersController {
enum: Object.values(DonateWastedFood),
example: DonateWastedFood.ALWAYS,
},
manufacturerAttribute: {
type: 'string',
enum: Object.values(ManufacturerAttribute),
example: ManufacturerAttribute.ORGANIC,
},
additionalComments: {
type: 'string',
example: 'Nope!',
},
newsletterSubscription: {
type: 'boolean',
example: true,
},
},
required: [
'foodManufacturerName',
Expand All @@ -196,7 +183,6 @@ export class FoodManufacturersController {
'unlistedProductAllergens',
'facilityFreeAllergens',
'productsGlutenFree',
'productsContainSulfites',
'productsSustainableExplanation',
'inKindDonations',
'donateWastedFood',
Expand Down
17 changes: 1 addition & 16 deletions apps/backend/src/foodManufacturers/manufacturers.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'typeorm';
import { User } from '../users/users.entity';
import { Donation } from '../donations/donations.entity';
import { Allergen, DonateWastedFood, ManufacturerAttribute } from './types';
import { Allergen, DonateWastedFood } from './types';
import { ApplicationStatus } from '../shared/types';

@Entity('food_manufacturers')
Expand Down Expand Up @@ -86,9 +86,6 @@ export class FoodManufacturer {
@Column({ name: 'products_gluten_free', type: 'boolean' })
productsGlutenFree!: boolean;

@Column({ name: 'products_contain_sulfites', type: 'boolean' })
productsContainSulfites!: boolean;

@Column({
name: 'products_sustainable_explanation',
type: 'text',
Expand All @@ -106,25 +103,13 @@ export class FoodManufacturer {
})
donateWastedFood!: DonateWastedFood;

@Column({
name: 'manufacturer_attribute',
type: 'enum',
enum: ManufacturerAttribute,
enumName: 'manufacturer_attribute_enum',
nullable: true,
})
manufacturerAttribute!: ManufacturerAttribute | null;

@Column({
name: 'additional_comments',
type: 'text',
nullable: true,
})
additionalComments!: string | null;

@Column({ name: 'newsletter_subscription', type: 'boolean', nullable: true })
newsletterSubscription!: boolean | null;

@OneToMany(() => Donation, (donation) => donation.foodManufacturer)
donations!: Donation[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { AuthService } from '../auth/auth.service';
import { EmailsService } from '../emails/email.service';
import { mock } from 'jest-mock-extended';
import { emailTemplates, SSF_PARTNER_EMAIL } from '../emails/emailTemplates';
import { Allergen, DonateWastedFood, ManufacturerAttribute } from './types';
import { Allergen, DonateWastedFood } from './types';
import { DonationItemsService } from '../donationItems/donationItems.service';
import { DonationItem } from '../donationItems/donationItems.entity';
import { DataSource } from 'typeorm';
Expand Down Expand Up @@ -48,7 +48,6 @@ const dto: FoodManufacturerApplicationDto = {
unlistedProductAllergens: [Allergen.SHELLFISH, Allergen.TREE_NUTS],
facilityFreeAllergens: [Allergen.PEANUT, Allergen.FISH],
productsGlutenFree: false,
productsContainSulfites: false,
productsSustainableExplanation: 'none',
inKindDonations: false,
donateWastedFood: DonateWastedFood.ALWAYS,
Expand Down Expand Up @@ -296,9 +295,7 @@ describe('FoodManufacturersService', () => {
secondaryContactLastName: 'Johnson',
secondaryContactEmail: 'sarah.johnson@example.com',
secondaryContactPhone: '555-555-5557',
manufacturerAttribute: ManufacturerAttribute.ORGANIC,
additionalComments: 'We specialize in allergen-free products',
newsletterSubscription: true,
};

await service.addFoodManufacturer(optionalDto);
Expand All @@ -314,7 +311,6 @@ describe('FoodManufacturersService', () => {
);
expect(saved?.status).toBe(ApplicationStatus.PENDING);
expect(saved?.secondaryContactFirstName).toBe('Sarah');
expect(saved?.manufacturerAttribute).toBe(ManufacturerAttribute.ORGANIC);
});

it('should still save manufacturer to database if representative email send fails', async () => {
Expand Down
6 changes: 0 additions & 6 deletions apps/backend/src/foodManufacturers/manufacturers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,12 @@ export class FoodManufacturersService {
foodManufacturerData.facilityFreeAllergens;
foodManufacturer.productsGlutenFree =
foodManufacturerData.productsGlutenFree;
foodManufacturer.productsContainSulfites =
foodManufacturerData.productsContainSulfites;
foodManufacturer.productsSustainableExplanation =
foodManufacturerData.productsSustainableExplanation;
foodManufacturer.inKindDonations = foodManufacturerData.inKindDonations;
foodManufacturer.donateWastedFood = foodManufacturerData.donateWastedFood;
foodManufacturer.manufacturerAttribute =
foodManufacturerData.manufacturerAttribute ?? null;
foodManufacturer.additionalComments =
foodManufacturerData.additionalComments ?? null;
foodManufacturer.newsletterSubscription =
foodManufacturerData.newsletterSubscription ?? null;

await this.repo.save(foodManufacturer);

Expand Down
8 changes: 0 additions & 8 deletions apps/backend/src/foodManufacturers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,4 @@ export enum Allergen {
FISH = 'Fish',
SHELLFISH = 'Shellfish',
SESAME = 'Sesame',
GLUTEN = 'Gluten',
}

export enum ManufacturerAttribute {
FEMALE = 'Female-founded or women-led',
NON_GMO = 'Non-GMO Project Verified',
ORGANIC = 'USDA Certified Organic',
NONE = 'None of the above',
}
Loading
Loading