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,60 @@
|
||||
"use server";
|
||||
|
||||
import { Sites } from "@/_config/sites";
|
||||
import { Group, Peripherie, PeripherieFilterOptionen, PeripherieUpdate } from "@/types/rk";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
|
||||
|
||||
export async function PeripherieFindApi(filter?: PeripherieFilterOptionen): Promise<Peripherie[]> {
|
||||
let filterStr = '';
|
||||
if (filter && (filter.adrByte || filter.elementId || filter.groupId)) {
|
||||
filterStr = '?'
|
||||
if (filter.adrByte) filterStr += 'adrByte=' + filter.adrByte;
|
||||
if (filter.groupId) filterStr += 'groupId=' + filter.groupId;
|
||||
if (filter.elementId) filterStr += 'elementId=' + filter.elementId;
|
||||
}
|
||||
console.log(`http://localhost:3000/peripherie` + filterStr)
|
||||
const result = await fetch(`http://localhost:3000/peripherie` + filterStr, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function GetEA_Differences(): Promise<Peripherie[]> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/peripherie/differences`, {
|
||||
method: 'GET',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
const data = await result.json();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function api_peripherieUpdate(id: string, data: PeripherieUpdate): Promise<ActionResult<Peripherie>> {
|
||||
|
||||
const result = await fetch(`http://localhost:3000/peripherie/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
|
||||
const resultData = await result.json();
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errors: resultData.message, // kommt aus NestJS
|
||||
};
|
||||
}
|
||||
|
||||
revalidatePath(Sites.peripheries.url);
|
||||
return { success: true };
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user