diff --git a/components/Forms/BookingWidget/FormContent/Search/index.tsx b/components/Forms/BookingWidget/FormContent/Search/index.tsx index c1f681cc8..d09c26031 100644 --- a/components/Forms/BookingWidget/FormContent/Search/index.tsx +++ b/components/Forms/BookingWidget/FormContent/Search/index.tsx @@ -38,7 +38,7 @@ export default function Search({ locations, handlePressEnter }: SearchProps) { const value = useWatch({ name }) const locationString = getValues("location") const location = - locationString && isValidJson(locationString) + locationString && isValidJson(decodeURIComponent(locationString)) ? JSON.parse(decodeURIComponent(locationString)) : null const [state, dispatch] = useReducer( @@ -98,7 +98,6 @@ export default function Search({ locations, handlePressEnter }: SearchProps) { setValue("location", encodeURIComponent(stringified)) sessionStorage.setItem(sessionStorageKey, stringified) setValue(name, selectedItem.name) - const newHistoryItem: SearchHistoryItem = { type: selectedItem.type, id: selectedItem.id, @@ -178,14 +177,14 @@ export default function Search({ locations, handlePressEnter }: SearchProps) { }, [location]) function getLocationLabel(): string { + const fallbackLabel = intl.formatMessage({ id: "Where to" }) if (location?.type === "hotels") { - return location?.relationships?.city?.name || "" + return location?.relationships?.city?.name || fallbackLabel } if (state.searchData?.type === "hotels") { - return state.searchData?.relationships?.city?.name || "" + return state.searchData?.relationships?.city?.name || fallbackLabel } - - return intl.formatMessage({ id: "Where to" }) + return fallbackLabel } return (