import { Button, Error, Grid, Spinner } from "@chakra-ui/react" import { useRouter } from "next/router" import React, { useContext, useEffect, useState } from "react" import Layout from "../../components/layout" import { learningitemfetcher } from "../../datafetch/datafetch" /** * params - * length of path - plength ( the number of tasks ) * structure of the path - DAG * type of path to be formed - pathtype */ function Menubox(props) { const { data, isLoading, isError } = learningitemfetcher() const [showedcount, setShowedcount] = React.useState(40) const router = useRouter() if (isLoading) return if (isError) return const container = ( <> {data.slice(0, showedcount).map((item) => { if ([1, 22, 3, 24, 5, 26].includes(item.id)) { return (
{ router.push(`/learningpage/${item.id}`) }} >
) } return
})}
) return container } export default function LearningPath(props) { const [isloaded, setIsLoaded] = React.useState(false) useEffect(() => { if (!isloaded) { console.log("isloaded called") setIsLoaded(true) } }) return ( <> ) } /**This place should be used to get any information from the server side * example : we need to get the session token * or any thing related to the page */ export async function getServerSideProps() { const data = await fetch("https://jsonplaceholder.typicode.com/todos").then((response) => { response.json() }) return { props: { title: "rahul" } } } LearningPath.getLayout = function getLayout(page) { return {page} }