Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rt buttons #56

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 45 additions & 33 deletions src/components/AddItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,49 +68,61 @@ export function AddItem({ data, listPath }) {
};

return (
<>
<form onSubmit={handleNewItemSubmit} className="add-item-form">
<div className="flex flex-col items-center justify-center mx-auto">
<form onSubmit={handleNewItemSubmit} className="m-2 p-2 items-center">
{/* Item Name Section */}
<div className="flex items-center mb-4">
<label htmlFor="name" className="mr-2">
Item name:{' '}
</label>
<input
id="name"
type="text"
placeholder="Enter new item name"
value={formNewItem.name}
onChange={handleNewItemChange}
name="name"
required
className="border p-2"
/>
<span className="text-center">
<label htmlFor="name" className="mr-2">
Item name:{' '}
</label>
<input
id="name"
type="text"
placeholder="Enter new item name"
value={formNewItem.name}
onChange={handleNewItemChange}
name="name"
required
className="border p-2"
/>
</span>
</div>

{/* Urgency Section */}
<div className="flex items-center mb-4">
<label htmlFor="nextPurchase" className="mb-2">
Urgency:{' '}
</label>
<select
name="nextPurchase"
id="nextPurchase"
onChange={handleNewItemChange}
value={formNewItem.nextPurchase}
required
className="border p-2 rounded mb-4"
>
<option value="">Select Urgency</option>
<option value={7}>Soon</option>
<option value={14}>Kind of soon</option>
<option value={30}>Not soon</option>
</select>
<span className="text-center m-4">
<label
htmlFor="nextPurchase"
className="justify-items-start m-2 p-2 mb-2"
>
Urgency:{' '}
</label>
<select
name="nextPurchase"
id="nextPurchase"
onChange={handleNewItemChange}
value={formNewItem.nextPurchase}
required
className="border p-2 rounded mb-4"
>
<option value="">Select Urgency</option>
<option value={7}>Soon</option>
<option value={14}>Kind of soon</option>
<option value={30}>Not soon</option>
</select>
</span>
</div>

<button type="submit">Add Item</button>
<button
type="submit"
className="p-2 border-2 rounded-full border-yellow-300 hover:shadow-lg"
>
Add Item
</button>

<p>{messageItem}</p>
</form>
</>
</div>
);
}
12 changes: 9 additions & 3 deletions src/components/AddList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,23 @@ export function AddList({ setListPath, userId, userEmail }) {

return (
<>
<form onSubmit={handleCreateListButton}>
<label htmlFor="listName">List Name:</label>
<form className="m-2" onSubmit={handleCreateListButton}>
<label htmlFor="listName" className="text-2xl text-center m-2">
List Name:
</label>
<input
className="m-4"
type="text"
id="listName"
value={listName}
onChange={(e) => setListName(e.target.value)}
placeholder="Enter the name of your new list"
required
/>
<button type="submit" className="button">
<button
type="submit"
className="m-4 p-2 border-2 rounded-full border-yellow-300 hover:shadow-lg"
>
Create list
</button>
</form>
Expand Down
7 changes: 3 additions & 4 deletions src/components/ListItem.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useState, useEffect } from 'react';
import './ListItem.css';
import { FaTrashCan } from 'react-icons/fa6';
import { FaCartShopping } from 'react-icons/fa6';
import { FaTrashCan, FaCartShopping } from 'react-icons/fa6';

export function ListItem({
name,
Expand Down Expand Up @@ -43,7 +42,7 @@ export function ListItem({
};

return (
<div className="list-item flex items-center justify-between p-3">
<div className="list-item items-center justify-between p-3 rounded-xl">
<div className="flex items-center justify-between space-x-2">
<label className="flex items-center space-x-2">
<input
Expand All @@ -60,7 +59,7 @@ export function ListItem({
</label>
<div className="flex items-center space-x-2">
<span
className={`px-2 py-1 border text-sm font-medium ${categoryColor[category]}`}
className={`px-2 py-1 border text-sm font-medium uppercase ${categoryColor[category]}`}
style={{ color: categoryColor[category] }}
>
{category}
Expand Down
12 changes: 9 additions & 3 deletions src/components/SingleList.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './SingleList.css';
// import './SingleList.css';
import { useNavigate } from 'react-router-dom';
import { deleteList } from '../api';
import { FaTrashCan } from 'react-icons/fa6';

export function SingleList({ name, path, setListPath, userId, userEmail }) {
const navigate = useNavigate();
Expand All @@ -24,10 +25,15 @@ export function SingleList({ name, path, setListPath, userId, userEmail }) {
};

return (
<li className="SingleList">
<li className="flex flex-row items-baseline text-lg m-4 p-2 border-2 rounded-xl border-yellow-300 hover:shadow-lg">
<button onClick={handleClick}>{name}</button>
{isUsersList && (
<button onClick={() => handleDelete(path, userEmail)}>X</button>
<button
className="flex place-self-center pl-2"
onClick={() => handleDelete(path, userEmail)}
>
<FaTrashCan className="" />
</button>
)}
</li>
);
Expand Down
10 changes: 10 additions & 0 deletions src/components/SingleListOld.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.SingleList {
align-items: baseline;
display: flex;
flex-direction: row;
font-size: 1.2em;
}

.SingleList-label {
margin-left: 0.2em;
}
83 changes: 45 additions & 38 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,52 @@ export function Home({ data, setListPath, userId, userEmail }) {

return (
<div className="Home">
{!!user ? (
<>
<p>Welcome back {auth.currentUser.displayName.split(' ')[0]}!</p>
{data.length === 0 && (
<p>
{' '}
You don&apos;t have any shopping lists yet. Start by creating your
first one!
<div className="container mx-auto px-2 flex flex-col items-center justify-center justify-items-center">
{!!user ? (
<>
<p className="text-3xl ">
Welcome back {auth.currentUser.displayName.split(' ')[0]}!
</p>
)}
{data.length > 0 && (
<ul>
{data.map((list, id) => (
<SingleList
key={id}
name={list.name}
path={list.path}
setListPath={setListPath}
userId={userId}
userEmail={userEmail}
/>
))}
</ul>
)}
<AddList
setListPath={setListPath}
userId={userId}
userEmail={userEmail}
/>
</>
) : (
<>
<p>
Welcome to the Shopping List app. Some catchy phrase / intro
message. Picture below?
</p>
<SignInButton></SignInButton>
</>
)}
{data.length === 0 && (
<p>
{' '}
You don&apos;t have any shopping lists yet. Start by creating
your first one!
</p>
)}
{data.length > 0 && (
<ul>
{data.map((list, id) => (
<SingleList
key={id}
name={list.name}
path={list.path}
setListPath={setListPath}
userId={userId}
userEmail={userEmail}
/>
))}
</ul>
)}
<AddList
setListPath={setListPath}
userId={userId}
userEmail={userEmail}
/>
</>
) : (
<>
<p className="text-2xl text-center">
Welcome to Shop&apos;n Go the smart app that keeps track of your
shopping lists and schedule.
</p>
<p className="text-lg italic mt-5 text-center">
Smart Choices, Swift Shopping!
</p>
<SignInButton className="rounded-full border-yellow-300 border-2 hover:bg-yellow-300"></SignInButton>
</>
)}
</div>
</div>
);
}
3 changes: 1 addition & 2 deletions src/views/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Outlet, NavLink, Link } from 'react-router-dom';
import { SignInButton, SignOutButton, useAuth } from '../api/useAuth';

import {
FaShoppingCart,
FaHome,
FaClipboardList,
FaShareAlt,
Expand Down Expand Up @@ -47,7 +46,7 @@ export function Layout() {
{user && (
<NavLink to="/manage-list" className="Nav-link">
<FaShareAlt />
<span className="hidden md:inline">Manage List</span>
<span className="hidden md:inline">Settings</span>
</NavLink>
)}
<NavLink to="/about" className="Nav-link">
Expand Down
45 changes: 28 additions & 17 deletions src/views/List.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { ListItem, AddItem } from '../components';
import { FiDelete } from 'react-icons/fi';
import {
comparePurchaseUrgency,
updateItem,
Expand All @@ -9,6 +10,7 @@ import {

export function List({ data, listPath, lists }) {
const [searchItem, setSearchItem] = useState('');
// eslint-disable-next-line no-unused-vars
const [items, setItems] = useState([]);

const listTitle = listPath ? listPath.split('/')[1] : null;
Expand Down Expand Up @@ -66,8 +68,8 @@ export function List({ data, listPath, lists }) {
};

return (
<>
<h2>{fixedListTitle}</h2>
<div className="container mx-auto px-4 min-h-screen flex flex-col items-center justify-center justify-items-center mb-40">
<h2 className="text-3xl">{fixedListTitle}</h2>
{!listPath && lists.length > 0 && data.length > 0 && (
<p>
Oops! No list selected yet. Head to the <Link to="/">home page</Link>{' '}
Expand Down Expand Up @@ -99,20 +101,29 @@ export function List({ data, listPath, lists }) {

<form onSubmit={handleSearch}>
<div>
<label htmlFor="search-item-in-list"> Search items:</label>
<input
onChange={handleSearch}
type="text"
id="search-item-in-list"
value={searchItem}
placeholder="Search an item..."
aria-label="Search for items"
/>
{searchItem && (
<button type="button" onClick={clearSearch}>
x
</button>
)}
<span className="flex flex-col m-2 p-2 justify-evenly">
<label
htmlFor="search-item-in-list"
className="text-center m-4"
>
{' '}
Search items:
</label>
<input
className="border"
onChange={handleSearch}
type="text"
id="search-item-in-list"
value={searchItem}
placeholder="Search an item..."
aria-label="Search for items"
/>
{searchItem && (
<button type="button" onClick={clearSearch}>
<FiDelete />
</button>
)}
</span>
</div>
</form>

Expand Down Expand Up @@ -152,6 +163,6 @@ export function List({ data, listPath, lists }) {
)}
</>
)}
</>
</div>
);
}
Loading
Loading