From 14d5e0cfa262e66775b4d5ddd538ef31b16215df Mon Sep 17 00:00:00 2001 From: Eva Langerova Date: Tue, 24 Sep 2024 19:08:12 +0200 Subject: [PATCH] create a new About view, conditional render of Home view and navbar for anonymous/logged in users --- src/App.jsx | 3 +- src/views/About.jsx | 17 +++++++++ src/views/Home.jsx | 83 +++++++++++++++++++++++++------------------- src/views/Layout.css | 6 ++++ src/views/Layout.jsx | 29 +++++++++------- src/views/index.js | 1 + 6 files changed, 91 insertions(+), 48 deletions(-) create mode 100644 src/views/About.jsx diff --git a/src/App.jsx b/src/App.jsx index 7a14ac5..871e34a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,6 +1,6 @@ import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; -import { Home, Layout, List, ManageList } from './views'; +import { Home, Layout, List, ManageList, About } from './views'; import { useAuth, useShoppingListData, useShoppingLists } from './api'; @@ -55,6 +55,7 @@ export function App() { /> } /> + } /> } diff --git a/src/views/About.jsx b/src/views/About.jsx new file mode 100644 index 0000000..be2e9bb --- /dev/null +++ b/src/views/About.jsx @@ -0,0 +1,17 @@ +export function About() { + return ( + <> +

This is the About page

+

We want to add following info here:

+
    +
  • introduction to the app - what does it do
  • +
  • how to use the app
  • +
  • info/link to collab lab
  • +
  • github link to the app repo
  • +
  • + info/github links to dev team - optional +
  • +
+ + ); +} diff --git a/src/views/Home.jsx b/src/views/Home.jsx index 6783c04..fc95dca 100644 --- a/src/views/Home.jsx +++ b/src/views/Home.jsx @@ -3,11 +3,14 @@ import { SingleList } from '../components'; import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { createList } from '../api/firebase'; +import { auth } from '../api/config.js'; +import { SignInButton, useAuth } from '../api/useAuth'; export function Home({ data, setListPath, userId, userEmail }) { const [listName, setListName] = useState(''); const [message, setMessage] = useState(''); const navigate = useNavigate(); + const { user } = useAuth(); const handleCreateListButton = async (e) => { e.preventDefault(); @@ -31,43 +34,53 @@ export function Home({ data, setListPath, userId, userEmail }) { return (
-

- Hello from the home (/) page! -

- {data.length === 0 && ( -

- {' '} - It seems you don't have any lists yet, Please create a list using - the form below -

- )} - {data.length > 0 && ( -
    - {data.map((list, id) => ( - +

    Welcome back {auth.currentUser.displayName}!

    + {data.length === 0 && ( +

    + {' '} + It seems you don't have any lists yet, Please create a list + using the form below +

    + )} + {data.length > 0 && ( +
      + {data.map((list, id) => ( + + ))} +
    + )} + +
    + + setListName(e.target.value)} + placeholder="Enter the name of your new list" /> - ))} -
+ + {message} + + + ) : ( + <> +

+ Welcome to the Shopping List app. Some catchy phrase / intro + message. Picture below? +

+ + )} - -
- - setListName(e.target.value)} - placeholder="Enter the name of your new list" - /> - - {message} -
); } diff --git a/src/views/Layout.css b/src/views/Layout.css index 85be734..c2e0bf5 100644 --- a/src/views/Layout.css +++ b/src/views/Layout.css @@ -71,3 +71,9 @@ text-decoration-thickness: 0.22em; text-underline-offset: 0.1em; } + +header { + display: flex; + justify-content: space-between; + align-items: center; +} diff --git a/src/views/Layout.jsx b/src/views/Layout.jsx index 4f4347a..82bb35d 100644 --- a/src/views/Layout.jsx +++ b/src/views/Layout.jsx @@ -1,6 +1,5 @@ -import { Outlet, NavLink } from 'react-router-dom'; +import { Outlet, NavLink, Link } from 'react-router-dom'; import './Layout.css'; -import { auth } from '../api/config.js'; import { SignInButton, SignOutButton, useAuth } from '../api/useAuth'; /** @@ -17,12 +16,11 @@ export function Layout() { <>
-

Smart shopping list

+ +

#APP/LogoPic

+ {!!user ? ( -
- Welcome {auth.currentUser.displayName}! - -
+ ) : ( )} @@ -35,11 +33,18 @@ export function Layout() { Home - - List - - - Manage List + {user && ( + + List + + )} + {user && ( + + Manage List + + )} + + About
diff --git a/src/views/index.js b/src/views/index.js index 9f10e56..e9d231b 100644 --- a/src/views/index.js +++ b/src/views/index.js @@ -2,3 +2,4 @@ export * from './ManageList'; export * from './Home'; export * from './Layout'; export * from './List'; +export * from './About';