Skip to content

Commit

Permalink
feat: added an unauthenticated home context with way to navigate to a…
Browse files Browse the repository at this point in the history
…bout page with button
  • Loading branch information
bbland1 committed Sep 25, 2024
1 parent 78c3716 commit df82471
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 24 deletions.
45 changes: 24 additions & 21 deletions src/views/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import "./Home.css";
import { SingleList, CreateList } from "../components";
import { List, User } from "../api/firebase";
import { List, User } from "../api";
import { NewUserHomeInfo } from "../views";

interface Props {
data: List[];
Expand All @@ -10,26 +11,28 @@ interface Props {
}

export function Home({ data, setListPath, user }: Props) {
if (!user) {
return <NewUserHomeInfo />;
}

return (
<>
<div className="Home">
<p>
Hello from the home (<code>/</code>) page!
</p>
{user && (
<ul>
{data.map((list, index) => (
<SingleList
key={index}
name={list.name}
path={list.path}
setListPath={setListPath}
/>
))}
<CreateList user={user} setListPath={setListPath} />
</ul>
)}
</div>
</>
<div className="Home">
<p>
Hello from the home (<code>/</code>) page!
</p>
{user && (
<ul>
{data.map((list, index) => (
<SingleList
key={index}
name={list.name}
path={list.path}
setListPath={setListPath}
/>
))}
<CreateList user={user} setListPath={setListPath} />
</ul>
)}
</div>
);
}
14 changes: 11 additions & 3 deletions src/views/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { Outlet } from "react-router-dom";
import { SignInButton, User } from "../api";
import { Outlet, useNavigate } from "react-router-dom";
import { User } from "../api";
import { AuthenticatedNavBar } from "../components";

import "./Layout.css";
Expand All @@ -10,15 +10,23 @@ interface Props {
}

export function Layout({ user }: Props) {
const navigate = useNavigate();
return (
<>
<div className="Layout">
<header className="Layout-header">
<h1>Smart shopping list</h1>
</header>
<main className="Layout-main">
{user && (
<button
onClick={() => navigate("/about")}
aria-label="Navigate to the about application page."
>
about
</button>
)}
<Outlet />
{!user && <SignInButton />}
</main>
{user && <AuthenticatedNavBar />}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./Layout";
export * from "./authenticated/List";
export * from "./unauthenticated/PageNotFound";
export * from "./unauthenticated/About";
export * from "./unauthenticated/NewUserHomeInfo";
33 changes: 33 additions & 0 deletions src/views/unauthenticated/NewUserHomeInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from "react";
import { useNavigate } from "react-router-dom";
import { SignInButton } from "../../api";

export function NewUserHomeInfo() {
const navigate = useNavigate();

return (
<>
<h1>Welcome to APPLICATION NAME</h1>
<p>
The next best thing to having someone else do the shopping for you!
Create and manage smart lists learn your habits to let you know exactly
when you will need t
</p>

<article>
<p>New to APPLICATION NAME?</p>
<button
onClick={() => navigate("/about")}
aria-label="Navigate to the about application page."
>
Learn More
</button>
</article>

<article>
<p>Welcome Back:</p>
<SignInButton />
</article>
</>
);
}

0 comments on commit df82471

Please sign in to comment.