wise-old-man
wise-old-man copied to clipboard
[app] Prevent custom periods before 2013
Looking to address #1373
I wasn't sure if there was already a component that can handle something like this, so I wrote it as a ternary for the time being. If there's already an abstract component that exists that I can use, please point me in that direction and I'll use that instead.
I also wasn't sure if there were any contribution guides for labels and generalized styling choices. I looked around but was able to find anything. I thought this implementation was simple enough in terms of visual queues, but when hitting another error (trying to update too fast), I saw a red X in a toast notification.
@Sharpienero is attempting to deploy a commit to the wiseoldman Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
wise-old-man | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Dec 11, 2023 10:59pm |
This is very nice, the "invalid state" looks great, could you apply the same logic to the end date?
I also wasn't sure if there were any contribution guides for labels and generalized styling choices. I looked around but was able to find anything.
We don't have any formal guidelines for these
@psikoi For clarification's sake, by the same
logic, do you mean making the max range currentYear, or do you mean making the min range 2013? Or both?
Added a few conditions: Bad start date, bad end date (e.g in the future) and start date greater than end date. Those will all display an error similar to what you liked before, but now give additional information to the user
Is there anything you'd like me to change about this implementation @psikoi?
Sorry for the delay on the review, a bit busy IRL atm.
I do think you have overcomplicated this solution a bit.
- The invalid "states" don't need to be stored in state variables, they can be computed on render, this would also remove the need for a "reset", as that computed invalid variable would be recreated anytime a selection happens
- No need to overcomplicate the labels, you can just hardcode some text in there
If the currently selected start/end date is invalid, show an error label, and prevent the submit button from working (disabled=true)
Closing in favour of https://github.com/wise-old-man/wise-old-man/pull/1507