Felder angepasst und Tests
This commit is contained in:
@@ -11,34 +11,33 @@ export const PUT = defineApiRoute({
|
||||
input: GEGEinpreisungSchema.omit({
|
||||
benutzer_id: true,
|
||||
id: true,
|
||||
uid: true,
|
||||
status: true,
|
||||
}).merge(z.object({
|
||||
nachweis_uid: UUidWithPrefix
|
||||
nachweis_id: UUidWithPrefix
|
||||
})),
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(input.nachweis_uid);
|
||||
const ausweisart = getAusweisartFromUUID(input.nachweis_id);
|
||||
|
||||
let einpreisung;
|
||||
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||
nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||
where: {
|
||||
uid: input.nachweis_uid
|
||||
id: input.nachweis_id
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.GEGNachweisGewerbe) {
|
||||
nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
||||
where: {
|
||||
uid: input.nachweis_uid
|
||||
id: input.nachweis_id
|
||||
}
|
||||
})
|
||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||
nachweis = await prisma.bedarfsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
uid: input.nachweis_uid
|
||||
id: input.nachweis_id
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@@ -59,7 +58,7 @@ export const PUT = defineApiRoute({
|
||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||
einpreisung = await prisma.gEGEinpreisung.create({
|
||||
data: {
|
||||
...omit(input, ["nachweis_uid"]),
|
||||
...omit(input, ["nachweis_id"]),
|
||||
status: Enums.Einpreisungsstatus.open,
|
||||
benutzer: {
|
||||
connect: {
|
||||
@@ -68,7 +67,7 @@ export const PUT = defineApiRoute({
|
||||
},
|
||||
geg_nachweis_wohnen: {
|
||||
connect: {
|
||||
uid: input.nachweis_uid
|
||||
id: input.nachweis_id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +75,7 @@ export const PUT = defineApiRoute({
|
||||
} else if (ausweisart === Enums.Ausweisart.GEGNachweisGewerbe) {
|
||||
einpreisung = await prisma.gEGEinpreisung.create({
|
||||
data: {
|
||||
...omit(input, ["nachweis_uid"]),
|
||||
...omit(input, ["nachweis_id"]),
|
||||
status: Enums.Einpreisungsstatus.open,
|
||||
benutzer: {
|
||||
connect: {
|
||||
@@ -85,7 +84,7 @@ export const PUT = defineApiRoute({
|
||||
},
|
||||
geg_nachweis_gewerbe: {
|
||||
connect: {
|
||||
uid: input.nachweis_uid
|
||||
id: input.nachweis_id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +92,7 @@ export const PUT = defineApiRoute({
|
||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||
einpreisung = await prisma.gEGEinpreisung.create({
|
||||
data: {
|
||||
...omit(input, ["nachweis_uid"]),
|
||||
...omit(input, ["nachweis_id"]),
|
||||
status: Enums.Einpreisungsstatus.open,
|
||||
benutzer: {
|
||||
connect: {
|
||||
@@ -102,7 +101,7 @@ export const PUT = defineApiRoute({
|
||||
},
|
||||
bedarfsausweis_gewerbe: {
|
||||
connect: {
|
||||
uid: input.nachweis_uid
|
||||
id: input.nachweis_id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +111,7 @@ export const PUT = defineApiRoute({
|
||||
await sendGEGAnforderungsMail(nachweis, user)
|
||||
|
||||
return {
|
||||
uid: einpreisung.uid
|
||||
id: einpreisung.id
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
return Astro.redirect("/dashboard/objekte/1", 301);
|
||||
---
|
||||
|
||||
---
|
||||
<script></script>
|
||||
Reference in New Issue
Block a user