From ed0593eb639b2e706d05dc4f9cbb2323c516a72a Mon Sep 17 00:00:00 2001 From: Robert Stolz Date: Thu, 21 Nov 2024 10:40:54 +0100 Subject: [PATCH] edit works, asyncon works --- frontend/src/App.tsx | 4 +--- frontend/src/components/Details.tsx | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b5fc645..a0f2d10 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -44,15 +44,13 @@ export default function App() { const handleSaveEdit = (id: string, editData: Restaurant) => { - if (!id) return; - axios + return axios .put(`/api/restaurant/${id}`, editData) .then((response) => { setRestaurants(prevRestaurants => prevRestaurants.map(r => r.id === id ? response.data : r) ); - navigate(`/`); }) .catch((error) => console.error("Error saving restaurant edits:", error)); }; diff --git a/frontend/src/components/Details.tsx b/frontend/src/components/Details.tsx index b611a7f..13c56c3 100644 --- a/frontend/src/components/Details.tsx +++ b/frontend/src/components/Details.tsx @@ -4,7 +4,7 @@ import { useEffect, useState } from "react"; import {useNavigate, useParams} from "react-router-dom"; type detailsEditProps = { - handleSaveEdit: (id:string, editData:Restaurant) => void; + handleSaveEdit: (id:string, editData:Restaurant) => Promise; } export default function Details(props: Readonly) { @@ -83,7 +83,7 @@ export default function Details(props: Readonly) { cols={40} /> - +