wise-old-man icon indicating copy to clipboard operation
wise-old-man copied to clipboard

[app] Prevent custom periods before 2013

Open Sharpienero opened this issue 1 year ago • 8 comments

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 avatar Dec 11 '23 22:12 Sharpienero

@Sharpienero is attempting to deploy a commit to the wiseoldman Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Dec 11 '23 22:12 vercel[bot]

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

vercel[bot] avatar Dec 11 '23 22:12 vercel[bot]

This is very nice, the "invalid state" looks great, could you apply the same logic to the end date?

psikoi avatar Dec 11 '23 23:12 psikoi

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 avatar Dec 11 '23 23:12 psikoi

@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?

Sharpienero avatar Dec 11 '23 23:12 Sharpienero

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

Sharpienero avatar Dec 12 '23 02:12 Sharpienero

Is there anything you'd like me to change about this implementation @psikoi?

Sharpienero avatar Dec 13 '23 01:12 Sharpienero

Sorry for the delay on the review, a bit busy IRL atm.

I do think you have overcomplicated this solution a bit.

  1. 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
  2. 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)

psikoi avatar Dec 13 '23 17:12 psikoi

Closing in favour of https://github.com/wise-old-man/wise-old-man/pull/1507

psikoi avatar May 12 '24 00:05 psikoi