Login Popup zu Kundendaten bewegt
This commit is contained in:
@@ -3,14 +3,14 @@ import { api } from "astro-typesafe-api/client"
|
||||
import { exclude } from "#lib/exclude.js";
|
||||
import Cookies from "js-cookie";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient, } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BildClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient, } from "#components/Ausweis/types.js";
|
||||
import { Enums } from "@ibcornelsen/database/client";
|
||||
|
||||
export async function ausweisSpeichern(
|
||||
ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient,
|
||||
objekt: ObjektClient,
|
||||
aufnahme: AufnahmeClient,
|
||||
bilder: (UploadedGebaeudeBild & { base64?: string })[],
|
||||
bilder: BildClient[],
|
||||
ausweisart: Enums.Ausweisart
|
||||
) {
|
||||
if (objekt.uid) {
|
||||
@@ -99,26 +99,15 @@ export async function ausweisSpeichern(
|
||||
ausweis.uid = uid;
|
||||
}
|
||||
|
||||
for (const bild of bilder) {
|
||||
if (bild.uid) {
|
||||
continue;
|
||||
await api.aufnahme._uid.bilder.PUT.fetch(bilder.map(bild => bild.uid), {
|
||||
params: {
|
||||
uid: aufnahme.uid
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
|
||||
const response = await api.aufnahme._uid.bilder.PUT.fetch({
|
||||
data: bild.data,
|
||||
kategorie: bild.kategorie
|
||||
}, {
|
||||
params: {
|
||||
uid: aufnahme.uid
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
|
||||
bild.uid = response.uid
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
return {
|
||||
uid_ausweis: ausweis.uid,
|
||||
uid_aufnahme: aufnahme.uid,
|
||||
|
||||
Reference in New Issue
Block a user