feat(SW-977): Scenario 2 & 4
This commit is contained in:
@@ -124,10 +124,12 @@ export default function Search({ locations, handlePressEnter }: SearchProps) {
|
||||
typeof window !== "undefined"
|
||||
? sessionStorage.getItem(sessionStorageKey)
|
||||
: undefined
|
||||
|
||||
const searchHistory =
|
||||
typeof window !== "undefined"
|
||||
? localStorage.getItem(localStorageKey)
|
||||
: null
|
||||
|
||||
if (searchData || searchHistory) {
|
||||
dispatch({
|
||||
payload: {
|
||||
@@ -160,13 +162,18 @@ export default function Search({ locations, handlePressEnter }: SearchProps) {
|
||||
}
|
||||
}, [stayType, stayValue, unregister, setValue])
|
||||
|
||||
useEffect(() => {
|
||||
sessionStorage.setItem(sessionStorageKey, locationString)
|
||||
}, [locationString])
|
||||
|
||||
function getLocationLabel(): string {
|
||||
if (state.searchData?.type === "hotels") {
|
||||
return state.searchData?.relationships?.city?.name || ""
|
||||
}
|
||||
if (location?.type === "hotels") {
|
||||
return location?.relationships?.city?.name || ""
|
||||
}
|
||||
if (state.searchData?.type === "hotels") {
|
||||
return state.searchData?.relationships?.city?.name || ""
|
||||
}
|
||||
|
||||
return intl.formatMessage({ id: "Where to" })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user