-
Notifications
You must be signed in to change notification settings - Fork 0
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
added styles using tailwindCss, delete not working #35
Changes from 7 commits
2e429bd
5e717fa
02f8128
afd5816
74ab503
d6687c7
de335e1
f4f106d
a2887ad
258bfb4
472cb5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,7 @@ | |
.SingleList-label { | ||
margin-left: 0.2em; | ||
} | ||
.selected { | ||
background-color: #000000; | ||
color: #e69500; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
import React from 'react'; | ||
import './SingleList.css'; | ||
import { MdOutlineDeleteForever } from 'react-icons/md'; | ||
import { deleteList } from '../api'; | ||
|
||
export function SingleList({ name, path, setListPath }) { | ||
function handleClick() { | ||
export function SingleList({ name, path, setListPath, listPath, email }) { | ||
// Function to handle selecting a list | ||
const handleClick = () => { | ||
setListPath(path); | ||
} | ||
}; | ||
|
||
// Function to handle deleting a list | ||
const handleDelete = async () => { | ||
const listPath = '/' + path; | ||
await deleteList(listPath, email); | ||
localStorage.setItem('tcl-shopping-list-path', ''); | ||
window.location.reload(); | ||
}; | ||
redapy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<li className="SingleList"> | ||
<button onClick={handleClick}>{name}</button> | ||
</li> | ||
<div | ||
className={`flex items-center justify-between ${path === listPath ? 'selected' : ''}`} | ||
> | ||
<li className="SingleList"> | ||
<button onClick={handleClick}>{name}</button> | ||
</li> | ||
<hr /> | ||
<MdOutlineDeleteForever className="text-red-700" onClick={handleDelete} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The delete button should be commented out as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check again working now |
||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
.home { | ||
background: rgba(255, 255, 255, 0.24); | ||
border-radius: 16px; | ||
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); | ||
backdrop-filter: blur(4.7px); | ||
-webkit-backdrop-filter: blur(4.7px); | ||
border: 1px solid rgba(255, 255, 255, 0.3); | ||
@apply rounded-2xl shadow-2xl px-4 md:px-24 text-black mt-8; | ||
} | ||
#list { | ||
@apply mt-8 flex flex-col justify-center items-center; | ||
} | ||
.input { | ||
@apply border border-blue-700 text-black bg-white p-3 rounded-xl; | ||
width: 70%; | ||
} | ||
.btn { | ||
background-color: #113767; | ||
@apply text-white p-3 rounded-xl shadow-md mb-8; | ||
} | ||
:hover .btn { | ||
background-color: #38598b; | ||
} | ||
.exit-btn { | ||
background-color: yellow; | ||
color: black; | ||
@apply p-3 rounded-xl shadow-md font-bold; | ||
} | ||
.hr-lines { | ||
position: relative; | ||
max-width: 500px; | ||
margin: 20px auto; | ||
text-align: center; | ||
} | ||
|
||
.hr-lines:before { | ||
content: ' '; | ||
height: 2px; | ||
width: 200px; | ||
background: red; | ||
display: block; | ||
position: absolute; | ||
top: 50%; | ||
left: 0; | ||
} | ||
|
||
.hr-lines:after { | ||
content: ' '; | ||
height: 2px; | ||
width: 200px; | ||
background: red; | ||
display: block; | ||
position: absolute; | ||
top: 50%; | ||
right: 0; | ||
} | ||
/* ..........................small screen................ */ | ||
@media only screen and (max-width: 600px) { | ||
.hr-lines { | ||
font-size: 12px; | ||
} | ||
|
||
.hr-lines:before { | ||
width: 100px; | ||
} | ||
|
||
.hr-lines:after { | ||
width: 100px; | ||
} | ||
.btn, | ||
.btn1, | ||
.singleList { | ||
font-size: 14px !important; | ||
} | ||
.input { | ||
width: 100%; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
import React, { useState } from 'react'; | ||
import { SingleList } from '../components/SingleList'; | ||
import './Home.css'; | ||
import { createList } from '../api/firebase'; | ||
import { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Link, useNavigate } from 'react-router-dom'; | ||
|
||
export function Home({ data, setListPath, userId, userEmail }) { | ||
export function Home({ data, listPath, setListPath, userId, userEmail }) { | ||
const [name, setName] = useState(''); | ||
const navigate = useNavigate(); | ||
|
||
const handleSubmit = async (event) => { | ||
event.preventDefault(); // Prevent the default form submission behavior. | ||
event.preventDefault(); | ||
|
||
try { | ||
const newList = await createList(userId, userEmail, name); | ||
setListPath(newList); // creates a new list and automatically creates the userId | ||
// that tracks the purchased item and also saves it to local storage | ||
|
||
setName(''); //refreshes the form after submission place takes it back to the default state | ||
|
||
alert('The item has been added.'); //alert message | ||
|
||
navigate('/list'); // navigate to list page | ||
setListPath(newList); | ||
setName(''); | ||
alert('The item has been added.'); | ||
navigate('/list'); | ||
} catch (err) { | ||
console.error(err); | ||
|
||
alert('item not created'); //alert message if there is an error with creating the item | ||
alert('Item not created'); | ||
} | ||
}; | ||
|
||
|
@@ -33,35 +28,45 @@ export function Home({ data, setListPath, userId, userEmail }) { | |
}; | ||
|
||
return ( | ||
<div className="Home"> | ||
<p> | ||
Hello from the home (<code>/</code>) page! | ||
</p> | ||
|
||
<div className="home"> | ||
<form id="list" onSubmit={handleSubmit}> | ||
<label htmlFor="listName">Name of shopping list: </label> | ||
<label htmlFor="listName" className="pt-8 font-bold text-center"> | ||
Kindly generate a shopping List | ||
</label> | ||
<br /> | ||
<input | ||
type="text" | ||
id="listName" | ||
value={name} | ||
onChange={handleChange} | ||
className="input" | ||
placeholder="Type Here..." | ||
required | ||
/> | ||
<br /> | ||
<button type="submit">Create list</button> | ||
<div className="btn"> | ||
<button type="submit">Register List</button> | ||
</div> | ||
</form> | ||
|
||
<ul> | ||
{data?.map((item) => ( | ||
<SingleList | ||
key={item.path} | ||
name={item.name} | ||
email={userEmail} | ||
path={item.path} | ||
setListPath={setListPath} | ||
listPath={listPath} // Pass listPath to SingleList | ||
/> | ||
Comment on lines
+59
to
60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to pass the listPath further, just use it here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont really understand... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. before you were using another duplicated state Now you will use the |
||
))} | ||
</ul> | ||
<h2 className="hr-lines">Tried🥱?</h2> | ||
|
||
<div className="flex justify-center flex-center m-6 exit-btn"> | ||
<Link to="/manage-list"> | ||
<button className="btn1"> Create a List Right Away!</button> | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done 💥✨! we don't want the user to have a shared list that does not exist 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay changed that