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