feat: SW-1422 Updated UX for booking code desktop and mobile
This commit is contained in:
@@ -31,7 +31,8 @@ export default function Form({
|
||||
type,
|
||||
})
|
||||
|
||||
const { handleSubmit, register } = useFormContext<BookingWidgetSchema>()
|
||||
const { handleSubmit, register, setValue } =
|
||||
useFormContext<BookingWidgetSchema>()
|
||||
|
||||
function onSubmit(data: BookingWidgetSchema) {
|
||||
const locationData: Location = JSON.parse(decodeURIComponent(data.location))
|
||||
@@ -44,7 +45,7 @@ export default function Form({
|
||||
...(locationData.type == "cities"
|
||||
? { city: locationData.name }
|
||||
: { hotel: locationData.operaId || "" }),
|
||||
...(data.bookingCode && data.bookingCode.value
|
||||
...(data.bookingCode?.value
|
||||
? { bookingCode: data.bookingCode.value }
|
||||
: {}),
|
||||
})
|
||||
@@ -54,6 +55,9 @@ export default function Form({
|
||||
if (data.bookingCode?.remember) {
|
||||
localStorage.setItem("bookingCode", JSON.stringify(data.bookingCode))
|
||||
}
|
||||
if (!data.bookingCode?.value) {
|
||||
setValue("bookingCode.remember", false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user