From 20ff47f5acf21122b5f368de7f0d5d715a6a0082 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 26 May 2024 14:20:12 -0700 Subject: [PATCH] feat: adds add item button, weird copying of items bug and every action requires a refresh or the useeffect enters a infinate loop --- frontend/src/components/EditItem.tsx | 34 +---- frontend/src/components/ItemGroup.tsx | 149 ++++++++++++--------- frontend/src/components/NewItemOptions.tsx | 42 +++--- 3 files changed, 108 insertions(+), 117 deletions(-) diff --git a/frontend/src/components/EditItem.tsx b/frontend/src/components/EditItem.tsx index 84ff66c..bc0c92f 100644 --- a/frontend/src/components/EditItem.tsx +++ b/frontend/src/components/EditItem.tsx @@ -89,20 +89,6 @@ const EditItem: React.FC = ({ itemId }) => { const format = (val: any) => `$` + val; const parse = (val: any) => val.replace(/^\$/, ""); - const handleDelete = async () => { - try { - const response = await fetch(`http://localhost:3001/items/${itemId}`, { - method: "DELETE", - }); - if (!response.ok) { - throw new Error(`Error: ${response.statusText}`); - } - console.log("Item deleted successfully"); - } catch (error) { - console.error("There was an error deleting the item", error); - } - }; - const handleSaveChanges = async () => { try { const updatedItem = { @@ -136,6 +122,7 @@ const EditItem: React.FC = ({ itemId }) => { } else { console.error("Failed to update profile"); } + window.location.reload(); } catch (error) { console.error("Error updating profile:", error); } @@ -315,7 +302,11 @@ const EditItem: React.FC = ({ itemId }) => { - + - + } + colorScheme="teal" + />