index.tsx 944 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import type { NextPage } from "next";
  2. import Link from "next/link";
  3. import Layout from "../components/Layout";
  4. import { useAuth } from "../context/UserContext";
  5. const Home: NextPage = () => {
  6. const { user, logout } = useAuth();
  7. return (
  8. <Layout>
  9. <div className="">
  10. {user ? (
  11. <>
  12. <h1>
  13. Welcome back, <em>{user.name}</em>!
  14. </h1>
  15. <p>
  16. You can change your settings in{" "}
  17. <Link href="/settings">
  18. <a>here</a>
  19. </Link>
  20. </p>
  21. <button
  22. type="button"
  23. onClick={() => logout()}
  24. className="form-button"
  25. >
  26. Logout
  27. </button>
  28. </>
  29. ) : (
  30. <>
  31. <h1>Welcome!</h1>
  32. <p>Log in to get started</p>
  33. </>
  34. )}
  35. </div>
  36. </Layout>
  37. );
  38. };
  39. export default Home;