From b104fa90ffb61c0549a6a26973c03f8f75b3403e Mon Sep 17 00:00:00 2001 From: lyannne Date: Sun, 9 Aug 2026 18:50:15 -0400 Subject: [PATCH 1/3] made optional fields --- frontend/src/components/FieldLabel.tsx | 20 ++++++++++ .../main-page/grants/edit-grant/EditGrant.tsx | 8 ++-- .../edit-grant/components/EditGrantInfo.tsx | 37 ++++++++++--------- .../main-page/grants/grant-view/GrantView.tsx | 18 ++++++--- .../grant-view/components/GrantCard.tsx | 12 +++--- 5 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 frontend/src/components/FieldLabel.tsx diff --git a/frontend/src/components/FieldLabel.tsx b/frontend/src/components/FieldLabel.tsx new file mode 100644 index 00000000..8f880701 --- /dev/null +++ b/frontend/src/components/FieldLabel.tsx @@ -0,0 +1,20 @@ +import type { ReactNode } from "react"; + +type FieldLabelProps = { + isRequired?: boolean; + className?: string; + children: ReactNode; +}; + +export default function FieldLabel({ + isRequired, + className, + children, +}: FieldLabelProps) { + return ( + + ); +} diff --git a/frontend/src/main-page/grants/edit-grant/EditGrant.tsx b/frontend/src/main-page/grants/edit-grant/EditGrant.tsx index 30944924..dbf859c1 100644 --- a/frontend/src/main-page/grants/edit-grant/EditGrant.tsx +++ b/frontend/src/main-page/grants/edit-grant/EditGrant.tsx @@ -81,27 +81,27 @@ const EditGrant: React.FC<{ if (!form.organization.trim()) return "Organization Name is required"; if (!form.status) return "Status is required"; if (form.amount == null || form.amount <= 0) return "Amount must be greater than 0"; - if (!form.applicationDeadline) return "Due Date is required"; if ( form.applicationDate && + form.applicationDeadline && new Date(form.applicationDate).getTime() > new Date(form.applicationDeadline).getTime() ) { return "Application Date cannot be after Due Date"; } - if (!form.grantStartDate) return "Grant Start Date is required"; if ( + form.grantStartDate && + form.applicationDeadline && new Date(form.grantStartDate).getTime() < new Date(form.applicationDeadline).getTime() ) { return "Grant Start Date cannot be before Due Date"; } - if (!form.estimatedCompletionTime || form.estimatedCompletionTime <= 0) return "Estimated completion time must be greater than 0"; + if (form.estimatedCompletionTime < 0) return "Estimated completion time cannot be negative"; if (!form.doesBcanQualify) return "BCAN eligibility is required"; if(form.reportDates.length > 0 && !form.reportDates.every((date) => date !== "")) return "Report deadlines must have a value"; if (!form.timeline || form.timeline <= 0) return "Timeline must be greater than 0"; if (!form.bcanPocEmail) return "BCAN contact required"; - if (!form.grantProviderPocEmail) return "Grant provider contact required"; if(form.attachments.length > 0 && !form.attachments.every((attachment) => attachment.url !== "")) return "Attachments must have a value"; return null; }; diff --git a/frontend/src/main-page/grants/edit-grant/components/EditGrantInfo.tsx b/frontend/src/main-page/grants/edit-grant/components/EditGrantInfo.tsx index faa9f4b5..8c6b11ca 100644 --- a/frontend/src/main-page/grants/edit-grant/components/EditGrantInfo.tsx +++ b/frontend/src/main-page/grants/edit-grant/components/EditGrantInfo.tsx @@ -8,6 +8,7 @@ import { faSquareXmark, } from "@fortawesome/free-solid-svg-icons"; import EditGrantDeleteItem from "./EditGrantDeleteItem"; +import FieldLabel from "../../../../components/FieldLabel"; type EditGrantProps = { form: GrantFormState; @@ -18,9 +19,9 @@ export default function EditGrantInfo({ form, dispatch }: EditGrantProps) { return (
- +