From 5fc3dd0cd18e78707c94313ee707ea6658312100 Mon Sep 17 00:00:00 2001 From: vivitt Date: Fri, 5 Apr 2024 15:08:36 +0200 Subject: [PATCH] Set focus on ManageList buttons - Add an optional parameter in the managelist route to use it to programatically set focus on the inputs when users navigate to it using the buttons in the List view. - Remove selected property in the Select input first's option to avoid console warning --- src/App.jsx | 2 +- src/api/firebase.js | 8 +++++++- src/components/ListButtons.jsx | 4 ++-- src/views/ManageList.jsx | 24 ++++++++++++++++++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index bdfe690..e212802 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -79,7 +79,7 @@ export function App() { } /> { + return path.includes(id); +}; + /** * Delete a user's list only if the current user is the list owner. * @param {string} userId The id of the user who owns the list. @@ -184,7 +188,7 @@ export async function shareList(listPath, currentUserId, recipientEmail) { */ export async function deleteList(userId, userEmail, listPath, listId) { // Check if current user is owner. - if (!listPath.includes(userId)) { + if (!userIsListOwner(userId, listPath)) { const usersCollectionRef = collection(db, 'users'); const userDocumentRef = doc(usersCollectionRef, userEmail); const userSharedLists = (await getDoc(userDocumentRef)).data().sharedLists; @@ -199,6 +203,8 @@ export async function deleteList(userId, userEmail, listPath, listId) { // Delete list doc const listCollectionRef = collection(db, userId); const listDocumentRef = doc(listCollectionRef, listId); + const itemsCollectionRef = collection(listDocumentRef, 'items'); + console.log(itemsCollectionRef); await deleteDoc(listDocumentRef); // Update users doc that include a list reference diff --git a/src/components/ListButtons.jsx b/src/components/ListButtons.jsx index b4c6981..6ff5d4a 100644 --- a/src/components/ListButtons.jsx +++ b/src/components/ListButtons.jsx @@ -13,7 +13,7 @@ const ListButtons = (props) => {