Skip to content

Commit

Permalink
Remove unnecessary state
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed May 21, 2024
1 parent e9d2792 commit ef6c213
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ const inputText = (choice: RaRecord) => `${choice.name}`

export const CategoryInput = () => {
const record = useRecordContext()
const { setValue } = useFormContext()
const { setValue, getValues } = useFormContext()

const [selectedValue, setSelectedValue] = useState(record.classification_id)
const [previousSelectedValue, setPreviousSelectedValue] = useState(record.classification_id)

const [dialogOpen, setDialogOpen] = useState(false)
const [autocompleteOpen, setAutocompleteOpen] = useState(false)

Expand All @@ -35,13 +33,13 @@ export const CategoryInput = () => {
}

const handleDialogConfirm = () => {
const selectedValue = getValues('classification_id')
setPreviousSelectedValue(selectedValue)
setDialogOpen(false)
}

const handleChange: AutocompleteInputProps['onChange'] = (value, classificationRecord) => {
if (typeof classificationRecord === 'object' && classificationRecord?.form_id) {
setSelectedValue(value)
setDialogOpen(true)
} else {
setPreviousSelectedValue(value)
Expand Down

0 comments on commit ef6c213

Please sign in to comment.