Skip to content

Commit

Permalink
added UI element to List and ManageList indicating which list the use…
Browse files Browse the repository at this point in the history
…r has selected
  • Loading branch information
DevinaG007 committed Mar 25, 2024
1 parent ad8dac3 commit 0a18786
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
33 changes: 19 additions & 14 deletions src/views/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { comparePurchaseUrgency } from '../api/firebase';

export function List({ data, listPath }) {
const [searchTerm, setSearchTerm] = useState('');
const listName = listPath.split('/')[1];

const navigate = useNavigate();

Expand All @@ -27,7 +28,7 @@ export function List({ data, listPath }) {
});

filteredData.sort(comparePurchaseUrgency);

console.log(listPath);
return (
<>
{!listPath ? (
Expand All @@ -40,6 +41,7 @@ export function List({ data, listPath }) {
) : null}
{listPath && data.length === 0 ? (
<>
<h2>{listName}</h2>
<h2>
This list is currently empty. Click below to add your first item.
</h2>
Expand All @@ -49,19 +51,22 @@ export function List({ data, listPath }) {
</>
) : null}
{data.length > 0 ? (
<form>
<label htmlFor="itemFilter">
Search for an item:
<input
type="text"
id="itemFilter"
name="itemFilter"
value={searchTerm}
onChange={handleChange}
/>
</label>
{searchTerm ? <button onClick={reset}>Reset</button> : null}
</form>
<>
<h2>{listName}</h2>
<form>
<label htmlFor="itemFilter">
Search for an item:
<input
type="text"
id="itemFilter"
name="itemFilter"
value={searchTerm}
onChange={handleChange}
/>
</label>
{searchTerm ? <button onClick={reset}>Reset</button> : null}
</form>
</>
) : null}
<ul>
{filteredData.map((item) => {
Expand Down
6 changes: 3 additions & 3 deletions src/views/ManageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { addItem } from '../api';
import { shareList } from '../api/firebase.js';

export function ManageList({ listPath, userId, data }) {
const listName = listPath.split('/')[1];

const initialItemFormState = {
itemName: '',
daysUntilNextPurchase: 0,
Expand Down Expand Up @@ -71,9 +73,7 @@ export function ManageList({ listPath, userId, data }) {

return (
<>
<p>
Hello from the <code>/manage-list</code> page!
</p>
<h2>{listName}</h2>
<section>
<form onSubmit={handleItemSubmit}>
<label htmlFor="itemName">
Expand Down

0 comments on commit 0a18786

Please sign in to comment.