feat(SW-160): update profile
This commit is contained in:
committed by
Michael Zetterberg
parent
b6e22d51a5
commit
2337d37f1a
@@ -17,7 +17,6 @@ import type { Key } from "react-aria-components"
|
||||
|
||||
import type { DateProps } from "./date"
|
||||
|
||||
/** TODO: Get selecting with Enter-key to work */
|
||||
export default function DateSelect({ name, registerOptions = {} }: DateProps) {
|
||||
const { formatMessage } = useIntl()
|
||||
const d = useWatch({ name })
|
||||
@@ -54,6 +53,18 @@ export default function DateSelect({ name, registerOptions = {} }: DateProps) {
|
||||
const monthLabel = formatMessage({ id: "Month" })
|
||||
const yearLabel = formatMessage({ id: "Year" })
|
||||
|
||||
let dateValue = null
|
||||
try {
|
||||
/**
|
||||
* parseDate throws when its not a valid
|
||||
* date, but we can't check isNan since
|
||||
* we recieve the date as "1999-01-01"
|
||||
*/
|
||||
dateValue = parseDate(d)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
return (
|
||||
<DatePicker
|
||||
aria-label={formatMessage({ id: "Select date of birth" })}
|
||||
@@ -61,7 +72,7 @@ export default function DateSelect({ name, registerOptions = {} }: DateProps) {
|
||||
isRequired={!!registerOptions.required}
|
||||
name={name}
|
||||
ref={field.ref}
|
||||
value={isNaN(d) ? undefined : parseDate(d)}
|
||||
value={dateValue}
|
||||
>
|
||||
<Group>
|
||||
<DateInput className={styles.container}>
|
||||
|
||||
Reference in New Issue
Block a user