Skip to content

Commit

Permalink
Make sure to clear the plateSize field when switching vehicle value
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaagma committed Nov 19, 2024
1 parent ff6c7d5 commit 6def85f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ export const VehicleSelectField: FC<
const disabled =
!!response?.vehiclePlateOrderChecksByPermno?.validationErrorMessages
?.length
setPlate(disabled ? '' : currentVehicle.permno || '')
setValue(
'pickVehicle.plate',
disabled ? '' : currentVehicle.permno || '',
)

const permno = disabled ? '' : currentVehicle.permno || ''

setPlate(permno)

setValue('pickVehicle.plate', permno)

setValue('plateSize.frontPlateSize', [])
setValue('plateSize.rearPlateSize', [])

setIsLoading(false)
})
.catch((error) => console.error(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ export const FindVehicleFormField: FC<React.PropsWithChildren<Props>> = ({
setValue('vehicleMileage.requireMileage', vehicleDetails?.requireMileage)
setValue('vehicleMileage.mileageReading', vehicleDetails?.mileageReading)

setValue('plateSize.frontPlateSize', [])
setValue('plateSize.rearPlateSize', [])

if (permno) setValue('vehicleInfo.plate', permno)
if (permno) setValue('vehicleInfo.type', vehicleDetails.make)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export const VehicleRadioFormField: FC<React.PropsWithChildren<Props>> = ({
setValue('vehicleMileage.requireMileage', currentVehicle?.requireMileage)
setValue('vehicleMileage.mileageReading', currentVehicle?.mileageReading)

setValue('plateSize.frontPlateSize', [])
setValue('plateSize.rearPlateSize', [])

if (permno) setValue('vehicleInfo.plate', permno)
if (permno) setValue('vehicleInfo.type', currentVehicle?.make)
} else if (field.itemType === 'PLATE') {
Expand Down

0 comments on commit 6def85f

Please sign in to comment.