diff --git a/client/src/App.jsx b/client/src/App.jsx index 3968464..8ed8745 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -9,6 +9,7 @@ import useAuthLoader from "./hooks/useAuthLoader"; import MoviePage from "./pages/MoviePage"; import Navbar from "./components/Navbar"; import TmdbMovie from "./pages/MoviesPage"; +import SearchResultPage from "./pages/SearchResultPage"; function isTokenExpired(token) { if (!token) return true; @@ -37,7 +38,7 @@ export default function App() { return ( - + @@ -98,6 +99,15 @@ export default function App() { } /> + + : + } + /> + ); diff --git a/client/src/api/tmdb.api.js b/client/src/api/tmdb.api.js index af88aac..8d2d734 100644 --- a/client/src/api/tmdb.api.js +++ b/client/src/api/tmdb.api.js @@ -3,4 +3,9 @@ import axiosInstance from "./axiosInstance"; export const getTrendingMovies = async () => { const res = await axiosInstance.get('/movies/trending'); return res; +} + +export const getTopRatedMovies = async () => { + const res = await axiosInstance.get('/movies/top-rated'); + return res; } \ No newline at end of file diff --git a/client/src/api/user.api.js b/client/src/api/user.api.js index 645c920..a7fec1d 100644 --- a/client/src/api/user.api.js +++ b/client/src/api/user.api.js @@ -11,5 +11,10 @@ export const setProfileCover = async (backdrop) => { cover: backdrop }); + return res.data; +} + +export const searchUsers = async (query) => { + const res = await axiosInstance.get(`/user/search?q=${query}`); return res.data; } \ No newline at end of file diff --git a/client/src/components/Navbar.jsx b/client/src/components/Navbar.jsx index 3966e48..6bb7349 100644 --- a/client/src/components/Navbar.jsx +++ b/client/src/components/Navbar.jsx @@ -1,4 +1,4 @@ -import { Link, useLocation } from "react-router-dom"; +import { Link, useLocation, useNavigate } from "react-router-dom"; import { useState } from "react"; import useUserStore from "../store/userStore"; import Modal from "./ui/Modal"; @@ -21,12 +21,18 @@ export default function Navbar() { return (userData.firstName[0] + (userData.lastName?.[0] || "")).toUpperCase(); }; + const navigate = useNavigate(); + + const handleSearch = (query) => { + navigate(`/search?q=${query}`); + }; + const isActive = (path) => location.pathname === path; return (