|
@@ -1,7 +1,45 @@
|
|
|
import type { NextPage } from "next";
|
|
import type { NextPage } from "next";
|
|
|
import Link from "next/link";
|
|
import Link from "next/link";
|
|
|
|
|
+import { FC } from "react";
|
|
|
import Layout from "../components/Layout";
|
|
import Layout from "../components/Layout";
|
|
|
-import { useAuth } from "../context/UserContext";
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ useAuth,
|
|
|
|
|
+ UserContextAuthenticatedInterface,
|
|
|
|
|
+} from "../context/UserContext";
|
|
|
|
|
+
|
|
|
|
|
+const AuthenticatedView: FC<
|
|
|
|
|
+ Pick<UserContextAuthenticatedInterface, "user" | "logout">
|
|
|
|
|
+> = ({ user, logout }) => (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h1 className="text-2xl font-bold mb-4 text-center">Welcome back!</h1>
|
|
|
|
|
+ <div className="rounded w-full mx-auto border p-4 flex flex-col gap-4 xs:max-w-md xs:gap-6 xs:py-6">
|
|
|
|
|
+ <header className="flex flex-col items-center text-center gap-2 xs:flex-row xs:gap-4 xs:text-left">
|
|
|
|
|
+ <div className="h-12 w-12 bg-gray-300 rounded-full"></div>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h2 className="font-bold">{user.name}</h2>
|
|
|
|
|
+ <p className="text-sm">{user.email}</p>
|
|
|
|
|
+ <p>
|
|
|
|
|
+ <span className="bg-green-200 font-semibold font-mono rounded text-xs inline-block px-1 leading-5">
|
|
|
|
|
+ {user.team}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </header>
|
|
|
|
|
+ <div className="flex flex-col gap-2 xs:flex-row">
|
|
|
|
|
+ <Link href="/settings">
|
|
|
|
|
+ <a className="default-button">Edit profile</a>
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ onClick={() => logout()}
|
|
|
|
|
+ className="outline-button"
|
|
|
|
|
+ >
|
|
|
|
|
+ Logout
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
const Home: NextPage = () => {
|
|
const Home: NextPage = () => {
|
|
|
const { user, logout } = useAuth();
|
|
const { user, logout } = useAuth();
|
|
@@ -9,29 +47,12 @@ const Home: NextPage = () => {
|
|
|
<Layout>
|
|
<Layout>
|
|
|
<div className="">
|
|
<div className="">
|
|
|
{user ? (
|
|
{user ? (
|
|
|
- <>
|
|
|
|
|
- <h1>
|
|
|
|
|
- Welcome back, <em>{user.name}</em>!
|
|
|
|
|
- </h1>
|
|
|
|
|
- <p>
|
|
|
|
|
- You can change your settings in{" "}
|
|
|
|
|
- <Link href="/settings">
|
|
|
|
|
- <a>here</a>
|
|
|
|
|
- </Link>
|
|
|
|
|
- </p>
|
|
|
|
|
- <button
|
|
|
|
|
- type="button"
|
|
|
|
|
- onClick={() => logout()}
|
|
|
|
|
- className="form-button"
|
|
|
|
|
- >
|
|
|
|
|
- Logout
|
|
|
|
|
- </button>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ <AuthenticatedView user={user} logout={logout} />
|
|
|
) : (
|
|
) : (
|
|
|
- <>
|
|
|
|
|
- <h1>Welcome!</h1>
|
|
|
|
|
- <p>Log in to get started</p>
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h1 className="text-2xl font-bold mb-4 text-center">Welcome!</h1>
|
|
|
|
|
+ <p className="text-center">Please, sign up or log in to continue</p>
|
|
|
|
|
+ </div>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
</Layout>
|
|
</Layout>
|