Fehler von Jens gefixt

This commit is contained in:
Moritz Utcke
2025-02-12 12:28:17 +07:00
parent 23c95dab63
commit fe3b2809d9
10 changed files with 107 additions and 86 deletions

View File

@@ -5,11 +5,11 @@ export const createCaller = createCallerFactory({
"postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"),
"aufnahme/[uid]": await import("../src/pages/api/aufnahme/[uid].ts"),
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
"auth/forgot-password": await import("../src/pages/api/auth/forgot-password.ts"),
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
"bilder/[uid]": await import("../src/pages/api/bilder/[uid].ts"),
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
"objekt": await import("../src/pages/api/objekt/index.ts"),
"rechnung": await import("../src/pages/api/rechnung/index.ts"),
"ticket": await import("../src/pages/api/ticket/index.ts"),

View File

@@ -1,15 +1,11 @@
<script lang="ts">
import AusweisWeiter from "#modules/VerbrauchsausweisWohnen/AusweisWeiter.svelte";
import Hilfe from "#components/Ausweis/Hilfe.svelte";
import {
AufnahmeClient,
BedarfsausweisWohnenClient,
BenutzerClient,
ObjektClient,
UploadedGebaeudeBild,
VerbrauchsausweisGewerbeClient,
VerbrauchsausweisWohnenClient,
} from "./types.js";
import { ausweisSpeichern } from "#client/lib/ausweisSpeichern.js";
import { validateAccessTokenClient } from "#client/lib/validateAccessToken.js";
import { AufnahmeClient, BedarfsausweisWohnenClient, BenutzerClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import Overlay from "#components/Overlay.svelte";
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
import { Enums } from "@ibcornelsen/database/client";
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient;
@@ -19,7 +15,46 @@
export let aufnahme: AufnahmeClient;
export let ausweisart: Enums.Ausweisart
export let spaeterWeitermachen;
async function ausweisAbschicken() {
if (!await validateAccessTokenClient()) {
loginOverlayHidden = false;
return
}
loginOverlayHidden = true
const result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart);
if (result !== null) {
window.history.pushState(
{},
"",
`${location.pathname}?uid=${ausweis.uid}`
);
window.location.href = `/kundendaten?uid=${ausweis.uid}`;
}
}
async function spaeterWeitermachen() {
if (!await validateAccessTokenClient()) {
loginOverlayHidden = false;
return
}
loginOverlayHidden = true
const result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart);
if (result !== null) {
window.history.pushState(
{},
"",
`${location.pathname}?uid=${ausweis.uid}`
);
}
}
let loginOverlayHidden = true;
</script>
<div
@@ -33,14 +68,13 @@
>Später Weitermachen
</button>
<div class="">
<AusweisWeiter
bind:ausweis
bind:bilder
bind:user
bind:objekt
bind:aufnahme
{ausweisart}
></AusweisWeiter>
<div>
<Overlay bind:hidden={loginOverlayHidden}>
<div class="bg-white w-full max-w-screen-sm py-8">
<EmbeddedAuthFlowModule onLogin={ausweisAbschicken}></EmbeddedAuthFlowModule>
</div>
</Overlay>
<button on:click={ausweisAbschicken} type="button" class="button" data-cy="weiter">Weiter</button>
</div>
</div>

View File

@@ -45,7 +45,7 @@
</script>
<div class="" use:clickOutside={() => {
<div use:clickOutside={() => {
hideZipDropdown = true;
}}>
@@ -65,13 +65,19 @@
maxlength="5"
/>
<div data-test="plz-container" class="absolute top-[calc(100%+4px)] left-0 w-full bg-white py-2 shadow-md rounded-lg z-50" hidden={hideZipDropdown}>
<div data-test="plz-container" class="absolute top-[calc(100%+4px)] flex flex-col left-0 bg-white py-1 shadow-md rounded-lg z-10" class:hidden={hideZipDropdown}>
{#each zipCodes as zipCode}
<div class="hover:bg-gray-100 cursor-pointer px-2 py-0.5 text-nowrap" tabindex="-1" on:click={() => {
<button class="hover:bg-gray-100 cursor-pointer px-2 py-1 text-nowrap" tabindex="-1" on:click={() => {
zip = zipCode.plz;
city = zipCode.stadt;
hideZipDropdown = true;
}}>{zipCode.plz}, {zipCode.stadt}</div>
}}>{zipCode.plz}, {zipCode.stadt}</button>
{/each}
</div>
</div>
</div>
<style>
button:not(:last-of-type) {
@apply border-b border-b-gray-200;
}
</style>

View File

@@ -6,6 +6,7 @@ import "svelte-ripple-action/ripple.css"
import DashboardSidebar from "../components/Dashboard/DashboardSidebar.svelte"
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
import { createCaller } from "src/astro-typesafe-api-caller";
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
const valid = validateAccessTokenServer(Astro)
@@ -16,7 +17,11 @@ if (!valid) {
const caller = createCaller(Astro)
const benutzer = await caller.v1.benutzer.self()
const benutzer = await caller.user.self.GET.fetch(null, {
headers: {
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
}
})
export interface Props {
title: string;

View File

@@ -4,7 +4,7 @@ import { getEmpfehlungen } from "#lib/XML/getEmpfehlungen.js";
import { Enums } from "@ibcornelsen/database/server";
import * as fs from "fs"
import moment from "moment";
import { PDFDocument, PDFFont, PDFName, PDFNumber, PDFPage, StandardFonts, TextAlignment } from "pdf-lib";
import { PDFDocument, PDFFont, PDFName, PDFNumber, PDFPage, RotationTypes, StandardFonts, TextAlignment } from "pdf-lib";
/* -------------------------------- Pdf Tools ------------------------------- */
@@ -82,7 +82,6 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
/* -------------------------------- Seite 2 -------------------------------- */
const co2Emissionen = fillFormField("co2emissionen", berechnungen?.co2EmissionenGesamt.toString(), 8, TextAlignment.Center)
const addEnergieverbrauchSkalaPfeile = async (page: PDFPage) => {
const pfeilNachUnten = await pdf.embedPng(fs.readFileSync(new URL("../../../public/images/pfeil-nach-unten.png", import.meta.url), "base64"))
@@ -172,11 +171,7 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
}
}
addEnergieverbrauchSkalaPfeile(pages[1])
addEnergieverbrauchSkalaPfeile(pages[2])
const primaerenergiebedarfIst = fillFormField("primaerenergiebedarf_ist", berechnungen?.primaerEnergieVerbrauchGesamt.toString())
addEnergieverbrauchSkalaPfeile(pages[2])
/* -------------------------------- Seite 3 -------------------------------- */
@@ -369,6 +364,22 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
}
function addAnsichtsausweisLabel(page: PDFPage, font: PDFFont) {
page.drawText("Ansichtsausweis", {
x: page.getWidth() / 2 - font.heightAtSize(112) * 2.2, y: page.getHeight() - font.heightAtSize(112) / 2,
size: 112,
font,
rotate: {
type: RotationTypes.Degrees,
angle: -60
},
opacity: 0.3
})
}
for (const page of pages) {
addAnsichtsausweisLabel(page, font)
}
// pdf.getForm().flatten()

View File

@@ -3,6 +3,9 @@
export let user: BenutzerClient;
export let objekte: ObjektClient[];
console.log(objekte);
</script>
<h1 class="text-4xl font-medium my-8">Willkommen zurück, {user.vorname}!</h1>
@@ -12,7 +15,7 @@
<h1 class="text-4xl font-medium my-8">Gebäude</h1>
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
{#each objekte as objekt}
<!-- {#each objekte as objekt}
<div class="card lg:card-side bg-base-200 card-bordered border-base-300">
<figure class="lg:w-1/2">
<img
@@ -25,5 +28,5 @@
<h4 class="text-lg font-semibold">{objekt.adresse}, {objekt.plz} {objekt.ort}</h4>
</div>
</div>
{/each}
{/each} -->
</div>

View File

@@ -30,6 +30,7 @@
export let ausweis: VerbrauchsausweisWohnenClient;
export let aufnahme: AufnahmeClient;
export let objekt: ObjektClient;
export let ausweisart: Enums.Ausweisart;
let rechnung: Partial<RechnungClient> = {
email: user.email,
@@ -89,6 +90,13 @@
0
);
const zurueck = {
[Enums.Ausweisart.VerbrauchsausweisWohnen]: `/energieausweis-erstellen/verbrauchsausweis-wohngebaeude?uid=${ausweis.uid}`,
[Enums.Ausweisart.VerbrauchsausweisGewerbe]: `/energieausweis-erstellen/verbrauchsausweis-gewerbe?uid=${ausweis.uid}`,
[Enums.Ausweisart.BedarfsausweisWohnen]: `/energieausweis-erstellen/bedarfsausweis-wohnen?uid=${ausweis.uid}`,
[Enums.Ausweisart.BedarfsausweisGewerbe]: `/energieausweis-erstellen/bedarfsausweis-gewerbe?uid=${ausweis.uid}`,
}[ausweisart]
async function speichern(e: SubmitEvent) {
e.preventDefault();
@@ -254,7 +262,7 @@
<div
class="w-full grid grid-cols-[min-content_1fr_min-content_min-content] grid-rows-[min_content_1fr] gap-x-2 self-start justify-self-end mt-8"
>
<button class="button justify-self-start">Zurück</button>
<a class="button justify-self-start" href={zurueck}>Zurück</a>
<div></div>

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { loginClient } from "#lib/login";
import { loginClient } from "#lib/login.js";
import CrossCircled from "radix-svelte-icons/src/lib/icons/CrossCircled.svelte";
import { fade } from "svelte/transition";
@@ -61,7 +61,7 @@
<span class="font-semibold">Das hat leider nicht geklappt, haben sie ihr Passwort und ihre Email Adresse richtig eingegeben?</span>
</div>
{/if}
<button class="btn btn-primary" type="submit">Einloggen</button>
<button class="button" type="submit">Einloggen</button>
<div class="flex-row justify-between" style="margin-top: 10px">
<a class="link link-hover" href="/auth/signup{redirect ? `?redirect=${redirect}` : ""}">Registrieren</a>
<a class="link link-hover" href="/auth/passwort-vergessen{redirect ? `?redirect=${redirect}` : ""}"

View File

@@ -1,46 +0,0 @@
<script lang="ts">
import { ausweisSpeichern } from "#client/lib/ausweisSpeichern.js";
import { validateAccessTokenClient } from "#client/lib/validateAccessToken.js";
import { AufnahmeClient, BedarfsausweisWohnenClient, BenutzerClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import Overlay from "#components/Overlay.svelte";
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
import { Enums } from "@ibcornelsen/database/client";
export let objekt: ObjektClient;
export let bilder: UploadedGebaeudeBild[];
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient;
export let user: BenutzerClient;
export let aufnahme: AufnahmeClient;
export let ausweisart: Enums.Ausweisart
async function ausweisAbschicken() {
if (!await validateAccessTokenClient()) {
loginOverlayHidden = false;
return
}
loginOverlayHidden = true
const result = await ausweisSpeichern(ausweis, objekt, aufnahme, bilder, ausweisart);
if (result !== null) {
window.history.pushState(
{},
"",
`${location.pathname}?uid=${ausweis.uid}`
);
window.location.href = `/kundendaten?uid=${ausweis.uid}`;
}
}
let loginOverlayHidden = true;
</script>
<Overlay bind:hidden={loginOverlayHidden}>
<div class="bg-white w-full max-w-screen-sm py-8">
<EmbeddedAuthFlowModule onLogin={ausweisAbschicken}></EmbeddedAuthFlowModule>
</div>
</Overlay>
<button on:click={ausweisAbschicken} type="button" class="button" data-cy="weiter">Weiter</button>

View File

@@ -88,6 +88,6 @@ if (!ausweis || !user) {
---
<AusweisLayout title="Kundendaten Aufnehmen - IBCornelsen">
<KundendatenModule {user} {ausweis} {objekt} {aufnahme} selectedPaymentType={Enums.Bezahlmethoden.paypal} client:load></KundendatenModule>
<KundendatenModule {user} {ausweis} {objekt} {aufnahme} {ausweisart} selectedPaymentType={Enums.Bezahlmethoden.paypal} client:load></KundendatenModule>
</AusweisLayout>