Skip to content

Commit

Permalink
feat: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash committed Oct 11, 2023
1 parent 3e59af9 commit d9a52d9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/pages/components/DateSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ import React from 'react'
import { DatePicker } from '@mui/x-date-pickers/DatePicker'
import { TEXTS } from 'src/resources/texts'
import { DataAndTimeSelectorProps } from './utils/dateAndTime'
import { DateValidationError } from '@mui/x-date-pickers'

export function DateSelector({ time, onChange }: DataAndTimeSelectorProps) {
const [error, setError] = React.useState<DateValidationError | null>(null)
return (
<DatePicker
sx={{ width: '100%' }}
value={time}
onChange={(ts) => onChange(ts!)}
format="DD/MM/YYYY"
label={TEXTS.choose_date}
disableFuture
/>
<>
<DatePicker
sx={{ width: '100%' }}
value={time}
onChange={(ts) => onChange(ts!)}
format="DD/MM/YYYY"
label={TEXTS.choose_date}
disableFuture
onError={(err) => setError(err)}
/>
{error && <div style={{ color: 'red' }}>{error}</div>}
</>
)
}

0 comments on commit d9a52d9

Please sign in to comment.