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:
@@ -60,13 +60,18 @@ export default function BookingCode() {
|
||||
|
||||
function updateBookingCodeFormValue(value: string) {
|
||||
// Set value and show error if validation fails
|
||||
setValue("bookingCode.value", value.toUpperCase(), { shouldValidate: true })
|
||||
setValue("bookingCode.value", value.toUpperCase(), {
|
||||
shouldValidate: true,
|
||||
shouldDirty: true,
|
||||
})
|
||||
|
||||
if (getValues(REDEMPTION)) {
|
||||
// Remove the redemption as user types booking code and show notification for the same
|
||||
// Add delay to handle table mode rendering
|
||||
setTimeout(function () {
|
||||
setValue(REDEMPTION, false)
|
||||
setValue(REDEMPTION, false, {
|
||||
shouldDirty: true,
|
||||
})
|
||||
})
|
||||
// Hide the above notification popup after 5 seconds by re-triggering validation
|
||||
// This is kept consistent with location search field error notification timeout
|
||||
@@ -87,7 +92,10 @@ export default function BookingCode() {
|
||||
) {
|
||||
setShowRemember(false)
|
||||
if (codeError) {
|
||||
setValue("bookingCode.value", "", { shouldValidate: true })
|
||||
setValue("bookingCode.value", "", {
|
||||
shouldValidate: true,
|
||||
shouldDirty: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -306,7 +314,7 @@ export function RemoveExtraRooms({ ...props }: ButtonProps) {
|
||||
// Timeout to delay the event scheduling issue with touch events on mobile
|
||||
window.setTimeout(() => {
|
||||
const rooms = getValues("rooms")[0]
|
||||
setValue("rooms", [rooms], { shouldValidate: true })
|
||||
setValue("rooms", [rooms], { shouldValidate: true, shouldDirty: true })
|
||||
trigger("bookingCode.value")
|
||||
trigger(REDEMPTION)
|
||||
}, 300)
|
||||
@@ -357,12 +365,12 @@ function TabletBookingCode({
|
||||
}
|
||||
}
|
||||
if (!isOpen && !bookingCode?.value) {
|
||||
setValue("bookingCode.flag", false)
|
||||
setValue("bookingCode.flag", false, { shouldDirty: true })
|
||||
setIsOpen(isOpen)
|
||||
} else if (!codeError || isOpen) {
|
||||
setIsOpen(isOpen)
|
||||
if (isOpen || bookingCode?.value) {
|
||||
setValue("bookingCode.flag", true)
|
||||
setValue("bookingCode.flag", true, { shouldDirty: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,7 +386,7 @@ function TabletBookingCode({
|
||||
{...register("bookingCode.flag", {
|
||||
onChange: function () {
|
||||
if (bookingCode?.value || isOpen) {
|
||||
setValue("bookingCode.flag", true)
|
||||
setValue("bookingCode.flag", true, { shouldDirty: true })
|
||||
}
|
||||
},
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user