fix: display warning message on database connection error
This commit is contained in:
parent
ece5a3cc85
commit
8c5fefc282
1 changed files with 13 additions and 2 deletions
|
|
@ -91,11 +91,17 @@ function Navigation() {
|
|||
|
||||
export default function App() {
|
||||
const [trips, setTrips] = useState<any[]>([]);
|
||||
const [dbError, setDbError] = useState<string | null>(null);
|
||||
const navigate = useNavigate();
|
||||
|
||||
async function loadTrips() {
|
||||
const data = await getTrips();
|
||||
setTrips(data);
|
||||
try {
|
||||
const data = await getTrips();
|
||||
setTrips(data);
|
||||
setDbError(null);
|
||||
} catch (err) {
|
||||
setDbError("Warnung: Verbindung zur Datenbank fehlgeschlagen!");
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -114,6 +120,11 @@ export default function App() {
|
|||
return (
|
||||
<div className="p-4 max-w-5xl mx-auto">
|
||||
<Navigation />
|
||||
{dbError && (
|
||||
<div className="mb-4 p-3 bg-red-100 text-red-700 rounded border border-red-300 font-semibold text-center">
|
||||
{dbError}
|
||||
</div>
|
||||
)}
|
||||
<Routes>
|
||||
<Route path="/trips" element={<TripsPage />} />
|
||||
<Route path="/trips/:id" element={<TripChecklist trips={trips} />} />
|
||||
|
|
|
|||
Loading…
Reference in a new issue