Highlight und neue ID
This commit is contained in:
@@ -13,8 +13,8 @@ export async function ausweisSpeichern(
|
||||
bilder: BildClient[],
|
||||
ausweisart: Enums.Ausweisart
|
||||
) {
|
||||
if (objekt.uid) {
|
||||
await api.objekt._uid.PATCH.fetch({
|
||||
if (objekt.id) {
|
||||
await api.objekt._id.PATCH.fetch({
|
||||
adresse: objekt.adresse,
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
@@ -22,14 +22,14 @@ export async function ausweisSpeichern(
|
||||
plz: objekt.plz
|
||||
}, {
|
||||
params: {
|
||||
uid: objekt.uid
|
||||
id: objekt.id
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const { uid } = await api.objekt.PUT.fetch({
|
||||
const { id } = await api.objekt.PUT.fetch({
|
||||
adresse: objekt.adresse,
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
@@ -41,16 +41,16 @@ export async function ausweisSpeichern(
|
||||
}
|
||||
})
|
||||
|
||||
objekt.uid = uid;
|
||||
objekt.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (aufnahme.uid) {
|
||||
await api.aufnahme._uid.PATCH.fetch({
|
||||
if (aufnahme.id) {
|
||||
await api.aufnahme._id.PATCH.fetch({
|
||||
baujahr_gebaeude: aufnahme.baujahr_gebaeude,
|
||||
baujahr_heizung: aufnahme.baujahr_heizung,
|
||||
baujahr_klima: aufnahme.baujahr_klima,
|
||||
baujahr_klima: aufnahme.baujahr_klima || [],
|
||||
alternative_heizung: aufnahme.alternative_heizung,
|
||||
alternative_kuehlung: aufnahme.alternative_kuehlung,
|
||||
alternative_lueftung: aufnahme.alternative_lueftung,
|
||||
@@ -102,14 +102,14 @@ export async function ausweisSpeichern(
|
||||
zirkulation: aufnahme.zirkulation
|
||||
}, {
|
||||
params: {
|
||||
uid: aufnahme.uid
|
||||
id: aufnahme.id
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const { uid } = await api.aufnahme.PUT.fetch({
|
||||
const { id } = await api.aufnahme.PUT.fetch({
|
||||
aufnahme: {
|
||||
baujahr_gebaeude: aufnahme.baujahr_gebaeude,
|
||||
baujahr_heizung: aufnahme.baujahr_heizung,
|
||||
@@ -165,56 +165,56 @@ export async function ausweisSpeichern(
|
||||
zentralheizung: aufnahme.zentralheizung,
|
||||
zirkulation: aufnahme.zirkulation
|
||||
},
|
||||
uid_objekt: objekt.uid
|
||||
objekt_id: objekt.id
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
|
||||
aufnahme.uid = uid
|
||||
aufnahme.id = id
|
||||
}
|
||||
|
||||
let patchRoute: any;
|
||||
let putRoute: any;
|
||||
if (ausweisart == Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
patchRoute = api["verbrauchsausweis-wohnen"]._uid.PATCH
|
||||
patchRoute = api["verbrauchsausweis-wohnen"]._id.PATCH
|
||||
putRoute = api["verbrauchsausweis-wohnen"].PUT
|
||||
} else if (ausweisart == Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
patchRoute = api["verbrauchsausweis-gewerbe"]._uid.PATCH
|
||||
patchRoute = api["verbrauchsausweis-gewerbe"]._id.PATCH
|
||||
putRoute = api["verbrauchsausweis-gewerbe"].PUT
|
||||
} else if (ausweisart == Enums.Ausweisart.BedarfsausweisWohnen) {
|
||||
patchRoute = api["bedarfsausweis-wohnen"]._uid.PATCH
|
||||
patchRoute = api["bedarfsausweis-wohnen"]._id.PATCH
|
||||
putRoute = api["bedarfsausweis-wohnen"].PUT
|
||||
}
|
||||
|
||||
if (ausweis.uid) {
|
||||
if (ausweis.id) {
|
||||
await patchRoute.fetch({
|
||||
...exclude(ausweis, ["uid"])
|
||||
...exclude(ausweis, ["id"])
|
||||
}, {
|
||||
params: {
|
||||
uid: ausweis.uid
|
||||
id: ausweis.id
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const { uid } = await putRoute.fetch({
|
||||
const { id } = await putRoute.fetch({
|
||||
ausweis,
|
||||
uid_aufnahme: aufnahme.uid
|
||||
aufnahme_id: aufnahme.id
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
|
||||
ausweis.uid = uid;
|
||||
ausweis.id = id;
|
||||
}
|
||||
|
||||
await api.aufnahme._uid.bilder.PUT.fetch(bilder.map(bild => bild.uid), {
|
||||
await api.aufnahme._id.bilder.PUT.fetch(bilder.map(bild => bild.id), {
|
||||
params: {
|
||||
uid: aufnahme.uid
|
||||
id: aufnahme.id
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
@@ -222,29 +222,8 @@ export async function ausweisSpeichern(
|
||||
})
|
||||
|
||||
return {
|
||||
uid_ausweis: ausweis.uid,
|
||||
uid_aufnahme: aufnahme.uid,
|
||||
uid_objekt: objekt.uid
|
||||
ausweis_id: ausweis.id,
|
||||
aufnahme_id: aufnahme.id,
|
||||
objekt_id: objekt.id
|
||||
}
|
||||
|
||||
|
||||
// await client.v1.tickets.erstellen.mutate({
|
||||
// titel: "Ausweis konnte nicht gespeichert werden",
|
||||
// beschreibung: e.stack,
|
||||
// email: user.email ?? "",
|
||||
// metadata: JSON.stringify({
|
||||
// ausweis,
|
||||
// }),
|
||||
// });
|
||||
|
||||
// addNotification({
|
||||
// dismissable: false,
|
||||
// message:
|
||||
// "Ausweis konnte nicht gespeichert werden, bitte versuchen sie es erneut.",
|
||||
// subtext:
|
||||
// "Sollte das Problem weiterhin bestehen, kontaktieren sie bitte den Support.",
|
||||
// timeout: 6000,
|
||||
// type: "error",
|
||||
// });
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user