diff --git a/src/App.js b/src/App.js index 904e5b7..0dae341 100644 --- a/src/App.js +++ b/src/App.js @@ -25,7 +25,7 @@ function App() { } /> {/* Private routes */} - }> + }> } /> } /> } /> diff --git a/src/api/posts.js b/src/api/posts.js index 7059e98..8633352 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -41,9 +41,18 @@ export const deletePostRequest = async (id) => export const getPostRequest = async (id) => await axios.get(PostId + id); -export const updatePostRequest = async (id, newFields) => - await axios.put(`${UpdatePost}/${id}`, newFields, { - headers: { - Authorization: `Bearer ${getTokenFromCookie()}`, - }, - }); + export const updatePostRequest = async (id, formData) => { + try { + const response = await axios.put(`${UpdatePost}/${id}`, formData, { + headers: { + Authorization: `Bearer ${getTokenFromCookie()}`, + 'Content-Type': 'multipart/form-data', + }, + }); + + return response.data; + } catch (error) { + + throw error; + } + }; \ No newline at end of file diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index a6524d6..feaf65a 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -14,7 +14,7 @@ const Navbar = () => { const isAdminPage = location.pathname === "/admin"; const userListPage = location.pathname === "/users"; const isContactPage = location.pathname === "/contact"; - + const { setAuth } = useAuth(); const handleLogout = () => { @@ -32,7 +32,7 @@ const Navbar = () => { if (isLoginPage || isSignupPage) { return null; } - + const hideHomeLink = location.pathname.startsWith("/posts/"); return (