stand2026_10_06
This commit is contained in:
1 parent
41f80ce947
commit
266f8c3b4f
199 files changed
+17061
-87
No files matched your search
@@ -0,0 +1,53 @@
|
||||
'use server'
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { Anlage } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function api_anlagen_getAll(): Promise<Anlage[]> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/anlage`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_anlage_getSelected(): Promise<Anlage> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/anlage/selected`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_anlage_setSelected(id: string): Promise<Anlage> {
|
||||
console.log(`http://localhost:3000/anlage/selected/${id}`);
|
||||
|
||||
const result = await fetch(`http://localhost:3000/anlage/selected/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
|
||||
console.log(result.status, result.statusText);
|
||||
|
||||
if (!result.ok) {
|
||||
const error = await result.text();
|
||||
throw new Error(`API Fehler ${result.status}: ${error}`);
|
||||
}
|
||||
|
||||
revalidatePath(Sites.anlagen.url);
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user