Speichern
This commit is contained in:
@@ -4,7 +4,7 @@ import { exclude } from "#lib/exclude.js";
|
|||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BildClient, 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 "#lib/client/prisma";
|
import { Enums } from "#lib/client/prisma.js";
|
||||||
|
|
||||||
export async function ausweisSpeichern(
|
export async function ausweisSpeichern(
|
||||||
ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient,
|
ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
BenutzerClient,
|
BenutzerClient,
|
||||||
BildClient,
|
BildClient,
|
||||||
ObjektClient,
|
ObjektClient,
|
||||||
RechnungClient,
|
|
||||||
UnterlageClient,
|
UnterlageClient,
|
||||||
VerbrauchsausweisWohnenClient,
|
VerbrauchsausweisWohnenClient,
|
||||||
} from "#components/Ausweis/types.js";
|
} from "#components/Ausweis/types.js";
|
||||||
@@ -160,19 +159,20 @@
|
|||||||
loginOverlayHidden = true
|
loginOverlayHidden = true
|
||||||
|
|
||||||
let result: Awaited<ReturnType<typeof ausweisSpeichern>> | null = null;
|
let result: Awaited<ReturnType<typeof ausweisSpeichern>> | null = null;
|
||||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
|
||||||
result = await nachweisSpeichern(ausweis, objekt, aufnahme, bilder, unterlagen, ausweisart)
|
|
||||||
} else {
|
|
||||||
result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result === null) {
|
try {
|
||||||
addNotification({
|
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||||
dismissable: true,
|
result = await nachweisSpeichern(ausweis, objekt, aufnahme, bilder, unterlagen, ausweisart)
|
||||||
message: "Ups... Das hat nicht geklappt.",
|
} else {
|
||||||
subtext: "Der Nachweis konnte nicht gespeichert werden, bitte versuchen sie es erneut oder kontaktieren sie unseren Support."
|
result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart)
|
||||||
})
|
}
|
||||||
}
|
} catch(e) {
|
||||||
|
addNotification({
|
||||||
|
dismissable: true,
|
||||||
|
message: "Ups... Das hat nicht geklappt.",
|
||||||
|
subtext: "Speichern ist fehlgeschlagen, bitte versuchen sie es erneut oder kontaktieren sie unseren Support."
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { uid } = await api.rechnung.anfordern.PUT.fetch(
|
const { uid } = await api.rechnung.anfordern.PUT.fetch(
|
||||||
@@ -219,10 +219,18 @@
|
|||||||
loginOverlayHidden = true
|
loginOverlayHidden = true
|
||||||
|
|
||||||
let result: Awaited<ReturnType<typeof ausweisSpeichern>> | null = null;
|
let result: Awaited<ReturnType<typeof ausweisSpeichern>> | null = null;
|
||||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.GEGNachweisBedarfsausweis) {
|
try {
|
||||||
result = await nachweisSpeichern(ausweis, objekt, aufnahme, bilder, unterlagen, ausweisart)
|
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||||
} else {
|
result = await nachweisSpeichern(ausweis, objekt, aufnahme, bilder, unterlagen, ausweisart)
|
||||||
result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart)
|
} else {
|
||||||
|
result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart)
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
addNotification({
|
||||||
|
dismissable: true,
|
||||||
|
message: "Ups... Das hat nicht geklappt.",
|
||||||
|
subtext: "Speichern ist fehlgeschlagen, bitte versuchen sie es erneut oder kontaktieren sie unseren Support."
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result !== null) {
|
if (result !== null) {
|
||||||
@@ -232,7 +240,7 @@
|
|||||||
`${location.pathname}?uid=${ausweis.uid}`
|
`${location.pathname}?uid=${ausweis.uid}`
|
||||||
);
|
);
|
||||||
|
|
||||||
localStorage.clear()
|
localStorage.clear();
|
||||||
window.location.href = `/speichern-erfolgreich?uid=${ausweis.uid}`
|
window.location.href = `/speichern-erfolgreich?uid=${ausweis.uid}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { AufnahmeClient, OptionalNullable, UUidWithPrefix, ZodOverlap } from "#components/Ausweis/types.js";
|
import { AufnahmeClient, OptionalNullable, UUidWithPrefix, ZodOverlap } from "#components/Ausweis/types.js";
|
||||||
import { exclude } from "#lib/exclude.js";
|
import { exclude } from "#lib/exclude.js";
|
||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { AufnahmeSchema, prisma } from "#lib/server/prisma";
|
import { AufnahmeSchema, prisma } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@ export const PATCH = defineApiRoute({
|
|||||||
uid: true,
|
uid: true,
|
||||||
benutzer_id: true,
|
benutzer_id: true,
|
||||||
objekt_id: true,
|
objekt_id: true,
|
||||||
|
erstellungsdatum: true
|
||||||
}),
|
}),
|
||||||
output: z.void(),
|
output: z.void(),
|
||||||
middleware: authorizationMiddleware,
|
middleware: authorizationMiddleware,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ObjektClient, OptionalNullable, ZodOverlap } from "#components/Ausweis/types.js";
|
import { ObjektClient, OptionalNullable, ZodOverlap } from "#components/Ausweis/types.js";
|
||||||
import { exclude } from "#lib/exclude.js";
|
import { exclude } from "#lib/exclude.js";
|
||||||
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { ObjektSchema, prisma } from "#lib/server/prisma";
|
import { ObjektSchema, prisma } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -9,7 +9,8 @@ export const PATCH = defineApiRoute({
|
|||||||
input: ObjektSchema.omit({
|
input: ObjektSchema.omit({
|
||||||
uid: true,
|
uid: true,
|
||||||
id: true,
|
id: true,
|
||||||
benutzer_id: true
|
benutzer_id: true,
|
||||||
|
erstellungsdatum: true
|
||||||
}),
|
}),
|
||||||
output: z.void(),
|
output: z.void(),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { OptionalNullable, UUidWithPrefix, VerbrauchsausweisWohnenClient, ZodOverlap } from "#components/Ausweis/types.js";
|
import { OptionalNullable, UUidWithPrefix, VerbrauchsausweisWohnenClient, ZodOverlap } from "#components/Ausweis/types.js";
|
||||||
import { exclude } from "#lib/exclude.js";
|
import { exclude } from "#lib/exclude.js";
|
||||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||||
import { prisma, VerbrauchsausweisWohnenSchema } from "#lib/server/prisma";
|
import { prisma, VerbrauchsausweisWohnenSchema } from "#lib/server/prisma.js";
|
||||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -10,8 +10,10 @@ export const PATCH = defineApiRoute({
|
|||||||
uid: true,
|
uid: true,
|
||||||
id: true,
|
id: true,
|
||||||
benutzer_id: true,
|
benutzer_id: true,
|
||||||
aufnahme_id: true,
|
aufnahme_id: true
|
||||||
}),
|
}).merge(z.object({
|
||||||
|
startdatum: z.coerce.date()
|
||||||
|
})),
|
||||||
output: z.void(),
|
output: z.void(),
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": z.string()
|
"Authorization": z.string()
|
||||||
|
|||||||
Reference in New Issue
Block a user