feat: SW-276 Optimized code
This commit is contained in:
@@ -26,7 +26,7 @@ export default function ChildInfoSelector({
|
||||
const ageLabel = intl.formatMessage({ id: "Age" })
|
||||
const ageReqdErrMsg = intl.formatMessage({ id: "Child age is required" })
|
||||
const bedLabel = intl.formatMessage({ id: "Bed" })
|
||||
const { setValue } = useFormContext()
|
||||
const { setValue, trigger } = useFormContext()
|
||||
const { adults, childrenInAdultsBed } = useGuestsRoomsStore(
|
||||
(state) => state.rooms[roomIndex]
|
||||
)
|
||||
@@ -45,9 +45,7 @@ export default function ChildInfoSelector({
|
||||
|
||||
function updateSelectedAge(age: number) {
|
||||
updateChildAge(age, roomIndex, index)
|
||||
setValue(`rooms.${roomIndex}.children.${index}.age`, age, {
|
||||
shouldTouch: true,
|
||||
})
|
||||
setValue(`rooms.${roomIndex}.children.${index}.age`, age)
|
||||
const availableBedTypes = getAvailableBeds(age)
|
||||
updateSelectedBed(availableBedTypes[0].value)
|
||||
}
|
||||
@@ -60,6 +58,7 @@ export default function ChildInfoSelector({
|
||||
}
|
||||
updateChildBed(bed, roomIndex, index)
|
||||
setValue(`rooms.${roomIndex}.children.${index}.bed`, bed)
|
||||
trigger()
|
||||
}
|
||||
|
||||
const allBedTypes: ChildBed[] = [
|
||||
|
||||
Reference in New Issue
Block a user