diff --git a/public/img/Home-cover2.jpg b/public/img/Home-cover2.jpg
new file mode 100644
index 0000000..c8c44d4
Binary files /dev/null and b/public/img/Home-cover2.jpg differ
diff --git a/src/App.jsx b/src/App.jsx
index dc3067e..578ed79 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -54,6 +54,7 @@ export function App() {
diff --git a/src/api/firebase.js b/src/api/firebase.js
index 216b1d2..9081001 100644
--- a/src/api/firebase.js
+++ b/src/api/firebase.js
@@ -8,6 +8,7 @@ import {
updateDoc,
addDoc,
increment,
+ arrayRemove,
deleteDoc,
} from 'firebase/firestore';
import { useEffect, useState } from 'react';
@@ -224,6 +225,18 @@ export async function deleteItem(listPath, itemId) {
const docRef = doc(db, listPath, 'items', itemId);
await deleteDoc(docRef);
}
+// delete collection path
+export async function deleteList(listPath, email) {
+ const docRef = doc(db, listPath);
+
+ const userDocRef = doc(db, 'users', email);
+
+ await deleteDoc(docRef);
+
+ await updateDoc(userDocRef, {
+ sharedLists: arrayRemove(docRef),
+ });
+}
export async function comparePurchaseUrgency(dataset) {
dataset.sort((a, b) => {
diff --git a/src/components/SingleList.css b/src/components/SingleList.css
index 1e528f0..1dc5ead 100644
--- a/src/components/SingleList.css
+++ b/src/components/SingleList.css
@@ -8,3 +8,7 @@
.SingleList-label {
margin-left: 0.2em;
}
+.selected {
+ background-color: #000000;
+ color: #e69500;
+}
diff --git a/src/components/SingleList.jsx b/src/components/SingleList.jsx
index dcbbb17..8eb20bc 100644
--- a/src/components/SingleList.jsx
+++ b/src/components/SingleList.jsx
@@ -1,26 +1,35 @@
+import React from 'react';
import './SingleList.css';
+import { MdOutlineDeleteForever } from 'react-icons/md';
+import { deleteList } from '../api';
import { Button } from '@mui/material';
-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);
- localStorage.setItem('list', name);
- }
+ };
+
+ // 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();
+ };
return (
-
-
-
+
+
+
+
+
+
+
);
}
diff --git a/src/views/Home.css b/src/views/Home.css
index e69de29..1d6331e 100644
--- a/src/views/Home.css
+++ b/src/views/Home.css
@@ -0,0 +1,34 @@
+.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 cursor-pointer;
+}
+:hover .btn {
+ background-color: #38598b;
+}
+
+/* ..........................small screen................ */
+@media only screen and (max-width: 600px) {
+ .btn,
+ .singleList {
+ font-size: 14px !important;
+ }
+ .input {
+ width: 100%;
+ }
+}
diff --git a/src/views/Home.jsx b/src/views/Home.jsx
index 474acf2..851729b 100644
--- a/src/views/Home.jsx
+++ b/src/views/Home.jsx
@@ -1,31 +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 { Button } from '@mui/material';
-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');
}
};
@@ -34,34 +28,35 @@ export function Home({ data, setListPath, userId, userEmail }) {
};
return (
-