generated from Dicken/dickendock
Commit 8: Plugin-System (Scanner erweitern, Geräte importieren, Icons)
This commit is contained in:
17
apps/frontend/src/hooks/usePlugins.ts
Normal file
17
apps/frontend/src/hooks/usePlugins.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import type { PluginInfo } from "@launchpad/shared";
|
||||
|
||||
async function fetchPlugins(): Promise<PluginInfo[]> {
|
||||
const res = await fetch("/api/plugins");
|
||||
if (!res.ok) {
|
||||
throw new Error(`Plugins konnten nicht geladen werden (HTTP ${res.status})`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function usePlugins() {
|
||||
return useQuery({
|
||||
queryKey: ["plugins"],
|
||||
queryFn: fetchPlugins,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user