Skip to content

Commit

Permalink
Merge pull request #20 from the-collab-lab/fz-rc-read-lists-items
Browse files Browse the repository at this point in the history
Issue #2: Render the List and list items a user has access to
  • Loading branch information
zahrafalak authored Aug 18, 2024
2 parents 4fac988 + 136cf25 commit b83e38b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function App() {
* Check ./api/firestore.js for its implementation.
*/
const lists = useShoppingLists(userId, userEmail);

/**
* This custom hook takes our token and fetches the data for our list.
* Check ./api/firestore.js for its implementation.
Expand Down
15 changes: 11 additions & 4 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import './Home.css';
import { SingleList } from '../components';

export function Home({ data, setListPath }) {
const hasList = data.length !== 0;
return (
<div className="Home">
<p>
Hello from the home (<code>/</code>) page!
</p>
<ul>
{/**
* TODO: write some JavaScript that renders the `lists` array
* so we can see which lists the user has access to.
*/}
{hasList &&
data.map((list, index) => (
<SingleList
key={index}
name={list.name}
path={list.path}
setListPath={setListPath}
/>
))}
</ul>
</div>
);
Expand Down
8 changes: 3 additions & 5 deletions src/views/List.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { ListItem } from '../components';

export function List({ data }) {
const hasItem = data.length !== 0;
return (
<>
<p>
Hello from the <code>/list</code> page!
</p>
<ul>
{/**
* TODO: write some JavaScript that renders the `data` array
* using the `ListItem` component that's imported at the top
* of this file.
*/}
{hasItem &&
data.map((item) => <ListItem key={item.id} name={item.name} />)}
</ul>
</>
);
Expand Down

0 comments on commit b83e38b

Please sign in to comment.