diff --git a/src/App.tsx b/src/App.tsx
index 31afaf3..f0c00f6 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -13,6 +13,7 @@ export interface GameQuery {
genre: Genre | null;
platform: Platform | null;
sortOrder: string;
+ searchText: string;
}
function App() {
@@ -30,7 +31,7 @@ function App() {
}}
>
-
+ setGameQuery({ ...gameQuery, searchText })} />
diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx
index e42027d..1fb4b74 100644
--- a/src/components/NavBar.tsx
+++ b/src/components/NavBar.tsx
@@ -3,11 +3,15 @@ import logo from '../assets/logo.webp';
import ColorModeSwitch from './ColorModeSwitch';
import SearchInput from './SearchInput';
-const NavBar = () => {
+interface Props {
+ onSearch: (searchText: string) => void;
+}
+
+const NavBar = ({ onSearch }: Props) => {
return (
-
+
)
diff --git a/src/components/SearchInput.tsx b/src/components/SearchInput.tsx
index a420d1a..04378c8 100644
--- a/src/components/SearchInput.tsx
+++ b/src/components/SearchInput.tsx
@@ -1,12 +1,24 @@
import { Input, InputGroup, InputLeftElement } from "@chakra-ui/react";
+import { useRef } from "react";
import { BsSearch } from "react-icons/bs";
-const SearchInput = () => {
+interface Props {
+ onSearch: (searchText: string) => void;
+}
+
+const SearchInput = ({ onSearch }: Props) => {
+ const ref = useRef(null);
+
return (
-
- } />
-
-
+
);
};
diff --git a/src/hooks/useGames.ts b/src/hooks/useGames.ts
index 01d7385..1398a2f 100644
--- a/src/hooks/useGames.ts
+++ b/src/hooks/useGames.ts
@@ -23,7 +23,8 @@ const useGames = (gameQuery: GameQuery) =>
params: {
genres: gameQuery.genre?.id,
platforms: gameQuery.platform?.id,
- ordering: gameQuery.sortOrder
+ ordering: gameQuery.sortOrder,
+ search: gameQuery.searchText
},
},
[gameQuery]
diff --git a/src/index.css b/src/index.css
index e69de29..fd9f6c9 100644
--- a/src/index.css
+++ b/src/index.css
@@ -0,0 +1,3 @@
+form {
+ width: 100%;
+}
\ No newline at end of file