Updated the demographic input to work more as expected
This commit is contained in:
@@ -17,6 +17,7 @@ import ProgressBar from "@/components/Low/ProgressBar";
|
||||
import Layout from "@/components/High/Layout";
|
||||
import {calculateAverageLevel} from "@/utils/score";
|
||||
import axios from "axios";
|
||||
import DemographicInformationInput from "@/components/DemographicInformationInput";
|
||||
|
||||
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
const user = req.session.user;
|
||||
@@ -39,13 +40,36 @@ export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||
|
||||
export default function Home() {
|
||||
const [showDiagnostics, setShowDiagnostics] = useState(false);
|
||||
const {user} = useUser({redirectTo: "/login"});
|
||||
const [showDemographicInput, setShowDemographicInput] = useState(false);
|
||||
const {user, mutateUser} = useUser({redirectTo: "/login"});
|
||||
const {stats} = useStats(user?.id);
|
||||
|
||||
useEffect(() => {
|
||||
if (user) setShowDiagnostics(user.isFirstLogin);
|
||||
if (user) {
|
||||
setShowDemographicInput(!user.demographicInformation);
|
||||
setShowDiagnostics(user.isFirstLogin);
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
if (user && showDemographicInput) {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>EnCoach | Muscat Training Institute</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="A training platform for the IELTS exam provided by the Muscat Training Institute and developed by eCrop."
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
<Layout user={user} navDisabled>
|
||||
<DemographicInformationInput mutateUser={mutateUser} />
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
if (user && showDiagnostics) {
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user