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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ npm-debug.log
yarn-error.log
testem.log
/typings
.nx

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here? Can we get rid of it?



# System Files
.DS_Store
Thumbs.db
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/pantries/dtos/pantry-application.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ export class PantryApplicationDto {
@IsOptional()
@IsBoolean()
newsletterSubscription?: boolean;
}
}
7 changes: 7 additions & 0 deletions apps/backend/src/pantries/pantries.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import {
Param,
ParseIntPipe,
Post,
Put,
ValidationPipe,
} from '@nestjs/common';
import { Pantry } from './pantries.entity';
import { PantriesService } from './pantries.service';
import { PantryApplicationDto } from './dtos/pantry-application.dto';
import { ApiBody } from '@nestjs/swagger';
import { ApprovedPantryResponse } from './types';
import {
Activity,
AllergensConfidence,
Expand All @@ -34,6 +36,11 @@ export class PantriesController {
return this.pantriesService.getPendingPantries();
}

@Get('/approved')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should write a test for this as well.

async getApprovedPantries(): Promise<ApprovedPantryResponse[]> {
return this.pantriesService.getApprovedPantriesWithVolunteers();
}

@Get('/:pantryId')
async getPantry(
@Param('pantryId', ParseIntPipe) pantryId: number,
Expand Down
38 changes: 38 additions & 0 deletions apps/backend/src/pantries/pantries.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { validateId } from '../utils/validation.utils';
import { PantryStatus } from './types';
import { PantryApplicationDto } from './dtos/pantry-application.dto';
import { Role } from '../users/types';
import { ApprovedPantryResponse } from './types';

@Injectable()
export class PantriesService {
Expand Down Expand Up @@ -110,6 +111,43 @@ export class PantriesService {
await this.repo.update(id, { status: PantryStatus.DENIED });
}

async getApprovedPantriesWithVolunteers(): Promise<ApprovedPantryResponse[]> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in the type.ts file, this will need to change too.

const pantries = await this.repo.find({
where: { status: PantryStatus.APPROVED },
relations: ['pantryUser', 'volunteers'],
});

return pantries.map((pantry) => ({
pantryId: pantry.pantryId,
pantryName: pantry.pantryName,
address: {
line1: pantry.shipmentAddressLine1,
line2: pantry.shipmentAddressLine2,
city: pantry.shipmentAddressCity,
state: pantry.shipmentAddressState,
zip: pantry.shipmentAddressZip,
country: pantry.shipmentAddressCountry,
},
contactInfo: {
firstName: pantry.pantryUser.firstName,
lastName: pantry.pantryUser.lastName,
email: pantry.pantryUser.email,
phone: pantry.pantryUser.phone,
},
refrigeratedDonation: pantry.refrigeratedDonation,
allergenClients: pantry.allergenClients,
status: pantry.status,
dateApplied: pantry.dateApplied,
assignedVolunteers: (pantry.volunteers || []).map((volunteer) => ({
userId: volunteer.id,
name: `${volunteer.firstName} ${volunteer.lastName}`,
email: volunteer.email,
phone: volunteer.phone,
role: volunteer.role,
})),
}));
}

async findByIds(pantryIds: number[]): Promise<Pantry[]> {
pantryIds.forEach((id) => validateId(id, 'Pantry'));

Expand Down
32 changes: 32 additions & 0 deletions apps/backend/src/pantries/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
export interface ApprovedPantryResponse {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are going to need more info than this for our approved pantry response. For one, all these pantries are approved so we shouldnt need the status. Additionally, check out the Figma for the frontend: https://www.figma.com/design/brc5luMhizIFp893XIutYe/SP26---SSF-Designs?node-id=756-11085&t=3UiKr0MdYxCcdUUK-0

The modal that pops up with Pantry Details should tell you what information we need.

pantryId: number;
pantryName: string;
address: {
line1: string;
line2: string | null;
city: string;
state: string;
zip: string;
country: string | null;
};
contactInfo: {
firstName: string;
lastName: string;
email: string;
phone: string;
};
refrigeratedDonation: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the enum

allergenClients: string;
status: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

dateApplied: Date;
assignedVolunteers: AssignedVolunteer[];
}

export interface AssignedVolunteer {
userId: number;
name: string;
email: string;
phone: string;
role: string;
}

export enum RefrigeratedDonation {
YES = 'Yes, always',
NO = 'No',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,4 +1252,4 @@ export const submitPantryApplicationForm: ActionFunction = async ({
: null;
};

export default PantryApplicationForm;
export default PantryApplicationForm;
2 changes: 1 addition & 1 deletion apps/frontend/src/components/forms/usPhoneInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ export const USPhoneInput: React.FC<USPhoneInputProps> = ({
{...inputProps}
/>
);
};
};
2 changes: 1 addition & 1 deletion apps/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ root.render(
<App />
</ChakraProvider>
</StrictMode>,
);
);
2 changes: 1 addition & 1 deletion apps/frontend/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ const customConfig = defineConfig({
},
});

export const system = createSystem(defaultConfig, customConfig);
export const system = createSystem(defaultConfig, customConfig);
Loading