From d2b70e03d8ff5b83579ceece62e0cc15d947fe5f Mon Sep 17 00:00:00 2001 From: somidhroy Date: Wed, 8 Mar 2023 19:33:58 +0530 Subject: [PATCH 1/4] context setup added --- app/context/MyContext.tsx | 37 +++++++++++++++++++++++++++++++++++++ app/layout.tsx | 9 ++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 app/context/MyContext.tsx diff --git a/app/context/MyContext.tsx b/app/context/MyContext.tsx new file mode 100644 index 0000000..70afae7 --- /dev/null +++ b/app/context/MyContext.tsx @@ -0,0 +1,37 @@ +import { createContext, FC, useContext, useState } from "react"; +import UserProfile from "../components/UserProfile"; + +const StateContext = createContext< + { setProfile: (data: UserProfile) => void } | undefined +>(undefined); + + +interface UserProfile { + name: string; + username: string; + profile_img: string; +} + +export const ContextProvider = ({ children }: any) => { + const [userProfile, setUserProfile] = useState({ + name: "", + username: "", + profile_img: "", + }); + + const setProfile = (data: UserProfile) => { + setUserProfile({ + name: data.name, + username: data.username, + profile_img: data.profile_img, + }); + }; + + return ( + + {children} + + ); +}; + +export const useStateContext = () => useContext(StateContext); diff --git a/app/layout.tsx b/app/layout.tsx index 98d4d1e..f06f987 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -5,6 +5,7 @@ import Head from "./head"; import Loading from "./components/Loading"; import useTweetStore from "./store/tweetStore"; import Navbar from "./components/Navbar"; +import { ContextProvider } from "./context/MyContext"; export default function RootLayout({ children, @@ -15,9 +16,11 @@ export default function RootLayout({ - - {children} - + + + {children} + + ); } From 94b9340bddd8ab7ccc14f2d8d367d8a5ae853591 Mon Sep 17 00:00:00 2001 From: somidhroy Date: Thu, 9 Mar 2023 14:20:49 +0530 Subject: [PATCH 2/4] adding discover page --- app/components/Navbar.tsx | 2 +- app/dashboard/Sidebar.tsx | 4 +++- app/dashboard/page.tsx | 5 ++--- app/discover/Profile.tsx | 28 ++++++++++++++++++++++++++++ app/discover/page.tsx | 38 +++++++++++++++++++++++++++++++++----- app/page.tsx | 1 + app/search/SearchBar.tsx | 3 +++ 7 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 app/discover/Profile.tsx diff --git a/app/components/Navbar.tsx b/app/components/Navbar.tsx index 3513203..a6dfd5a 100644 --- a/app/components/Navbar.tsx +++ b/app/components/Navbar.tsx @@ -6,7 +6,7 @@ type NavbarProps = {}; const Navbar: FC = () => { return ( -