MCPcopy Create free account
hub / github.com/CodeWithHarry/Sigma-Web-Dev-Course / Dashboard

Function Dashboard

Video 131/components/Dashboard.js:10–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { Bounce } from 'react-toastify';
9
10const Dashboard = () => {
11 const { data: session, update } = useSession()
12 const router = useRouter()
13 const [form, setform] = useState({})
14
15 useEffect(() => {
16 console.log(session)
17
18 if (!session) {
19 router.push('/login')
20 }
21 else {
22 getData()
23 }
24 }, [])
25
26 const getData = async () => {
27 let u = await fetchuser(session.user.name)
28 setform(u)
29 }
30
31 const handleChange = (e) => {
32 setform({ ...form, [e.target.name]: e.target.value })
33 }
34
35 const handleSubmit = async (e) => {
36
37 let a = await updateProfile(e, session.user.name)
38 toast('Profile Updated', {
39 position: "top-right",
40 autoClose: 5000,
41 hideProgressBar: false,
42 closeOnClick: true,
43 pauseOnHover: true,
44 draggable: true,
45 progress: undefined,
46 theme: "light",
47 transition: Bounce,
48 });
49 }
50
51
52
53
54
55 return (
56 <>
57 <ToastContainer
58 position="top-right"
59 autoClose={5000}
60 hideProgressBar={false}
61 newestOnTop={false}
62 closeOnClick
63 rtl={false}
64 pauseOnFocusLoss
65 draggable
66 pauseOnHover
67 theme="light"

Callers

nothing calls this directly

Calls 1

getDataFunction · 0.70

Tested by

no test coverage detected