From 656a6e08da61b36b7ce4f50cf7f5fd568fa070bd Mon Sep 17 00:00:00 2001 From: NCanggoro Date: Mon, 4 Mar 2024 16:19:04 +0700 Subject: [PATCH] fix search on selected navigation --- src/components/Header/index.tsx | 6 ++++-- src/pages/LocationDetail/index.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 6793235..85112ab 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -7,6 +7,7 @@ import AsyncSelect from 'react-select/async'; import './style.css'; import { logoutService } from "../../services"; import { getSearchLocationService } from "../../services/locations"; +import { useNavigate } from "react-router-dom"; function Header() { @@ -17,6 +18,7 @@ function Header() { }) const dispatch = useDispatch(); + const navigate = useNavigate(); const user = useSelector((state: UserRootState) => state.auth) const onInput = (val: string): void => { @@ -38,8 +40,8 @@ function Header() { e.preventDefault(); } - const onSelectedSearchOption = (val) => { - console.log(val) + const onSelectedSearchOption = (val: any) => { + navigate(`/location/${val.value}`) } const onLoadSelectOptions = async (inputValue: string) => { diff --git a/src/pages/LocationDetail/index.tsx b/src/pages/LocationDetail/index.tsx index 1f27ade..498767b 100644 --- a/src/pages/LocationDetail/index.tsx +++ b/src/pages/LocationDetail/index.tsx @@ -196,7 +196,7 @@ function LocationDetail() { if(updatePage) { getLocationDetail() } - }, [updatePage]) + }, [updatePage, id]) return ( <>