mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2026-05-01 02:59:09 +00:00
fixed changed /api/mapping structure in frontend
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
export interface IDMapping {
|
||||
id_map: IDMap
|
||||
}
|
||||
|
||||
export interface IDMap {
|
||||
[name: string]: Name
|
||||
}
|
||||
@@ -11,6 +7,23 @@ export interface Name {
|
||||
last: string,
|
||||
}
|
||||
|
||||
function stupidSerdeFix(pairs: [string, Name][]): IDMap {
|
||||
const map: IDMap = {};
|
||||
for (const [key, value] of pairs) {
|
||||
map[key] = value;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
export async function fetchMapping(): Promise<IDMap> {
|
||||
let res = await fetch("/api/mapping");
|
||||
|
||||
let data = await res.json();
|
||||
|
||||
return stupidSerdeFix(data);
|
||||
}
|
||||
|
||||
export async function addMapping(id: string, firstName: string, lastName: string) {
|
||||
let req = await fetch("/api/mapping", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user