From 8d755071bc67fd2b7e1eeb37794173857c84d83c Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Tue, 28 Jan 2025 12:51:15 +0000 Subject: [PATCH] Merged in fix/SW-1335/city-label-missing (pull request #1218) Fix/SW-1335/city label missing * fix(SW-1335): add fallback label when missing * fix(SW-1335): update location if valid Approved-by: Niclas Edenvin --- .../Forms/BookingWidget/FormContent/Search/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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 (