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: 3 additions & 0 deletions apps/backend/src/foodManufacturers/manufacturers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class FoodManufacturersService {

const foodManufacturer = await this.repo.findOne({
where: { foodManufacturerId },
relations: ['foodManufacturerRepresentative'],
});

if (!foodManufacturer) {
Expand Down Expand Up @@ -121,6 +122,7 @@ export class FoodManufacturersService {

const foodManufacturer = await this.repo.findOne({
where: { foodManufacturerId: id },
relations: ['foodManufacturerRepresentative'],
});
if (!foodManufacturer) {
throw new NotFoundException(`Food Manufacturer ${id} not found`);
Expand All @@ -147,6 +149,7 @@ export class FoodManufacturersService {

const foodManufacturer = await this.repo.findOne({
where: { foodManufacturerId: id },
relations: ['foodManufacturerRepresentative'],
});
if (!foodManufacturer) {
throw new NotFoundException(`Food Manufacturer ${id} not found`);
Expand Down
26 changes: 26 additions & 0 deletions apps/frontend/src/api/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ export class ApiClient {
.then((response) => response.data);
}

public async getAllPendingFoodManufacturers(): Promise<FoodManufacturer[]> {
return this.axiosInstance
.get('/api/manufacturers/pending')
.then((response) => response.data);
}

public async getFoodManufacturer(
manufacturerId: number,
): Promise<FoodManufacturer> {
return this.get(
`/api/manufacturers/${manufacturerId}`,
) as Promise<FoodManufacturer>;
}

public async getPantryFromOrder(orderId: number): Promise<Pantry | null> {
return this.axiosInstance
.get(`/api/orders/${orderId}/pantry`)
Expand Down Expand Up @@ -289,6 +303,18 @@ export class ApiClient {
});
}

public async updateFoodManufacturer(
manufacturerId: number,
decision: 'approve' | 'deny',
): Promise<void> {
await this.axiosInstance.patch(
`/api/manufacturers/${manufacturerId}/${decision}`,
{
manufacturerId,
},
);
}

public async getPantryRequests(pantryId: number): Promise<FoodRequest[]> {
const data = await this.get(`/api/requests/${pantryId}/all`);
return data as FoodRequest[];
Expand Down
18 changes: 18 additions & 0 deletions apps/frontend/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { Authenticator } from '@aws-amplify/ui-react';
import FoodManufacturerApplication from '@containers/foodManufacturerApplication';
import { submitManufacturerApplicationForm } from '@components/forms/manufacturerApplicationForm';
import AssignedPantries from '@containers/volunteerAssignedPantries';
import ApproveFoodManufacturers from '@containers/approveFoodManufacturers';
import FoodManufacturerApplicationDetails from '@containers/foodManufacturerApplicationDetails';

Amplify.configure(CognitoAuthConfig);

Expand Down Expand Up @@ -154,6 +156,14 @@ const router = createBrowserRouter([
</ProtectedRoute>
),
},
{
path: '/approve-food-manufacturers',
element: (
<ProtectedRoute>
<ApproveFoodManufacturers />
</ProtectedRoute>
),
},
{
path: '/pantry-application-details/:applicationId',
element: (
Expand All @@ -162,6 +172,14 @@ const router = createBrowserRouter([
</ProtectedRoute>
),
},
{
path: '/food-manufacturer-application-details/:applicationId',
element: (
<ProtectedRoute>
<FoodManufacturerApplicationDetails />
</ProtectedRoute>
),
},
{
path: '/admin-donation',
element: (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Dialog, Text, Box, Button, CloseButton } from '@chakra-ui/react';
import { capitalize } from '@utils/utils';

interface ConfirmFoodManufacturerDecisionModalProps {
isOpen: boolean;
onClose: () => void;
onConfirm: () => void;
decision: string;
foodManufacturerName: string;
dateApplied: string;
}

const ConfirmFoodManufacturerDecisionModal: React.FC<
ConfirmFoodManufacturerDecisionModalProps
> = ({
isOpen,
onClose,
onConfirm,
decision,
foodManufacturerName,
dateApplied,
}) => {
return (
<Dialog.Root
open={isOpen}
onOpenChange={(e: { open: boolean }) => !e.open && onClose()}
>
<Dialog.Backdrop />
<Dialog.Positioner>
<Dialog.Content maxW="500px">
<Dialog.Header pb={0}>
<Dialog.Title fontSize="lg" fontWeight={600}>
Confirm Action
</Dialog.Title>
</Dialog.Header>

<Dialog.Body pb={4}>
<Text mb={4} color="gray.dark">
Are you sure you want to {decision} this application?
</Text>

<Box
p={6}
borderRadius="md"
border="1px solid"
borderColor="neutral.100"
>
<Text textStyle="p2">{foodManufacturerName}</Text>
<Text textStyle="p3" color="neutral.600">
Applied {dateApplied}
</Text>
</Box>
<Dialog.CloseTrigger asChild>
<CloseButton />
</Dialog.CloseTrigger>
</Dialog.Body>

<Dialog.Footer gap={2}>
<Button
variant="outline"
onClick={onClose}
borderColor="neutral.200"
color="neutral.800"
textStyle="p2"
fontWeight={600}
>
Cancel
</Button>
<Button
bg="blue.hover"
color="white"
onClick={() => {
onConfirm();
onClose();
}}
_hover={{ bg: 'neutral.800' }}
px={12}
textStyle="p2"
fontWeight={600}
>
{capitalize(decision)}
</Button>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Positioner>
</Dialog.Root>
);
};

export default ConfirmFoodManufacturerDecisionModal;
Loading
Loading