Skip to content

Commit

Permalink
Hint visible when picking a date from calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
jlledom committed Dec 5, 2024
1 parent 588b314 commit 587a618
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ const ExpirationDatePicker: FunctionComponent<Props> = ({ id, label }) => {
return new Date(new Date().getTime() + selectedItem.period * dayMs)
}, [selectedItem])

const fieldHint = useMemo(() => {
if (!fieldDate) return

const date = new Date(fieldDate)
date.setHours(0, 0, 0, 0)

return `The token will expire on ${date.toLocaleDateString()}`
}, [fieldDate])

const dateValue = useMemo(() => {
let value = ''

Expand All @@ -62,6 +53,14 @@ const ExpirationDatePicker: FunctionComponent<Props> = ({ id, label }) => {
return value
}, [fieldDate, selectedItem, pickedDate])

const fieldHint = useMemo(() => {
if (!dateValue) return

const date = new Date(dateValue)

return `The token will expire on ${date.toLocaleDateString()}`
}, [dateValue])

const handleOnChange = (_value: string, event: FormEvent<HTMLSelectElement>) => {
const value = (event.target as HTMLSelectElement).value
const selected = collection.find(i => i.id === value) ?? null
Expand Down

0 comments on commit 587a618

Please sign in to comment.