20
prisma/migrations/20250405131537_mime/migration.sql
Normal file
20
prisma/migrations/20250405131537_mime/migration.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `alte_ausweis_id` on the `BedarfsausweisWohnen` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `alte_ausweis_id` on the `VerbrauchsausweisGewerbe` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `alte_ausweis_id` on the `VerbrauchsausweisWohnen` table. All the data in the column will be lost.
|
||||
- Made the column `mime` on table `Unterlage` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "BedarfsausweisWohnen" DROP COLUMN "alte_ausweis_id";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Unterlage" ALTER COLUMN "mime" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "VerbrauchsausweisGewerbe" DROP COLUMN "alte_ausweis_id";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "VerbrauchsausweisWohnen" DROP COLUMN "alte_ausweis_id";
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
model BedarfsausweisWohnen {
|
||||
id String @id @unique @db.VarChar(8)
|
||||
alte_ausweis_id Int?
|
||||
benutzer_id String?
|
||||
ausstellgrund Ausstellgrund?
|
||||
registriernummer String? @db.VarChar
|
||||
|
||||
@@ -8,7 +8,7 @@ model Unterlage {
|
||||
id String @id @unique @db.VarChar(8)
|
||||
name String?
|
||||
kategorie String?
|
||||
mime String?
|
||||
mime String
|
||||
|
||||
aufnahme_id String?
|
||||
aufnahme Aufnahme? @relation(fields: [aufnahme_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
model VerbrauchsausweisGewerbe {
|
||||
id String @id @unique @db.VarChar(8)
|
||||
alte_ausweis_id Int?
|
||||
ausstellgrund Ausstellgrund?
|
||||
registriernummer String? @db.VarChar
|
||||
zusaetzliche_heizquelle Boolean?
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
model VerbrauchsausweisWohnen {
|
||||
/// @zod.describe("ID des Ausweises")
|
||||
id String @id @unique @db.VarChar(8)
|
||||
alte_ausweis_id Int?
|
||||
/// @zod.describe("Ausstellgrund wie z.B. Vermietung oder Verkauf")
|
||||
ausstellgrund Ausstellgrund?
|
||||
/// @zod.describe("Die Registriernummer des Ausweises")
|
||||
|
||||
@@ -5,6 +5,10 @@ export const createCaller = createCallerFactory({
|
||||
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
|
||||
"postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"),
|
||||
"unterlage": await import("../src/pages/api/unterlage.ts"),
|
||||
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
|
||||
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
|
||||
"auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
|
||||
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
|
||||
"admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"),
|
||||
"admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"),
|
||||
"admin/erinnern": await import("../src/pages/api/admin/erinnern.ts"),
|
||||
@@ -12,13 +16,9 @@ export const createCaller = createCallerFactory({
|
||||
"admin/post-ausstellen": await import("../src/pages/api/admin/post-ausstellen.ts"),
|
||||
"admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"),
|
||||
"admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"),
|
||||
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
|
||||
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
|
||||
"auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
|
||||
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
|
||||
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
|
||||
"bedarfsausweis-gewerbe/[id]": await import("../src/pages/api/bedarfsausweis-gewerbe/[id].ts"),
|
||||
"bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"),
|
||||
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
|
||||
"bedarfsausweis-wohnen/[id]": await import("../src/pages/api/bedarfsausweis-wohnen/[id].ts"),
|
||||
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
|
||||
"bilder/[id]": await import("../src/pages/api/bilder/[id].ts"),
|
||||
|
||||
@@ -3,15 +3,15 @@ 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, BildClient, ObjektClient, UnterlageClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient, } from "#components/Ausweis/types.js";
|
||||
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
|
||||
import { AufnahmeClient, BildClient, ObjektClient, } from "#components/Ausweis/types.js";
|
||||
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage } from "#lib/client/prisma.js";
|
||||
|
||||
export async function nachweisSpeichern(
|
||||
nachweis: BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe,
|
||||
objekt: ObjektClient,
|
||||
aufnahme: AufnahmeClient,
|
||||
bilder: BildClient[],
|
||||
unterlagen: UnterlageClient[],
|
||||
unterlagen: Unterlage[],
|
||||
ausweisart: Enums.Ausweisart
|
||||
) {
|
||||
if (objekt.id) {
|
||||
@@ -213,6 +213,17 @@ export async function nachweisSpeichern(
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
console.log(unterlagen);
|
||||
|
||||
|
||||
await api.aufnahme._id.unterlagen.PUT.fetch(unterlagen.map(unterlage => unterlage.id), {
|
||||
params: {
|
||||
id: aufnahme.id
|
||||
},
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
nachweis_id: nachweis.id,
|
||||
|
||||
@@ -49,7 +49,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
required
|
||||
data-cy="ausstellgrund"
|
||||
>
|
||||
<option disabled selected value={null}>Bitte auswählen</option>
|
||||
<option disabled selected >Bitte auswählen</option>
|
||||
{#each ausstellgrund as name}
|
||||
<option value={name}>{name}</option>
|
||||
{/each}
|
||||
@@ -225,7 +225,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
required
|
||||
bind:value={aufnahme.saniert}
|
||||
>
|
||||
<option disabled selected value={null}>Bitte auswählen</option>
|
||||
<option disabled selected>Bitte auswählen</option>
|
||||
<option value={true}>saniert</option>
|
||||
<option value={false}>unsaniert</option>
|
||||
</select>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { ausweisSpeichern } from "#client/lib/ausweisSpeichern.js";
|
||||
import { validateAccessTokenClient } from "#client/lib/validateAccessToken.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BenutzerClient, GEGNachweisWohnenClient, ObjektClient, UnterlageClient, BildClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, BenutzerClient, ObjektClient, BildClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import Overlay from "#components/Overlay.svelte";
|
||||
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
|
||||
|
||||
import { AusweisTyp, BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen } from "#lib/client/prisma.js";
|
||||
import { AusweisTyp, BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage } from "#lib/client/prisma.js";
|
||||
import { openWindowWithPost } from "#lib/helpers/window.js";
|
||||
import { PRICES } from "#lib/constants.js";
|
||||
import { nachweisSpeichern } from "#client/lib/nachweisSpeichern.js";
|
||||
|
||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient | BedarfsausweisGewerbe | GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||
export let bilder: BildClient[];
|
||||
export let unterlagen: UnterlageClient[] = [];
|
||||
export let unterlagen: Unterlage[] = [];
|
||||
export let user: BenutzerClient | null;
|
||||
export let objekt: ObjektClient;
|
||||
export let aufnahme: AufnahmeClient;
|
||||
@@ -21,13 +21,26 @@
|
||||
export let skala: HTMLDivElement;
|
||||
|
||||
export let showWeiter: boolean = true;
|
||||
export let showHelpButton: boolean = true;
|
||||
|
||||
export let ausweistyp: AusweisTyp = Enums.AusweisTyp.Standard;
|
||||
|
||||
async function ausweisAbschicken() {
|
||||
if (aufnahme.baujahr_gebaeude.length === 0) {
|
||||
(form.querySelector("input[name='baujahr_gebaeude']") as HTMLInputElement).setCustomValidity("Die Eingabe von mindestens einem Baujahr ist verpflichtend.")
|
||||
} else {
|
||||
(form.querySelector("input[name='baujahr_gebaeude']") as HTMLInputElement).setCustomValidity("")
|
||||
}
|
||||
|
||||
if (aufnahme.baujahr_heizung.length === 0) {
|
||||
(form.querySelector("input[name='baujahr_heizung']") as HTMLInputElement).setCustomValidity("Die Eingabe von mindestens einem Baujahr ist verpflichtend.")
|
||||
} else {
|
||||
(form.querySelector("input[name='baujahr_heizung']") as HTMLInputElement).setCustomValidity("")
|
||||
}
|
||||
|
||||
if (!form.checkValidity()) {
|
||||
// Entferne die Klasse "2xl:mt-[370px]" falls vorhanden
|
||||
document.getElementById("formInput-1")?.classList.remove("2xl:mt-[370px]");
|
||||
form.classList.remove("2xl:mt-[370px]");
|
||||
|
||||
// Verhindere das Scrollen (falls erforderlich)
|
||||
skala.classList.add("no-scroll");
|
||||
@@ -38,13 +51,13 @@
|
||||
// Finde das erste ungültige Feld und scrolle sanft darauf
|
||||
let firstInvalidField = form.querySelector(":invalid");
|
||||
if (firstInvalidField) {
|
||||
let offset = 150; // Abstand für bessere Sichtbarkeit
|
||||
let fieldPosition = firstInvalidField.getBoundingClientRect().top + window.scrollY;
|
||||
window.scrollTo({ top: fieldPosition - offset, behavior: "smooth" });
|
||||
let offset = 150; // Abstand für bessere Sichtbarkeit
|
||||
let fieldPosition = firstInvalidField.getBoundingClientRect().top + window.scrollY;
|
||||
window.scrollTo({ top: fieldPosition - offset, behavior: "smooth" });
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||
openWindowWithPost("/kundendaten", {
|
||||
@@ -120,11 +133,13 @@ sm:grid-cols-[1fr_min-content_min-content_min-content] sm:justify-self-end">
|
||||
|
||||
<div></div>
|
||||
|
||||
{#if showHelpButton}
|
||||
<div>
|
||||
<button class="button" type="button" on:click={() => (showHelp = !showHelp)}
|
||||
>Hilfe anfordern</button
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<button class="button" type="button" on:click={spaeterWeitermachen}
|
||||
>Später Weitermachen
|
||||
|
||||
@@ -214,7 +214,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
bind:value={aufnahme.dachgeschoss}
|
||||
required
|
||||
>
|
||||
<option disabled selected value={null}>Bitte auswählen</option>
|
||||
<option disabled selected >Bitte auswählen</option>
|
||||
<option value={Enums.Heizungsstatus.NICHT_VORHANDEN}
|
||||
>nicht vorhanden</option
|
||||
>
|
||||
@@ -243,7 +243,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
required
|
||||
bind:value={aufnahme.keller}
|
||||
>
|
||||
<option disabled selected value={null}>Bitte auswählen</option>
|
||||
<option disabled selected >Bitte auswählen</option>
|
||||
<option value={Enums.Heizungsstatus.NICHT_VORHANDEN}
|
||||
>nicht vorhanden</option
|
||||
>
|
||||
|
||||
@@ -50,7 +50,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
|
||||
required
|
||||
bind:value={aufnahme.lueftung}
|
||||
>
|
||||
<option disabled selected value={null}>Bitte auswählen</option>
|
||||
<option disabled selected >Bitte auswählen</option>
|
||||
<option value="Fensterlueftung">Fensterlüftung</option>
|
||||
<option value="Schachtlueftung">Schachtlüftung</option>
|
||||
<option value="LueftungsanlageOhneWaermerueckgewinnung"
|
||||
|
||||
@@ -138,8 +138,8 @@ export type ObjektKomplettClient = ObjektClient & {
|
||||
}
|
||||
|
||||
export type AufnahmeKomplettClient = AufnahmeClient & {
|
||||
bilder: BildClient[],
|
||||
unterlagen: UnterlageClient[],
|
||||
bilder: Bild[],
|
||||
unterlagen: Unterlage[],
|
||||
bedarfsausweise_wohnen: (BedarfsausweisWohnenClient & { rechnung: RechnungClient })[],
|
||||
verbrauchsausweise_wohnen: (VerbrauchsausweisWohnenClient & { rechnung: RechnungClient })[],
|
||||
verbrauchsausweise_gewerbe: (VerbrauchsausweisGewerbeClient & { rechnung: RechnungClient })[],
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
const ausweisart = getAusweisartFromId(ausweis.id);
|
||||
|
||||
const id = ausweis.alte_ausweis_id || ausweis.id;
|
||||
const id = ausweis.id;
|
||||
|
||||
async function ausweisStornieren() {
|
||||
const result = await dialogs.confirm({
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
export let lightTheme: boolean;
|
||||
export let benutzer: BenutzerClient;
|
||||
export let objekte: ObjektKomplettClient[];
|
||||
|
||||
const rippleOptions: RippleOptions = {
|
||||
center: false,
|
||||
@@ -168,10 +167,6 @@
|
||||
@apply flex flex-row gap-4 py-2.5 px-4 cursor-pointer items-center;
|
||||
}
|
||||
|
||||
.button-tab:focus {
|
||||
@apply shadow-none;
|
||||
}
|
||||
|
||||
summary.button-tab::after {
|
||||
@apply ml-auto;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import mime from "mime"
|
||||
import { api } from "astro-typesafe-api/client";
|
||||
import { BedarfsausweisGewerbe, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage } from "#lib/client/prisma.js";
|
||||
import { addNotification } from "./Notifications/shared.js";
|
||||
|
||||
|
||||
function getAllFiles(this: HTMLInputElement) {
|
||||
@@ -43,6 +44,17 @@
|
||||
|
||||
const mimeType = mime.getType(file.name.split(".").pop() as string)
|
||||
|
||||
if (!mimeType) {
|
||||
addNotification({
|
||||
message: "Das hat nicht geklappt.",
|
||||
subtext: "Wir sind uns nicht sicher was für eine Datei sie hochladen wollen, hat die Datei eine Dateiendung? (z.B. '.pdf' oder '.png')",
|
||||
dismissable: true,
|
||||
timeout: 5000
|
||||
})
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { id } = await api.unterlage.PUT.fetch({
|
||||
data: reader.result as string,
|
||||
kategorie,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Ausstellgrund, AusweisTyp } from "@prisma/client"
|
||||
|
||||
export const BedarfsausweisWohnenSchema = z.object({
|
||||
id: z.string(),
|
||||
alte_ausweis_id: z.number().int().nullish(),
|
||||
benutzer_id: z.string().nullish(),
|
||||
ausstellgrund: z.nativeEnum(Ausstellgrund).nullish(),
|
||||
registriernummer: z.string().nullish(),
|
||||
|
||||
@@ -4,6 +4,6 @@ export const UnterlageSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string().nullish(),
|
||||
kategorie: z.string().nullish(),
|
||||
mime: z.string().nullish(),
|
||||
mime: z.string(),
|
||||
aufnahme_id: z.string().nullish(),
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Ausstellgrund, AusweisTyp } from "@prisma/client"
|
||||
|
||||
export const VerbrauchsausweisGewerbeSchema = z.object({
|
||||
id: z.string(),
|
||||
alte_ausweis_id: z.number().int().nullish(),
|
||||
ausstellgrund: z.nativeEnum(Ausstellgrund).nullish(),
|
||||
registriernummer: z.string().nullish(),
|
||||
zusaetzliche_heizquelle: z.boolean().nullish(),
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Ausstellgrund, AusweisTyp } from "@prisma/client"
|
||||
|
||||
export const VerbrauchsausweisWohnenSchema = z.object({
|
||||
id: z.string().describe("ID des Ausweises"),
|
||||
alte_ausweis_id: z.number().int().nullish(),
|
||||
ausstellgrund: z.nativeEnum(Ausstellgrund).describe("Ausstellgrund wie z.B. Vermietung oder Verkauf").nullish(),
|
||||
registriernummer: z.string().describe("Die Registriernummer des Ausweises").nullish(),
|
||||
zusaetzliche_heizquelle: z.boolean().describe("Falls eine sekundäre Heizquelle existiert, sollte dieser Wert auf true stehen").nullish(),
|
||||
|
||||
@@ -5,7 +5,6 @@ import "../../svelte-dialogs.config.js";
|
||||
import DashboardSidebar from "../components/Dashboard/DashboardSidebar.svelte";
|
||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
|
||||
import { BenutzerClient, ObjektClient } from "#components/Ausweis/types";
|
||||
import { prisma } from "#lib/server/prisma";
|
||||
|
||||
const valid = validateAccessTokenServer(Astro)
|
||||
|
||||
@@ -20,29 +19,6 @@ export interface Props {
|
||||
|
||||
const { title, user } = Astro.props;
|
||||
|
||||
const objekte = await prisma.objekt.findMany({
|
||||
where: {
|
||||
benutzer: {
|
||||
id: user.id
|
||||
}
|
||||
},
|
||||
take: 10,
|
||||
orderBy: {
|
||||
erstellungsdatum: "desc"
|
||||
},
|
||||
include: {
|
||||
aufnahmen: {
|
||||
include: {
|
||||
bilder: true,
|
||||
unterlagen: true,
|
||||
bedarfsausweise_wohnen: true,
|
||||
verbrauchsausweise_gewerbe: true,
|
||||
verbrauchsausweise_wohnen: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const schema = JSON.stringify({
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Corporation",
|
||||
@@ -147,7 +123,7 @@ let lightTheme = Astro.cookies.get("theme")?.value === "light";
|
||||
2xl:grid-cols-[minmax(150px,300px)1fr] 2xl:gap-5 2xl:p-6"
|
||||
>
|
||||
|
||||
<DashboardSidebar lightTheme={lightTheme} benutzer={user} {objekte} client:load>
|
||||
<DashboardSidebar lightTheme={lightTheme} benutzer={user} client:load>
|
||||
</DashboardSidebar>
|
||||
|
||||
<article class="box rounded-tl-none
|
||||
|
||||
@@ -4,12 +4,10 @@ import { getEmpfehlungen } from "#lib/XML/getEmpfehlungen.js";
|
||||
import { Enums } from "#lib/server/prisma.js";
|
||||
import * as fs from "fs"
|
||||
import moment from "moment";
|
||||
import { PDFDocument, PDFFont, PDFImage, PDFPage, StandardFonts, TextAlignment } from "pdf-lib";
|
||||
import { PDFDocument, PDFFont, PDFImage, PDFPage, StandardFonts } from "pdf-lib";
|
||||
import { addCheckMark } from "./utils/checkbox.js";
|
||||
import { addText } from "./utils/text.js";
|
||||
import { addAnsichtsausweisLabel, addDatumGEG } from "./utils/helpers.js";
|
||||
import { fileURLToPath } from "url";
|
||||
import { PERSISTENT_DIR } from "#lib/server/constants.js";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
|
||||
/* -------------------------------- Pdf Tools ------------------------------- */
|
||||
@@ -106,7 +104,7 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
|
||||
|
||||
pages[0].drawText(erneuerbareEnergienVerwendung.join(", "), {
|
||||
x: 358,
|
||||
y: height - 325,
|
||||
y: height - 338,
|
||||
size: 8
|
||||
})
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import DashboardNachweis from "#components/Dashboard/DashboardNachweis.svelte";
|
||||
import NotificationProvider from "#components/NotificationProvider/NotificationProvider.svelte";
|
||||
import { Objekt } from "#lib/client/prisma.js";
|
||||
import { ChevronLeft, ChevronRight } from "radix-svelte-icons";
|
||||
import mime from "mime"
|
||||
import { ChevronLeft, ChevronRight, FileText } from "radix-svelte-icons";
|
||||
|
||||
export let user: BenutzerClient;
|
||||
export let aufnahme: AufnahmeKomplettClient;
|
||||
@@ -32,9 +33,9 @@
|
||||
{#if dropdownOpen}
|
||||
<div class="absolut mt-2 w-56 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5" on:click|stopPropagation on:keydown|stopPropagation on:keyup|stopPropagation>
|
||||
<div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">
|
||||
<a href="/energieausweis-erstellen/verbrauchsausweis-wohngebaeude?aufnahme={aufnahme.uid}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 w-full text-left" role="menuitem">Verbrauchsausweis Wohnen Erstellen</a>
|
||||
<a href="/energieausweis-erstellen/verbrauchsausweis-gewerbe?aufnahme={aufnahme.uid}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 w-full text-left" role="menuitem">Verbrauchsausweis Gewerbe Erstellen</a>
|
||||
<a href="/energieausweis-erstellen/bedarfsausweis-wohngebaeude?aufnahme={aufnahme.uid}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 w-full text-left" role="menuitem">Bedarfsausweis Erstellen</a>
|
||||
<a href="/energieausweis-erstellen/verbrauchsausweis-wohngebaeude?aufnahme={aufnahme.id}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 w-full text-left" role="menuitem">Verbrauchsausweis Wohnen Erstellen</a>
|
||||
<a href="/energieausweis-erstellen/verbrauchsausweis-gewerbe?aufnahme={aufnahme.id}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 w-full text-left" role="menuitem">Verbrauchsausweis Gewerbe Erstellen</a>
|
||||
<a href="/energieausweis-erstellen/bedarfsausweis-wohngebaeude?aufnahme={aufnahme.id}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 w-full text-left" role="menuitem">Bedarfsausweis Erstellen</a>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -44,15 +45,24 @@
|
||||
|
||||
<div class="relative bg-gray-100 rounded-md flex justify-center items-center">
|
||||
{#if aufnahme.bilder.length > 0}
|
||||
<h3 class="font-semibold">Bilder</h3>
|
||||
<Carousel perPage={3}>
|
||||
{#each aufnahme.bilder as bild, i (i)}
|
||||
<img src="/bilder/{bild.uid}.jpg" alt={bild.kategorie} class="max-h-[25vh] h-full w-full object-contain">
|
||||
<img src="/bilder/{bild.id}.jpg" alt={bild.kategorie} class="max-h-[25vh] h-full w-full object-contain">
|
||||
{/each}
|
||||
<span slot="left-control" class="p-2.5 bg-opacity-50 bg-white block rounded-full"><ChevronLeft size={24}></ChevronLeft></span>
|
||||
<span slot="right-control" class="p-2.5 bg-opacity-50 bg-white block rounded-full"><ChevronRight size={24}></ChevronRight></span>
|
||||
</Carousel>
|
||||
{/if}
|
||||
</div>
|
||||
{#if aufnahme.unterlagen.length > 0}
|
||||
<h3 class="font-semibold">Unterlagen</h3>
|
||||
<div class="grid grid-flow-col gap-4">
|
||||
{#each aufnahme.unterlagen as unterlage}
|
||||
<a href="/unterlagen/{unterlage.id}.{mime.getExtension(unterlage.mime)}" target="_blank" class="text-black flex flex-row items-center gap-2 bg-base-200 p-2 rounded-lg"><FileText size={32}></FileText> {unterlage.name}</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import PerformanceScore from "#components/Ausweis/PerformanceScore.svelte";
|
||||
import Progressbar from "#components/Ausweis/Progressbar.svelte";
|
||||
import Bereich from "#components/labels/Bereich.svelte";
|
||||
import type { Bezahlmethoden } from "#lib/client/prisma.js";
|
||||
import type { Bezahlmethoden, Unterlage } from "#lib/client/prisma.js";
|
||||
import { Enums } from "#lib/client/prisma.js";
|
||||
import {
|
||||
API_ACCESS_TOKEN_COOKIE_NAME,
|
||||
@@ -36,7 +36,7 @@
|
||||
export let aufnahme: AufnahmeClient;
|
||||
export let objekt: ObjektClient;
|
||||
export let bilder: BildClient[];
|
||||
export let unterlagen: UnterlageClient[];
|
||||
export let unterlagen: Unterlage[];
|
||||
export let rechnung: RechnungClient | null = null;
|
||||
export let ausweisart: Enums.Ausweisart;
|
||||
export let aktiveBezahlmethode: Bezahlmethoden = Enums.Bezahlmethoden.paypal;
|
||||
@@ -134,20 +134,24 @@
|
||||
);
|
||||
|
||||
const zurueck = {
|
||||
[Enums.Ausweisart.VerbrauchsausweisWohnen]:
|
||||
`/energieausweis-erstellen/verbrauchsausweis-wohngebaeude?uid=${ausweis.id}`,
|
||||
[Enums.Ausweisart.VerbrauchsausweisGewerbe]:
|
||||
`/energieausweis-erstellen/verbrauchsausweis-gewerbe?uid=${ausweis.id}`,
|
||||
[Enums.Ausweisart.BedarfsausweisWohnen]:
|
||||
`/energieausweis-erstellen/bedarfsausweis-wohnen?uid=${ausweis.id}`,
|
||||
[Enums.Ausweisart.GEGNachweisWohnen]:
|
||||
`/angebot-anfragen/geg-nachweis-wohnen-anfragen?uid=${ausweis.id}`,
|
||||
[Enums.Ausweisart.GEGNachweisGewerbe]:
|
||||
`/angebot-anfragen/geg-nachweis-gewerbe-anfragen?uid=${ausweis.id}`,
|
||||
[Enums.Ausweisart.BedarfsausweisGewerbe]:
|
||||
`/angebot-anfragen/bedarfsausweis-gewerbe-anfragen?uid=${ausweis.id}`,
|
||||
[Enums.Ausweisart.VerbrauchsausweisWohnen]:
|
||||
new URL("/energieausweis-erstellen/verbrauchsausweis-wohngebaeude", window.location.origin),
|
||||
[Enums.Ausweisart.VerbrauchsausweisGewerbe]:
|
||||
new URL("/energieausweis-erstellen/verbrauchsausweis-gewerbe", window.location.origin),
|
||||
[Enums.Ausweisart.BedarfsausweisWohnen]:
|
||||
new URL("/energieausweis-erstellen/bedarfsausweis-wohnen", window.location.origin),
|
||||
[Enums.Ausweisart.GEGNachweisWohnen]:
|
||||
new URL("/angebot-anfragen/geg-nachweis-wohnen-anfragen", window.location.origin),
|
||||
[Enums.Ausweisart.GEGNachweisGewerbe]:
|
||||
new URL("/angebot-anfragen/geg-nachweis-gewerbe-anfragen", window.location.origin),
|
||||
[Enums.Ausweisart.BedarfsausweisGewerbe]:
|
||||
new URL("/angebot-anfragen/bedarfsausweis-gewerbe-anfragen", window.location.origin),
|
||||
}[ausweisart];
|
||||
|
||||
if (ausweis.id) {
|
||||
zurueck.searchParams.append("id", ausweis.id)
|
||||
}
|
||||
|
||||
async function anfordern() {
|
||||
if (!form.checkValidity()) {
|
||||
addNotification({
|
||||
@@ -182,7 +186,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const { uid } = await api.rechnung.anfordern.PUT.fetch(
|
||||
const { id } = await api.rechnung.anfordern.PUT.fetch(
|
||||
{
|
||||
email: email,
|
||||
empfaenger: empfaenger,
|
||||
@@ -206,7 +210,7 @@
|
||||
// Alle alten Ausweisdateien im localStorage löschen.
|
||||
localStorage.clear();
|
||||
|
||||
window.location.href = `/einpreisung/success?e=${uid}&a=${result.nachweis_id}`;
|
||||
window.location.href = `/einpreisung/success?e=${id}&a=${result.nachweis_id}`;
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
dismissable: true,
|
||||
@@ -436,7 +440,7 @@
|
||||
active={1}
|
||||
steps={["Gebäudedaten", "Kundendaten", "Bestätigung"]}
|
||||
{ausweisart}
|
||||
ausweistyp={ausweis.ausweistyp}
|
||||
ausweistyp={"ausweistyp" in ausweis ? ausweis.ausweistyp : ausweis.nachweistyp}
|
||||
anliegen={"Angebot anfragen"}
|
||||
/>
|
||||
{:else}
|
||||
@@ -1026,7 +1030,7 @@ grid-cols-3 sm:grid-cols-5 justify-around justify-items-center items-center"
|
||||
class="grid grid-cols-1 gap-x-2 gap-y-1 self-start mt-0
|
||||
sm:grid-cols-[min-content_min-content_min-content] sm:justify-self-end sm:mt-8"
|
||||
>
|
||||
<a class="order-3 sm:order-1 button cursor-pointer text-center sm:text-start" href={zurueck}>Zurück</a>
|
||||
<a class="order-3 sm:order-1 button cursor-pointer text-center sm:text-start" href={zurueck.toString()}>Zurück</a>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
// Falls die Daten im localStorage neuer sind als der Ausweis den wir von der Datenbank bekommen haben, benutzen wir lieber diese.
|
||||
// Wir schauen auch ob der Benutzer nicht vielleicht ein Admin ist, dann sollten wir nichts aus dem localStorage holen.
|
||||
if ((user && user.rolle !== Enums.BenutzerRolle.ADMIN) && !id && (!ausweis.updated_at || moment(localStorage.getItem("verbrauchsausweis-wohnen.updated_at") || new Date()).isAfter(ausweis.updated_at))) {
|
||||
if (((user && user.rolle !== Enums.BenutzerRolle.ADMIN) || !user) && !id && (!ausweis.updated_at || moment(localStorage.getItem("verbrauchsausweis-wohnen.updated_at") || new Date()).isAfter(ausweis.updated_at))) {
|
||||
const localStorageAusweis = localStorage.getItem("verbrauchsausweis-wohnen.ausweis");
|
||||
if (localStorageAusweis) {
|
||||
ausweis = JSON.parse(localStorageAusweis)
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
bind:user
|
||||
bind:objekt
|
||||
bind:aufnahme
|
||||
showHelpButton={false}
|
||||
ausweisart={Enums.Ausweisart.BedarfsausweisGewerbe}
|
||||
{form}
|
||||
{skala}
|
||||
|
||||
@@ -231,6 +231,7 @@
|
||||
bind:user
|
||||
bind:objekt
|
||||
bind:aufnahme
|
||||
showHelpButton={false}
|
||||
ausweisart={Enums.Ausweisart.GEGNachweisGewerbe}
|
||||
{form}
|
||||
{skala}
|
||||
|
||||
@@ -147,35 +147,6 @@
|
||||
</Bereich>
|
||||
|
||||
<Bereich bereich="D" title="Gebäudepläne & Unterlagen">
|
||||
<div
|
||||
class="bereich-box grid grid-cols-1 lg:grid-cols-2 gap-x-6 mt-6"
|
||||
>
|
||||
<div class="md:box md:card mb-0">
|
||||
<div class="font-bold mb-2">Pläne</div>
|
||||
|
||||
<div>
|
||||
Hier können sie Grundrisspläne, Ansichtspläne und
|
||||
Schnitte hochladen. Die Dateien können entweder im PDF
|
||||
Format oder als Bild hochgeladen werden.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="md:box md:card mb-0 mt-6 md:mt-0">
|
||||
<div>
|
||||
<strong
|
||||
>Bitte laden Sie hier mind. 1 Dokument hoch:</strong
|
||||
>
|
||||
</div>
|
||||
<FileGrid
|
||||
max={Infinity}
|
||||
min={1}
|
||||
name={"plaene"}
|
||||
bind:files={plaene}
|
||||
bind:ausweis={nachweis}
|
||||
bind:objekt
|
||||
></FileGrid>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="bereich-box grid grid-cols-1 lg:grid-cols-2 gap-x-6 mt-6"
|
||||
>
|
||||
@@ -189,6 +160,14 @@
|
||||
können entweder im PDF Format oder als Bild hochgeladen
|
||||
werden.
|
||||
</div>
|
||||
|
||||
<div class="font-bold mb-2">Pläne</div>
|
||||
|
||||
<div>
|
||||
Hier können sie Grundrisspläne, Ansichtspläne und
|
||||
Schnitte hochladen. Die Dateien können entweder im PDF
|
||||
Format oder als Bild hochgeladen werden.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="md:box md:card mb-0 mt-6 md:mt-0">
|
||||
@@ -212,6 +191,7 @@
|
||||
bind:user
|
||||
bind:objekt
|
||||
bind:aufnahme
|
||||
showHelpButton={false}
|
||||
ausweisart={Enums.Ausweisart.GEGNachweisWohnen}
|
||||
{form}
|
||||
{skala}
|
||||
|
||||
@@ -17,6 +17,9 @@ export const PUT = defineApiRoute({
|
||||
}).merge(z.object({
|
||||
nachweis_id: UUidWithPrefix
|
||||
})),
|
||||
output: z.object({
|
||||
id: UUidWithPrefix
|
||||
}),
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
|
||||
@@ -2,13 +2,13 @@ import { authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
import { z } from "zod";
|
||||
import { fileURLToPath } from "url";
|
||||
import { writeFileSync } from "fs";
|
||||
import { PERSISTENT_DIR } from "#lib/server/constants.js";
|
||||
import { UnterlageSchema } from "src/generated/zod/unterlage.js";
|
||||
import { generatePrefixedId } from "#lib/db.js";
|
||||
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { PutObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { s3Client } from "#lib/s3.js";
|
||||
import mime from "mime"
|
||||
|
||||
export const PUT = defineApiRoute({
|
||||
input: UnterlageSchema.omit({
|
||||
@@ -20,31 +20,37 @@ export const PUT = defineApiRoute({
|
||||
output: z.object({
|
||||
id: UUidWithPrefix
|
||||
}),
|
||||
async fetch({ data, name, kategorie, mime }, ctx, user) {
|
||||
if (mime !== "application/pdf" && mime !== "image/png" && mime !== "image/jpeg") {
|
||||
async fetch({ data, name, kategorie, mime: mimeType }, ctx, user) {
|
||||
const extension = mime.getExtension(mimeType);
|
||||
if (!extension) {
|
||||
throw new APIError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Nicht unterstützter mimetype, unterstützt werden 'image/jpeg', 'image/png', 'application/pdf'."
|
||||
message: "Mime Type wird nicht unterstützt."
|
||||
})
|
||||
}
|
||||
|
||||
const buffer = Buffer.from(data, "base64");
|
||||
|
||||
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.Unterlage)
|
||||
|
||||
await prisma.unterlage.create({
|
||||
data: {
|
||||
id,
|
||||
kategorie: kategorie,
|
||||
mime,
|
||||
mime: mimeType,
|
||||
name
|
||||
}
|
||||
});
|
||||
|
||||
const filePath = fileURLToPath(new URL(`${PERSISTENT_DIR}/unterlagen/${id}`, import.meta.url));
|
||||
const buffer = Buffer.from(data, "base64");
|
||||
|
||||
try {
|
||||
writeFileSync(filePath, buffer)
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: "ibc-unterlagen",
|
||||
Key: `${id}.${extension}`,
|
||||
Body: buffer,
|
||||
ACL: "private"
|
||||
})
|
||||
|
||||
const response = await s3Client.send(command)
|
||||
} catch(e) {
|
||||
// Unterlage wurde nicht gespeichert, wir löschen den Eintrag wieder
|
||||
await prisma.unterlage.delete({
|
||||
|
||||
@@ -33,7 +33,7 @@ const objekte = await prisma.objekt.findFirst({
|
||||
every: {
|
||||
verbrauchsausweise_gewerbe: {
|
||||
some: {
|
||||
alte_ausweis_id: parseInt(id)
|
||||
id
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -44,7 +44,7 @@ const objekte = await prisma.objekt.findFirst({
|
||||
every: {
|
||||
verbrauchsausweise_wohnen: {
|
||||
some: {
|
||||
alte_ausweis_id: parseInt(id)
|
||||
id
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -55,40 +55,7 @@ const objekte = await prisma.objekt.findFirst({
|
||||
every: {
|
||||
bedarfsausweise_wohnen: {
|
||||
some: {
|
||||
alte_ausweis_id: parseInt(id)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
aufnahmen: {
|
||||
every: {
|
||||
verbrauchsausweise_gewerbe: {
|
||||
some: {
|
||||
id: `VG${id}`
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
aufnahmen: {
|
||||
every: {
|
||||
verbrauchsausweise_wohnen: {
|
||||
some: {
|
||||
id: `VW${id}`
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
aufnahmen: {
|
||||
every: {
|
||||
bedarfsausweise_wohnen: {
|
||||
some: {
|
||||
id: `BW${id}`
|
||||
id
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ const objekte = await prisma.objekt.findMany({
|
||||
every: {
|
||||
verbrauchsausweise_gewerbe: {
|
||||
some: {
|
||||
alte_ausweis_id: parseInt(id)
|
||||
id
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -54,7 +54,7 @@ const objekte = await prisma.objekt.findMany({
|
||||
every: {
|
||||
verbrauchsausweise_wohnen: {
|
||||
some: {
|
||||
alte_ausweis_id: parseInt(id)
|
||||
id
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -65,46 +65,7 @@ const objekte = await prisma.objekt.findMany({
|
||||
every: {
|
||||
bedarfsausweise_wohnen: {
|
||||
some: {
|
||||
alte_ausweis_id: parseInt(id)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
aufnahmen: {
|
||||
every: {
|
||||
verbrauchsausweise_gewerbe: {
|
||||
some: {
|
||||
uid: {
|
||||
startsWith: `vag-${id}`
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
aufnahmen: {
|
||||
every: {
|
||||
verbrauchsausweise_wohnen: {
|
||||
some: {
|
||||
uid: {
|
||||
startsWith: `vaw-${id}`
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
aufnahmen: {
|
||||
every: {
|
||||
bedarfsausweise_wohnen: {
|
||||
some: {
|
||||
uid: {
|
||||
startsWith: `baw-${id}`
|
||||
}
|
||||
id
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@ if (!params.has("ausweis") || !params.has("aufnahme") || !params.has("objekt") |
|
||||
return Astro.redirect("/404")
|
||||
}
|
||||
|
||||
let ausweis, aufnahme, objekt, ausweisart, bilder;
|
||||
let ausweis, aufnahme, objekt, ausweisart, bilder, unterlagen;
|
||||
try {
|
||||
ausweis = JSON.parse(params.get("ausweis") || "")
|
||||
aufnahme = JSON.parse(params.get("aufnahme") || "")
|
||||
objekt = JSON.parse(params.get("objekt") || "")
|
||||
ausweisart = JSON.parse(params.get("ausweisart") || "") as Enums.Ausweisart;
|
||||
bilder = JSON.parse(params.get("bilder") || "");
|
||||
|
||||
unterlagen = JSON.parse(params.get("unterlagen") || "[]")
|
||||
|
||||
if (!ausweisart || !Object.keys(Enums.Ausweisart).includes(ausweisart)) {
|
||||
throw new Error()
|
||||
}
|
||||
@@ -34,6 +35,6 @@ try {
|
||||
---
|
||||
|
||||
<AusweisLayout title="Kundendaten Aufnehmen - IBCornelsen">
|
||||
<KundendatenModule {user} {ausweis} {objekt} {aufnahme} {bilder} {ausweisart} unterlagen={[]} aktiveBezahlmethode={Enums.Bezahlmethoden.paypal} client:only="svelte" ></KundendatenModule>
|
||||
<KundendatenModule {user} {ausweis} {objekt} {aufnahme} {bilder} {ausweisart} {unterlagen} aktiveBezahlmethode={Enums.Bezahlmethoden.paypal} client:only ></KundendatenModule>
|
||||
</AusweisLayout>
|
||||
|
||||
|
||||
@@ -8,24 +8,24 @@ import { getPrismaAusweisAdapter } from "#lib/server/ausweis";
|
||||
import { sendInvoiceMail } from "#lib/server/mail/invoice";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
|
||||
const uidRechnung = Astro.url.searchParams.get("r");
|
||||
const uidAusweis = Astro.url.searchParams.get("a");
|
||||
const idRechnung = Astro.url.searchParams.get("r");
|
||||
const idAusweis = Astro.url.searchParams.get("a");
|
||||
const user = await getCurrentUser(Astro)
|
||||
|
||||
if (!uidRechnung || !uidAusweis || !user) {
|
||||
if (!idRechnung || !idAusweis || !user) {
|
||||
return Astro.redirect("/")
|
||||
}
|
||||
|
||||
const rechnung = await prisma.rechnung.findUnique({
|
||||
where: {
|
||||
uid: uidRechnung,
|
||||
id: idRechnung,
|
||||
benutzer: {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const adapter = getPrismaAusweisAdapter(uidAusweis);
|
||||
const adapter = getPrismaAusweisAdapter(idAusweis);
|
||||
|
||||
if (!adapter) {
|
||||
return Astro.redirect("/")
|
||||
@@ -33,7 +33,7 @@ if (!adapter) {
|
||||
|
||||
const ausweis = await adapter.findUnique({
|
||||
where: {
|
||||
uid: uidAusweis
|
||||
id: idAusweis
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
31
src/pages/unterlagen/[id].[extension].ts
Normal file
31
src/pages/unterlagen/[id].[extension].ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { prisma } from "#lib/server/prisma.js";
|
||||
import { APIRoute } from "astro";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
import mime from "mime"
|
||||
|
||||
export const GET: APIRoute = async (Astro) => {
|
||||
const { id } = Astro.params;
|
||||
|
||||
const unterlage = await prisma.unterlage.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!unterlage) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
});
|
||||
}
|
||||
|
||||
const extension = mime.getExtension(unterlage.mime)
|
||||
|
||||
const file = await getS3File("ibc-unterlagen", `${unterlage.id}.${extension}`);
|
||||
|
||||
if (!file) {
|
||||
return new Response(null, { status: 404 })
|
||||
}
|
||||
|
||||
return new Response(file, { status: 200 })
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user