Skip to content

Commit

Permalink
fix the city selection for start and main page
Browse files Browse the repository at this point in the history
  • Loading branch information
Falsal committed Aug 10, 2024
1 parent 479839c commit 0c24992
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/Search/CityResultList.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function CityResultList({
if(!!cityOne && !!idOne ){
setCityInput(_city.label);
setCity(_city.value)
navigate(`tour/${idOne.idOne}/${_city.value}`);
navigate(`tour/${idOne}/${_city.value}`);
window.location.reload()
}

Expand Down
21 changes: 17 additions & 4 deletions src/components/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ export function Search({
const cityParam = urlSearchParams.get("city");
// const { cityOne, idOne } = useParams();
const [city, setCity] = useState({
label: cityParam || capitalize(cityOne),
label: capitalize(cityParam) || capitalize(cityOne),
value: cityParam,
});

useEffect(() => {
console.log("**************************************************");
console.log("L74 Search/ cityOne", cityOne);
console.log("L75 Search/ idOne", idOne);
console.log("L75 Search/ cityParam", cityParam);
console.log("L75 Search/ city", city);

}, []);

const [region, setRegion] = useState(null);
Expand Down Expand Up @@ -397,20 +400,28 @@ export function Search({
searchParams,
initialCity: cityInput,
onSelect: async (city) => {
// console.log("L379 Search / cityOne :", cityOne)
console.log("L402 Search / cityParam :", cityParam)
console.log("L403 Search / city inside onSelect :", city)
console.log("L404 , Search / city.value :", city.value)
console.log("L405 , Search / cityOne :", cityOne)
console.log("L406 , Search / idOne :", idOne)
if (!!cityOne && !!idOne && pageKey === "detail") {
setCityInput(city.label);
setCity(city.value);
navigate(`tour/${idOne}/${city.value}`);
} else if (!!city) {
console.log("L413 Search / else if inside onSelect :", city)
setCityInput(city.label);
setCity(city);
pageKey === "start" && updateCapCity(city.label);
searchParams.set('city', city.value);
setSearchParams(searchParams)
window.location.reload()
}
hideModal();
},
cityOne: { cityOne },
idOne: { idOne },
cityOne: cityOne ,
idOne: idOne ,
setSearchParams,
title: "",
sourceCall: "city",
Expand Down Expand Up @@ -443,6 +454,8 @@ export function Search({
setCityInput(city.label);
setCity(city);
pageKey === "start" && updateCapCity(city.label);


}
hideModal();
},
Expand Down
3 changes: 2 additions & 1 deletion src/views/Main/DetailReworked.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ useEffect(() => {
}else{
tourId = !!searchParams.get("id") ? searchParams.get("id") : !!localStorage.getItem("tourId") ? localStorage.getItem("tourId") : null; // currently we only use localStorage for tourId
}
console.log("L324 tourId :", tourId)
if (!!tourId) {
setIsTourLoading(true);

Expand Down Expand Up @@ -809,7 +810,7 @@ useEffect(() => {
}}
>
<Box sx={{ width: "100%" }}>
<SearchContainer pageKey="detail" goto={"/suche"} idOne={idOne} cityOne={cityOne} />
<SearchContainer pageKey="detail" goto={"/suche"} idOne={idOne? idOne : null} cityOne={cityOne? cityOne : null} />
</Box>
</Box>
</Box>
Expand Down

0 comments on commit 0c24992

Please sign in to comment.