Merged in feat/sw-1245-bw-button-update (pull request #2262)
Feat/sw 1245 - Booking widget - change button text when new values * feat(sw-1245) - use isDirty to update button text * Change text only in booking flow * Revert test code Approved-by: Michael Zetterberg
This commit is contained in:
@@ -24,13 +24,13 @@ export default function AdultSelector({
|
||||
|
||||
function increaseAdultsCount() {
|
||||
if (currentAdults < 6) {
|
||||
setValue(name, currentAdults + 1)
|
||||
setValue(name, currentAdults + 1, { shouldDirty: true })
|
||||
}
|
||||
}
|
||||
|
||||
function decreaseAdultsCount() {
|
||||
if (currentAdults > 1) {
|
||||
setValue(name, currentAdults - 1)
|
||||
setValue(name, currentAdults - 1, { shouldDirty: true })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,22 @@ export default function ChildSelector({
|
||||
|
||||
function increaseChildrenCount(roomIndex: number) {
|
||||
if (currentChildren.length < 5) {
|
||||
setValue(`rooms.${roomIndex}.childrenInRoom.${currentChildren.length}`, {
|
||||
age: undefined,
|
||||
bed: undefined,
|
||||
})
|
||||
setValue(
|
||||
`rooms.${roomIndex}.childrenInRoom.${currentChildren.length}`,
|
||||
{
|
||||
age: undefined,
|
||||
bed: undefined,
|
||||
},
|
||||
{ shouldDirty: true }
|
||||
)
|
||||
}
|
||||
}
|
||||
function decreaseChildrenCount(roomIndex: number) {
|
||||
if (currentChildren.length > 0) {
|
||||
currentChildren.pop()
|
||||
setValue(`rooms.${roomIndex}.childrenInRoom`, currentChildren)
|
||||
setValue(`rooms.${roomIndex}.childrenInRoom`, currentChildren, {
|
||||
shouldDirty: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ export default function GuestsRoomsPickerDialog({
|
||||
const handleAddRoom = useCallback(() => {
|
||||
setValue("rooms", [...roomsValue, { adults: 1, childrenInRoom: [] }], {
|
||||
shouldValidate: true,
|
||||
shouldDirty: true,
|
||||
})
|
||||
}, [roomsValue, setValue])
|
||||
|
||||
@@ -66,7 +67,7 @@ export default function GuestsRoomsPickerDialog({
|
||||
setValue(
|
||||
"rooms",
|
||||
roomsValue.filter((_, i) => i !== index),
|
||||
{ shouldValidate: true }
|
||||
{ shouldValidate: true, shouldDirty: true }
|
||||
)
|
||||
},
|
||||
[roomsValue, setValue]
|
||||
|
||||
Reference in New Issue
Block a user