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:
@@ -33,7 +33,8 @@ export default function Form({ type, onClose }: BookingWidgetFormProps) {
|
||||
type,
|
||||
})
|
||||
|
||||
const { handleSubmit, setValue } = useFormContext<BookingWidgetSchema>()
|
||||
const { handleSubmit, setValue, reset } =
|
||||
useFormContext<BookingWidgetSchema>()
|
||||
|
||||
function onSubmit(data: BookingWidgetSchema) {
|
||||
const bookingFlowPage = data.hotel ? selectRate(lang) : selectHotel(lang)
|
||||
@@ -54,11 +55,14 @@ export default function Form({ type, onClose }: BookingWidgetFormProps) {
|
||||
router.push(`${bookingFlowPage}?${bookingWidgetParams.toString()}`)
|
||||
})
|
||||
if (!data.bookingCode?.value) {
|
||||
setValue("bookingCode.remember", false)
|
||||
setValue("bookingCode.remember", false, {
|
||||
shouldDirty: true,
|
||||
})
|
||||
localStorage.removeItem("bookingCode")
|
||||
} else if (data.bookingCode?.remember) {
|
||||
localStorage.setItem("bookingCode", JSON.stringify(data.bookingCode))
|
||||
}
|
||||
reset(data)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user