Benutzerdaten beim Speichern/Bestellen in Tabelle Benutzer speichern

This commit is contained in:
Carl Mahnke
2025-05-14 13:53:19 +02:00
parent 58a8136479
commit d76b8b4e14
3 changed files with 75 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
import { Aufnahme, Objekt } from "#lib/client/prisma.js";
import { Aufnahme, Benutzer, Objekt } from "#lib/client/prisma.js";
import { api } from "astro-typesafe-api/client";
import Cookies from "js-cookie";
@@ -161,4 +161,32 @@ export async function objektSpeichern(objekt: Objekt & { id?: string }): Promise
return id;
}
}
export async function benutzerSpeichern(benutzer: Partial<Benutzer>): Promise<string> {
const completeBenutzer: Benutzer = {
id: benutzer.id,
name: benutzer.name ?? null,
email: benutzer.email,
passwort: benutzer.passwort,
adresse: benutzer.adresse ?? null,
anrede: benutzer.anrede ?? null,
firma: benutzer.firma ?? null,
vorname: benutzer.vorname ?? null,
ort: benutzer.ort ?? null,
plz: benutzer.plz ?? null,
profilbild: benutzer.profilbild ?? null,
telefon: benutzer.telefon ?? null,
updated_at: new Date(),
verified: false
};
await api.user.POST.fetch(completeBenutzer
, {
headers: {
Authorization: `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
}
});
return benutzer.id;
}