Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,17 @@ const EditablePantryApplication: React.FC<EditablePantryApplicationProps> = ({
secondaryContactEmail: form.secondaryContactEmail || null,
secondaryContactPhone: form.secondaryContactPhone || null,
shipmentAddressLine1: form.shipmentLine1 || undefined,
shipmentAddressLine2: form.shipmentLine2 || undefined,
shipmentAddressLine2: form.shipmentLine2 || null,
shipmentAddressCity: form.shipmentCity || undefined,
shipmentAddressState: form.shipmentState || undefined,
shipmentAddressZip: form.shipmentZip || undefined,
shipmentAddressCountry: form.shipmentCountry || undefined,
shipmentAddressCountry: form.shipmentCountry || null,
mailingAddressLine1: form.mailingLine1 || undefined,
mailingAddressLine2: form.mailingLine2 || undefined,
mailingAddressLine2: form.mailingLine2 || null,
mailingAddressCity: form.mailingCity || undefined,
mailingAddressState: form.mailingState || undefined,
mailingAddressZip: form.mailingZip || undefined,
mailingAddressCountry: form.mailingCountry || undefined,
mailingAddressCountry: form.mailingCountry || null,
acceptFoodDeliveries: form.acceptFoodDeliveries === 'Yes',
deliveryWindowInstructions:
form.deliveryWindowInstructions || undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ const PantryApplicationForm: React.FC = () => {
</Field.HelperText>
<NativeSelect.Root>
<NativeSelect.Field
required
value={allergenClients}
onChange={(e) => setAllergenClients(e.target.value)}
placeholder="Select an option"
Expand Down
12 changes: 11 additions & 1 deletion apps/frontend/src/components/forms/requestDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,17 @@ const RequestDetailsModal: React.FC<RequestDetailsModalProps> = ({
additionalNotes !== '' ? 'neutral.800' : 'neutral.300'
}
value={additionalNotes}
onChange={(e) => setAdditionalNotes(e.target.value)}
onChange={(e) => {
const words = e.target.value.trim().split(/\s+/);
if (words.length <= 250) {
setAdditionalNotes(e.target.value);
} else {
setAlertMessage(
'Exceeded word limit',
AlertStatus.ERROR,
);
}
}}
/>
<Field.HelperText color="neutral.600">
Max 250 words
Expand Down
164 changes: 90 additions & 74 deletions apps/frontend/src/containers/formRequests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useSearchParams, useNavigate } from 'react-router-dom';
import { ROUTES } from '../routes';
import { AlertStatus } from '../types/types';
import { PaginationControl } from '@components/pagination';
import PageEmptyState from '@components/pageEmptyState';

const FormRequests: React.FC = () => {
const [currentPage, setCurrentPage] = useState<number>(1);
Expand All @@ -46,7 +47,13 @@ const FormRequests: React.FC = () => {
const pageSize = 10;

const fetchRequests = useCallback(async () => {
const pantryId = await ApiClient.getCurrentUserPantryId();
let pantryId: number | undefined;
try {
pantryId = await ApiClient.getCurrentUserPantryId();
} catch {
setAlertMessage('Error fetching pantry', AlertStatus.ERROR);
return;
}
setPantryId(pantryId);
if (pantryId) {
try {
Expand Down Expand Up @@ -87,9 +94,10 @@ const FormRequests: React.FC = () => {
setCurrentPage(Math.floor(idx / pageSize) + 1);
}
} else {
setAlertMessage('Request not found.', AlertStatus.ERROR);
navigate(ROUTES.REQUEST_FORM, { replace: true });
}
}, [searchParams, requests, navigate]);
}, [searchParams, requests, navigate, setAlertMessage]);

const paginatedRequests = requests.slice(
(currentPage - 1) * pageSize,
Expand Down Expand Up @@ -156,79 +164,87 @@ const FormRequests: React.FC = () => {
</>
)}
</HStack>
<Table.Root mt={6} variant="line" showColumnBorder>
<Table.Header>
<Table.Row>
<Table.ColumnHeader
color="neutral.800"
textStyle="p2"
fontWeight={600}
>
Request #
</Table.ColumnHeader>
<Table.ColumnHeader
color="neutral.800"
textStyle="p2"
fontWeight={600}
>
Status
</Table.ColumnHeader>
<Table.ColumnHeader
color="neutral.800"
textStyle="p2"
fontWeight={600}
textAlign="right"
>
Date Requested
</Table.ColumnHeader>
</Table.Row>
</Table.Header>
<Table.Body>
{paginatedRequests.map((request) => (
<Table.Row key={request.requestId}>
<Table.Cell color="gray.dark" textStyle="p2">
<Link
textDecorationColor="gray.dark"
variant="underline"
onClick={() => setOpenReadOnlyRequest(request)}
>
{request.requestId}
</Link>
</Table.Cell>
<Table.Cell>
{request.status === FoodRequestStatus.ACTIVE ? (
<Badge
bgColor="teal.200"
color="teal.hover"
textStyle="p2"
fontWeight={500}
fontSize={12}
py={1}
px={2}
>
Active
</Badge>
) : (
<Badge
bgColor="neutral.300"
color="gray.dark"
textStyle="p2"
fontWeight={500}
fontSize={12}
py={1}
px={2}
>
Closed
</Badge>
)}
</Table.Cell>
<Table.Cell color="neutral.700" textStyle="p2" textAlign="right">
{formatDate(request.requestedAt)}
</Table.Cell>
{requests.length === 0 ? (
<PageEmptyState entity="food requests" />
) : (
<Table.Root mt={6} variant="line" showColumnBorder>
<Table.Header>
<Table.Row>
<Table.ColumnHeader
color="neutral.800"
textStyle="p2"
fontWeight={600}
>
Request #
</Table.ColumnHeader>
<Table.ColumnHeader
color="neutral.800"
textStyle="p2"
fontWeight={600}
>
Status
</Table.ColumnHeader>
<Table.ColumnHeader
color="neutral.800"
textStyle="p2"
fontWeight={600}
textAlign="right"
>
Date Requested
</Table.ColumnHeader>
</Table.Row>
))}
</Table.Body>
</Table.Root>
</Table.Header>
<Table.Body>
{paginatedRequests.map((request) => (
<Table.Row key={request.requestId}>
<Table.Cell color="gray.dark" textStyle="p2">
<Link
textDecorationColor="gray.dark"
variant="underline"
onClick={() => setOpenReadOnlyRequest(request)}
>
{request.requestId}
</Link>
</Table.Cell>
<Table.Cell>
{request.status === FoodRequestStatus.ACTIVE ? (
<Badge
bgColor="teal.200"
color="teal.hover"
textStyle="p2"
fontWeight={500}
fontSize={12}
py={1}
px={2}
>
Active
</Badge>
) : (
<Badge
bgColor="neutral.300"
color="gray.dark"
textStyle="p2"
fontWeight={500}
fontSize={12}
py={1}
px={2}
>
Closed
</Badge>
)}
</Table.Cell>
<Table.Cell
color="neutral.700"
textStyle="p2"
textAlign="right"
>
{formatDate(request.requestedAt)}
</Table.Cell>
</Table.Row>
))}
</Table.Body>
</Table.Root>
)}
{openReadOnlyRequest && !deleteRequest && (
<RequestDetailsModal
request={openReadOnlyRequest}
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/src/containers/pantryOrderManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ const PantryOrderManagement: React.FC = () => {
setSelectedOrderId(match.orderId);
}
} else {
setAlertMessage('Order not found.', AlertStatus.ERROR);
navigate(ROUTES.PANTRY_ORDER_MANAGEMENT, { replace: true });
}
}, [searchParams, statusOrders, navigate]);
}, [searchParams, statusOrders, navigate, setAlertMessage]);

// Helper to reset page for a specific status
const resetPageForStatus = (status: OrderStatus) => {
Expand Down
8 changes: 4 additions & 4 deletions apps/frontend/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ export interface UpdatePantryApplicationDto {
secondaryContactEmail?: string | null;
secondaryContactPhone?: string | null;
shipmentAddressLine1?: string;
shipmentAddressLine2?: string;
shipmentAddressLine2?: string | null;
shipmentAddressCity?: string;
shipmentAddressState?: string;
shipmentAddressZip?: string;
shipmentAddressCountry?: string;
shipmentAddressCountry?: string | null;
mailingAddressLine1?: string;
mailingAddressLine2?: string;
mailingAddressLine2?: string | null;
mailingAddressCity?: string;
mailingAddressState?: string;
mailingAddressZip?: string;
mailingAddressCountry?: string;
mailingAddressCountry?: string | null;
acceptFoodDeliveries?: boolean;
deliveryWindowInstructions?: string;
allergenClients?: string;
Expand Down
Loading