Fehler gefixt die beim Testen aufgefallen sind.

This commit is contained in:
Moritz Utcke
2025-02-17 11:24:07 +07:00
parent 74f05d404c
commit 5f8d30a5a3
17 changed files with 116 additions and 103 deletions

View File

@@ -5,12 +5,12 @@ 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"),
"bilder/[uid]": await import("../src/pages/api/bilder/[uid].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"),
"bedarfsausweis-wohnen/[uid]": await import("../src/pages/api/bedarfsausweis-wohnen/[uid].ts"),
"bedarfsausweis-wohnen": await import("../src/pages/api/bedarfsausweis-wohnen/index.ts"),
"bilder/[uid]": await import("../src/pages/api/bilder/[uid].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

@@ -5,7 +5,7 @@
//import Label from "#components/Label.svelte";
import { auditHeizungGebaeudeBaujahr } from "../Verbrauchsausweis/audits/HeizungGebaeudeBaujahr.js";
import { addNotification, deleteNotification } from "@ibcornelsen/ui";
import { addNotification, deleteNotification } from "#components/Notifications/shared.js";
import TagInput from "../TagInput.svelte";
import { Enums } from "@ibcornelsen/database/client";
import {

View File

@@ -86,22 +86,6 @@
}
}
$: {
console.log(month, year);
if ((availableDates.filter(date => date.month === month && date.year === year).length === 0) && typeof month === "number" && typeof year === "number") {
addNotification({
message: "Monat nicht verfügbar.",
subtext: "Der ausgewählte Monat ist in diesem Jahr nicht verfügbar, bitte wählen sie einen neuen Start Monat.",
dismissable: true,
type: "warning",
timeout: 0,
uid: "monat_nicht_verfuegbar",
selector: "select[name='energieverbrauch_zeitraum_monat']"
})
}
}
$: abweichung = auditVerbrauchAbweichung(ausweis, aufnahme);
</script>

View File

@@ -78,29 +78,6 @@
}
}
$: {
console.log(month, year);
if (
availableDates.filter(
(date) => date.month === month && date.year === year
).length === 0 &&
typeof month === "number" &&
typeof year === "number"
) {
addNotification({
message: "Monat nicht verfügbar.",
subtext:
"Der ausgewählte Monat ist in diesem Jahr nicht verfügbar, bitte wählen sie einen neuen Start Monat.",
dismissable: true,
type: "warning",
timeout: 0,
uid: "monat_nicht_verfuegbar",
selector: "select[name='energieverbrauch_zeitraum_monat']",
});
}
}
$: abweichung = auditVerbrauchAbweichung(ausweis, aufnahme);
</script>

View File

@@ -1,5 +1,7 @@
<script lang="ts"></script>
<script lang="ts">
<div class="fixed right-8 bottom-8 max-w-[400px] flex flex-col gap-4 z-50">
</script>
<div class="fixed right-8 bottom-8 max-w-[400px] flex flex-col gap-4 z-50" {...$$restProps}>
<slot></slot>
</div>

View File

@@ -75,7 +75,7 @@
on:focusin={onFocusIn}
on:focusout={onFocusOut}
on:blur={() => {
if (tag.toString().length >= minlength && tag.toString().length < maxlength) {
if (tag.toString().length >= minlength && tag.toString().length <= maxlength) {
addTag(tag)
tag = ""
}

View File

@@ -1,15 +1,24 @@
import { ObjektClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import {
ObjektClient,
VerbrauchsausweisWohnenClient,
} from "#components/Ausweis/types.js";
import { AuditType, hidden } from "./hidden.js";
import { getKlimafaktoren } from "#lib/Klimafaktoren.js";
export async function auditKlimaFaktoren(ausweis: VerbrauchsausweisWohnenClient, gebaeude: ObjektClient): Promise<boolean> {
export async function auditKlimaFaktoren(
ausweis: VerbrauchsausweisWohnenClient,
gebaeude: ObjektClient
): Promise<boolean> {
if (hidden.has(AuditType.KLIMA_FAKTOREN)) {
return false;
}
if (ausweis.startdatum && gebaeude.plz && ausweis.verbrauch_1) {
try {
const response = await getKlimafaktoren(ausweis.startdatum, gebaeude.plz);
const response = await getKlimafaktoren(
ausweis.startdatum,
gebaeude.plz
);
return true; // Alle Klimfaktoren konnten abgefragt werden.
} catch (e) {
return true;

View File

@@ -2,7 +2,7 @@ import { AufnahmeClient } from "#components/Ausweis/types.js";
import { AuditType, hidden } from "./hidden.js";
export function auditLeerStand(gebaeude: AufnahmeClient): boolean {
if (gebaeude.leerstand && !hidden.has(AuditType.LEER_STAND)) {
if (gebaeude.leerstand) {
return (
(gebaeude.leerstand > 30)
);

View File

@@ -1,7 +1,7 @@
import { AufnahmeClient, ObjektClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import { AufnahmeClient, ObjektClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
import { AuditType, hidden } from "./hidden.js";
export function auditVerbrauchAbweichung(ausweis: VerbrauchsausweisWohnenClient, aufnahme: AufnahmeClient): number[] {
export function auditVerbrauchAbweichung(ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient, aufnahme: AufnahmeClient): number[] {
if (aufnahme.leerstand && (aufnahme.leerstand > 0)) {
return [];
}

View File

@@ -16,21 +16,25 @@ const { title } = Astro.props;
<script>
window.addEventListener("scroll", (event) => {
let scroll = window.scrollY;
const skala = document.getElementById("skala")
console.log(scroll);
if(scroll>=400){
document.getElementById('skala')?.classList.add('2xl:fixed','2xl:py-4','2xl:top-0','2xl:z-20');
document.getElementById('skala')?.classList.remove('w-full');
if (skala) {
skala.classList.add('2xl:fixed','2xl:py-4','2xl:top-0','2xl:z-20');
skala.classList.remove('w-full');
skala.style.borderBottom = "3px solid #e6e6e6";
}
document.getElementById('skala').style.borderBottom = "3px solid #e6e6e6";
const performanceBox = document.getElementById('performance-box')
if (performanceBox) {
performanceBox.style.maxWidth = "688.5px";
}
const progressBox = document.getElementById('progress-box');
document.getElementById('performance-box').style.maxWidth = "688.5px";
document.getElementById('progress-box').style.maxWidth = "688.5px";
if (progressBox) {
progressBox.style.maxWidth = "688.5px"
}
document.getElementById('formInput-1')?.classList.add('2xl:mt-[370px]');
@@ -38,11 +42,12 @@ console.log(scroll);
}else{
if (skala) {
skala.classList.remove('2xl:fixed','2xl:py-4','2xl:top-0','2xl:z-20')
skala.classList.add('w-full')
skala.style.borderBottom = "none";
}
document.getElementById('skala')?.classList.remove('2xl:fixed','2xl:py-4','2xl:top-0','2xl:z-20');
document.getElementById('skala')?.classList.add('w-full');
document.getElementById('skala').style.borderBottom = "none";
document.getElementById('formInput-1')?.classList.remove('2xl:mt-[370px]');

View File

@@ -48,13 +48,15 @@
<span class="font-semibold">Falls sie ein Konto bei uns haben wurde eine Email an sie verschickt.</span>
</div>
{/if}
<button type="submit" class="btn btn-primary"
<button type="submit" class="button"
>Email zum Zurücksetzen des Passworts senden.</button
>
{#if showEmailSuccess}
<div class="flex-row justify-between" style="margin-top: 10px">
<a class="link link-hover"
href="/auth/login{redirect ? `?redirect=${redirect}` : ""}">Einloggen</a
>
</div>
{/if}
</form>
</div>

View File

@@ -70,14 +70,9 @@
required
/>
</div>
<button type="submit" class="btn btn-primary"
<button type="submit" class="button"
>Passwort zurückzusetzen</button
>
<div class="flex-row justify-between" style="margin-top: 10px">
<a class="link link-hover"
href="/auth/login">Einloggen</a
>
</div>
</form>
</div>

View File

@@ -3,9 +3,6 @@
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>

View File

@@ -1,8 +1,10 @@
<script lang="ts">
import { addNotification } from "@ibcornelsen/ui";
import { addNotification } from "#components/Notifications/shared.js";
import { CrossCircled } from "radix-svelte-icons";
import { fade } from "svelte/transition";
import { api } from "astro-typesafe-api/client";
import NotificationProvider from "#components/NotificationProvider/NotificationProvider.svelte";
import NotificationWrapper from "#components/Notifications/NotificationWrapper.svelte";
let passwort: string;
let email: string;
@@ -13,6 +15,16 @@
async function login(e: SubmitEvent) {
e.preventDefault()
if (passwort.length < 8) {
addNotification({
message: "Passwort muss mindestens 6 Zeichen enthalten.",
dismissable: true,
timeout: 3000,
type: "error"
})
return;
}
try {
const { uid } = await api.user.PUT.fetch({
email,
@@ -92,7 +104,7 @@
<span class="font-semibold">Da ist wohl etwas schiefgelaufen. Diese Email Adresse ist bereits in Benutzung, haben sie vielleicht bereits ein Konto bei uns?</span>
</div>
{/if}
<button type="submit" class="btn btn-primary"
<button type="submit" class="button"
>Registrieren</button
>
<div class="flex-row justify-between" style="margin-top: 10px">
@@ -102,4 +114,5 @@
<a class="link link-hover" href="/auth/passwort-vergessen{redirect ? `?redirect=${redirect}` : ""}">Passwort Vergessen?</a>
</div>
</form>
<NotificationWrapper></NotificationWrapper>
</div>

View File

@@ -51,6 +51,7 @@
AufnahmeClient,
} from "#components/Ausweis/types.js";
import { Enums } from "@ibcornelsen/database/client";
import { onMount } from "svelte";
// TODO: Vom Server sollte ein volles Objekt kommen, dass alle Subobjekte enthält, weil es sonst zu Problemen führen kann
// wenn aufnahme oder objekt nicht existiert...
@@ -60,6 +61,27 @@
export let user: BenutzerClient = {} as BenutzerClient;
export let bilder: UploadedGebaeudeBild[] = []
if (Object.keys(ausweis).length === 0) {
const localStorageAusweis = localStorage.getItem("ausweis");
if (localStorageAusweis) {
ausweis = JSON.parse(localStorageAusweis)
}
}
if (Object.keys(aufnahme).length === 0) {
const localStorageAufnahme = localStorage.getItem("aufnahme");
if (localStorageAufnahme) {
aufnahme = JSON.parse(localStorageAufnahme)
}
}
if (Object.keys(objekt).length === 0) {
const localStorageObjekt = localStorage.getItem("objekt");
if (localStorageObjekt) {
objekt = JSON.parse(localStorageObjekt)
}
}
async function spaeterWeitermachen() {
// TODO FIX
// const result = await ausweisSpeichern(
@@ -144,6 +166,18 @@
let waitOverlayHidden = true;
let speichernOverlayHidden = true;
$: {
if (ausweis.uid && objekt.uid && aufnahme.uid) {
localStorage.setItem(ausweis.uid, JSON.stringify(ausweis))
localStorage.setItem(objekt.uid, JSON.stringify(objekt))
localStorage.setItem(aufnahme.uid, JSON.stringify(aufnahme))
} else {
localStorage.setItem("ausweis", JSON.stringify(ausweis))
localStorage.setItem("aufnahme", JSON.stringify(aufnahme))
localStorage.setItem("objekt", JSON.stringify(objekt))
}
}
$: {
if (
aufnahme.saniert &&
@@ -302,7 +336,7 @@ lg:grid-cols-2 lg:gap-x-6
>
</div>
<ButtonWeiterHilfe {spaeterWeitermachen}
<ButtonWeiterHilfe
bind:ausweis
bind:bilder
bind:user
@@ -317,7 +351,7 @@ lg:grid-cols-2 lg:gap-x-6
</form>
<RawNotificationWrapper>
<RawNotificationWrapper class="fixed left-8 bottom-8 max-w-[400px] flex flex-col gap-4 z-50">
{#each Object.entries($notifications) as [uid, notification] (uid)}
<RawNotification notification={{ ...notification, uid }}>
{@html notification.subtext}
@@ -416,7 +450,8 @@ lg:grid-cols-2 lg:gap-x-6
dismissable: true,
onUserDismiss: () => {
hidden.add(AuditType.HEIZUNG_JUENGER_DREI_JAHRE);
objekt = objekt;
aufnahme = aufnahme;
},
type: "warning",
}}
@@ -440,6 +475,7 @@ lg:grid-cols-2 lg:gap-x-6
onUserDismiss: () => {
hidden.add(AuditType.ZEITRAUM_AKTUELL);
objekt = objekt;
ausweis = ausweis
},
type: "warning",
}}
@@ -463,6 +499,7 @@ lg:grid-cols-2 lg:gap-x-6
onUserDismiss: () => {
hidden.add(AuditType.KLIMA_FAKTOREN);
objekt = objekt;
ausweis = ausweis;
},
type: "warning",
}}
@@ -486,7 +523,7 @@ lg:grid-cols-2 lg:gap-x-6
dismissable: true,
onUserDismiss: () => {
hidden.add(AuditType.WOHN_FLAECHE);
objekt = objekt;
aufnahme = aufnahme;
},
type: "warning",
}}
@@ -506,7 +543,7 @@ lg:grid-cols-2 lg:gap-x-6
dismissable: true,
onUserDismiss: () => {
hidden.add(AuditType.WARM_WASSER);
objekt = objekt;
ausweis = ausweis;
},
type: "warning",
}}
@@ -522,11 +559,7 @@ lg:grid-cols-2 lg:gap-x-6
message: "Plausibilitätsprüfung",
timeout: 0,
uid: "LEER_STAND",
dismissable: true,
onUserDismiss: () => {
hidden.add(AuditType.LEER_STAND);
objekt = objekt;
},
dismissable: false,
type: "warning",
}}
>
@@ -536,7 +569,8 @@ lg:grid-cols-2 lg:gap-x-6
</RawNotification>
{/if}
{#if auditVerbrauchAbweichung(ausweis, aufnahme).length > 0}
{@const abweichung = auditVerbrauchAbweichung(ausweis, aufnahme)}
{#if abweichung.length > 0}
<RawNotification
notification={{
message: "Plausibilitätsprüfung",
@@ -546,17 +580,12 @@ lg:grid-cols-2 lg:gap-x-6
onUserDismiss: () => {
hidden.add(AuditType.VERBRAUCH_ABWEICHUNG);
objekt = objekt;
ausweis = ausweis;
},
type: "warning",
}}
>
Die Abweichung der Verbräuche zwischen Zeitraum {auditVerbrauchAbweichung(
ausweis,
aufnahme
)[0]} und {auditVerbrauchAbweichung(
ausweis,
aufnahme
)[1]} beträgt mehr als 30% und sie haben keinen Leerstand angegeben.
Die Abweichung der Verbräuche zwischen Zeitraum {abweichung[0]} und {abweichung[1]} beträgt mehr als 30% und sie haben keinen Leerstand angegeben.
Sind sie sich sicher, dass das stimmt?
</RawNotification>
{/if}

View File

@@ -7,7 +7,7 @@ import { z } from "zod";
export const PUT = defineApiRoute({
input: z.object({
email: z.string().email(),
passwort: z.string().min(6),
passwort: z.string().min(8),
vorname: z.string(),
name: z.string()
}),

View File

@@ -76,5 +76,5 @@ if (uid) {
---
<AusweisLayout title="Verbrauchsausweis erstellen">
<VerbrauchsausweisWohnenModule client:load {ausweis} {objekt} {aufnahme} {bilder} />
<VerbrauchsausweisWohnenModule client:only {ausweis} {objekt} {aufnahme} {bilder} />
</AusweisLayout>