feat: SW-1422 Updated UX for booking code desktop and mobile
This commit is contained in:
@@ -85,7 +85,7 @@ export default function BookingWidgetClient({
|
||||
|
||||
const selectedBookingCode = bookingWidgetSearchData
|
||||
? bookingWidgetSearchData.bookingCode
|
||||
: undefined
|
||||
: ""
|
||||
|
||||
const defaultRoomsData: BookingWidgetSchema["rooms"] =
|
||||
bookingWidgetSearchData?.rooms?.map((room) => ({
|
||||
@@ -113,7 +113,7 @@ export default function BookingWidgetClient({
|
||||
: now.utc().add(1, "day").format("YYYY-MM-DD"),
|
||||
},
|
||||
bookingCode: {
|
||||
value: selectedBookingCode ?? "",
|
||||
value: selectedBookingCode,
|
||||
remember: false,
|
||||
},
|
||||
redemption: false,
|
||||
@@ -156,36 +156,36 @@ export default function BookingWidgetClient({
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const sessionStorageSearchData =
|
||||
typeof window !== "undefined"
|
||||
? sessionStorage.getItem("searchData")
|
||||
: undefined
|
||||
if (typeof window !== "undefined" && !selectedLocation) {
|
||||
const sessionStorageSearchData = sessionStorage.getItem("searchData")
|
||||
|
||||
const initialSelectedLocation: Location | undefined =
|
||||
sessionStorageSearchData && isValidJson(sessionStorageSearchData)
|
||||
? JSON.parse(sessionStorageSearchData)
|
||||
: undefined
|
||||
const initialSelectedLocation: Location | undefined =
|
||||
sessionStorageSearchData && isValidJson(sessionStorageSearchData)
|
||||
? JSON.parse(sessionStorageSearchData)
|
||||
: undefined
|
||||
|
||||
!selectedLocation?.name &&
|
||||
initialSelectedLocation?.name &&
|
||||
methods.setValue("search", initialSelectedLocation.name)
|
||||
!selectedLocation &&
|
||||
methods.setValue("search", initialSelectedLocation.name)
|
||||
sessionStorageSearchData &&
|
||||
methods.setValue("location", encodeURIComponent(sessionStorageSearchData))
|
||||
methods.setValue(
|
||||
"location",
|
||||
encodeURIComponent(sessionStorageSearchData)
|
||||
)
|
||||
}
|
||||
}, [methods, selectedLocation])
|
||||
|
||||
const storedBookingCode =
|
||||
typeof window !== "undefined"
|
||||
? localStorage.getItem("bookingCode")
|
||||
: undefined
|
||||
const initialBookingCode: BookingCodeSchema | undefined =
|
||||
storedBookingCode && isValidJson(storedBookingCode)
|
||||
? JSON.parse(storedBookingCode)
|
||||
: undefined
|
||||
!selectedBookingCode &&
|
||||
initialBookingCode &&
|
||||
initialBookingCode.remember &&
|
||||
methods.setValue("bookingCode", initialBookingCode)
|
||||
}, [methods, selectedLocation, selectedBookingCode])
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined" && !selectedBookingCode) {
|
||||
const storedBookingCode = localStorage.getItem("bookingCode")
|
||||
const initialBookingCode: BookingCodeSchema | undefined =
|
||||
storedBookingCode && isValidJson(storedBookingCode)
|
||||
? JSON.parse(storedBookingCode)
|
||||
: undefined
|
||||
|
||||
initialBookingCode?.remember &&
|
||||
methods.setValue("bookingCode", initialBookingCode)
|
||||
}
|
||||
}, [methods, selectedBookingCode])
|
||||
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
|
||||
Reference in New Issue
Block a user