-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from green-ecolution/feature/add-vehicle-api
feat: add vehilce api
- Loading branch information
Showing
5 changed files
with
90 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { vehicleQuery } from "@/api/queries"; | ||
import LoadingInfo from "@/components/general/error/LoadingInfo"; | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { createFileRoute } from "@tanstack/react-router"; | ||
import { Suspense } from "react"; | ||
import { ErrorBoundary } from "react-error-boundary"; | ||
|
||
export const Route = createFileRoute("/_protected/vehicles/")({ | ||
component: Vehicles, | ||
meta: () => [ | ||
{ | ||
title: 'Fahrzeuge', | ||
path: '/vehicles', | ||
}, | ||
] | ||
}); | ||
|
||
function Vehicles() { | ||
const { data: vehicleRes } = useSuspenseQuery(vehicleQuery()) | ||
|
||
return ( | ||
<div className="container mt-6"> | ||
<article className="mb-20 2xl:w-4/5"> | ||
<h1 className="font-lato font-bold text-3xl mb-4 lg:text-4xl xl:text-5xl"> | ||
Auflistung aller Fahrzeuge | ||
</h1> | ||
<p> | ||
Hier finden Sie eine Übersicht aller Fahrzeuge, welche für Einsätze verwendet werden können. | ||
</p> | ||
</article> | ||
|
||
<Suspense fallback={<LoadingInfo label="Daten werden geladen" />}> | ||
<ErrorBoundary | ||
fallback={ | ||
<p className="text-center text-dark-600 mt-10"> | ||
Es ist ein Fehler aufgetreten. Bitte versuchen Sie es später | ||
erneut. | ||
</p> | ||
} | ||
> | ||
<ul> | ||
{vehicleRes.data?.length === 0 ? ( | ||
<li className="text-center text-dark-600 mt-10"> | ||
<p> | ||
Es wurden leider keine Fahrzeuge gefunden. | ||
</p> | ||
</li> | ||
) : ( | ||
vehicleRes.data?.map((vehicle, key) => ( | ||
<li key={key} className="mb-5 last:mb-0"> | ||
Fahrzeug {vehicle.id} | ||
</li> | ||
)) | ||
)} | ||
</ul> | ||
</ErrorBoundary> | ||
</Suspense> | ||
</div> | ||
); | ||
} |