Repository navigation
Nathan/donor offer bugs - #341
Conversation
✅ Deploy Preview for hope-for-haiti ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Greptile SummaryThis PR fixes two bugs: it hides the "Create Donor Offer" button on the Finalized and Archived tabs, and adds client-side validation to prevent past deadlines when creating a donor offer.
Confidence Score: 4/5Safe to merge after fixing the date-validation bypass in handleSubmit; the tab-button fix is correct as-is. One P1 finding: the new date validation is applied only at file-upload time and can be trivially bypassed by editing dates afterward, defeating the stated goal of the PR. The tab-button change is clean and correct. src/app/donorOffers/create/page.tsx — handleSubmit needs the same date guard that was added to validateBeforeUpload. Important Files Changed
|
| const getTodayDateString = () => { | ||
| const date = new Date(); | ||
| const year = date.getFullYear(); | ||
| const month = String(date.getMonth() + 1).padStart(2, '0'); | ||
| const day = String(date.getDate()).padStart(2, '0'); | ||
|
|
||
| return `${year}-${month}-${day}`; | ||
| }; |
There was a problem hiding this comment.
getTodayDateString should be a module-level utility
This function doesn't close over any component state or props, so defining it inside the component creates a new function reference on every render. Move it outside the component (or to a shared utility file).
| const getTodayDateString = () => { | |
| const date = new Date(); | |
| const year = date.getFullYear(); | |
| const month = String(date.getMonth() + 1).padStart(2, '0'); | |
| const day = String(date.getDate()).padStart(2, '0'); | |
| return `${year}-${month}-${day}`; | |
| }; | |
| const getTodayDateString = () => { | |
| const date = new Date(); | |
| const year = date.getFullYear(); | |
| const month = String(date.getMonth() + 1).padStart(2, '0'); | |
| const day = String(date.getDate()).padStart(2, '0'); | |
| return `${year}-${month}-${day}`; | |
| }; | |
| export default function CreateDonorOfferPage() { |
Description
Resolves ticket number: #327 & #330
Explain what your code changes: Removed create donor offer button from finalized and archived tabs. Added date validation create donor offer screen.
List the steps you took to test your code: Visually confirmed and tested invalid dates.
Checklist