Route handling + Added main layout.
This commit is contained in:
+4
-7
@@ -1,17 +1,14 @@
|
||||
import MainLayout from "@/components/Layouts/MainLayout";
|
||||
import "@/styles/globals.css";
|
||||
import { SessionProvider } from "next-auth/react";
|
||||
import type { AppProps } from "next/app";
|
||||
import Head from "next/head";
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<SessionProvider session={pageProps.session}>
|
||||
<Head>
|
||||
<title>Linkwarden</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
<Component {...pageProps} />
|
||||
<MainLayout>
|
||||
<Component {...pageProps} />
|
||||
</MainLayout>
|
||||
</SessionProvider>
|
||||
);
|
||||
}
|
||||
|
||||
+1
-7
@@ -6,15 +6,9 @@ export default function Dashboard() {
|
||||
|
||||
const user = session?.user;
|
||||
|
||||
console.log();
|
||||
return (
|
||||
<div className="p-5">
|
||||
<div>
|
||||
<p className="text-3xl font-bold text-center mb-10">Linkwarden</p>
|
||||
</div>
|
||||
<div>
|
||||
<p>Welcome {user?.name?.toLocaleUpperCase()}!</p>
|
||||
</div>
|
||||
<p className="text-3xl font-bold text-center mb-10">Linkwarden</p>
|
||||
<Collections />
|
||||
</div>
|
||||
);
|
||||
|
||||
+3
-15
@@ -1,8 +1,6 @@
|
||||
import { signIn } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
|
||||
interface FormData {
|
||||
email: string;
|
||||
@@ -10,16 +8,6 @@ interface FormData {
|
||||
}
|
||||
|
||||
export default function Login() {
|
||||
const session = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (session.status === "authenticated") {
|
||||
console.log("Already logged in.");
|
||||
router.push("/");
|
||||
}
|
||||
}, []);
|
||||
|
||||
const [form, setForm] = useState<FormData>({
|
||||
email: "",
|
||||
password: "",
|
||||
@@ -40,7 +28,7 @@ export default function Login() {
|
||||
password: "",
|
||||
});
|
||||
|
||||
router.push("/");
|
||||
// router.push("/");
|
||||
} else {
|
||||
console.log("User not found or password does not match.", res);
|
||||
}
|
||||
@@ -72,7 +60,7 @@ export default function Login() {
|
||||
>
|
||||
Login
|
||||
</div>
|
||||
<Link href={"/auth/register"} className="block mx-auto w-min">
|
||||
<Link href={"/register"} className="block mx-auto w-min">
|
||||
Register
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
+3
-12
@@ -1,6 +1,5 @@
|
||||
import Link from "next/link";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
interface FormData {
|
||||
@@ -10,16 +9,8 @@ interface FormData {
|
||||
}
|
||||
|
||||
export default function Register() {
|
||||
const session = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (session.status === "authenticated") {
|
||||
console.log("Already logged in.");
|
||||
router.push("/");
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
const [form, setForm] = useState<FormData>({
|
||||
name: "",
|
||||
email: "",
|
||||
@@ -51,7 +42,7 @@ export default function Register() {
|
||||
password: "",
|
||||
});
|
||||
|
||||
router.push("/auth/login");
|
||||
router.push("/login");
|
||||
}
|
||||
} else {
|
||||
console.log("Please fill out all the fields.");
|
||||
@@ -88,7 +79,7 @@ export default function Register() {
|
||||
>
|
||||
Register
|
||||
</div>
|
||||
<Link href={"/auth/login"} className="block mx-auto w-min">
|
||||
<Link href={"/login"} className="block mx-auto w-min">
|
||||
Login
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user