This commit is contained in:
Moritz Utcke
2025-04-05 22:35:08 -03:00
parent 6c108f0455
commit 074ee8b463
15 changed files with 559 additions and 602 deletions

View File

@@ -1,6 +1,6 @@
import { OmitKeys, TicketClient } from "#components/Ausweis/types.js"; import { OmitKeys, TicketClient } from "#components/Ausweis/types.js";
import { api } from "astro-typesafe-api/client"; import { api } from "astro-typesafe-api/client";
export async function createTicket(info: OmitKeys<TicketClient, "created_at" | "deleted_at" | "prioritaet" | "updated_at" | "status" | "uid">) { export async function createTicket(info: OmitKeys<TicketClient, "created_at" | "deleted_at" | "prioritaet" | "updated_at" | "status">) {
return await api.ticket.PUT.fetch(info) return await api.ticket.PUT.fetch(info)
} }

View File

@@ -49,7 +49,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
data-cy="ausstellgrund" data-cy="ausstellgrund"
> >
<option disabled selected >Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
{#each ausstellgrund as name} {#each ausstellgrund as name}
<option value={name}>{name}</option> <option value={name}>{name}</option>
{/each} {/each}
@@ -73,7 +73,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
bind:value={aufnahme.gebaeudetyp} bind:value={aufnahme.gebaeudetyp}
> >
<option disabled selected value>Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
{#if ausweisart==Enums.Ausweisart.VerbrauchsausweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.BedarfsausweisWohnen} {#if ausweisart==Enums.Ausweisart.VerbrauchsausweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.BedarfsausweisWohnen}
<option value="Einfamilienhaus">Einfamilienhaus</option> <option value="Einfamilienhaus">Einfamilienhaus</option>
@@ -225,7 +225,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
bind:value={aufnahme.saniert} bind:value={aufnahme.saniert}
> >
<option disabled selected>Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
<option value={true}>saniert</option> <option value={true}>saniert</option>
<option value={false}>unsaniert</option> <option value={false}>unsaniert</option>
</select> </select>

View File

@@ -5,7 +5,7 @@
import Overlay from "#components/Overlay.svelte"; import Overlay from "#components/Overlay.svelte";
import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte"; import EmbeddedAuthFlowModule from "#modules/EmbeddedAuthFlowModule.svelte";
import { AusweisTyp, BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage } from "#lib/client/prisma.js"; import { AusweisTyp, BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, Unterlage, VerbrauchsausweisWohnen } from "#lib/client/prisma.js";
import { openWindowWithPost } from "#lib/helpers/window.js"; import { openWindowWithPost } from "#lib/helpers/window.js";
import { PRICES } from "#lib/constants.js"; import { PRICES } from "#lib/constants.js";
import { nachweisSpeichern } from "#client/lib/nachweisSpeichern.js"; import { nachweisSpeichern } from "#client/lib/nachweisSpeichern.js";
@@ -19,6 +19,7 @@
export let ausweisart: Enums.Ausweisart export let ausweisart: Enums.Ausweisart
export let form: HTMLFormElement; export let form: HTMLFormElement;
export let skala: HTMLDivElement; export let skala: HTMLDivElement;
export let blockLocalStorageSync: boolean = false;
export let showWeiter: boolean = true; export let showWeiter: boolean = true;
export let showHelpButton: boolean = true; export let showHelpButton: boolean = true;
@@ -95,10 +96,10 @@
let result: Awaited<ReturnType<typeof ausweisSpeichern>> | Awaited<ReturnType<typeof nachweisSpeichern>> | null = null; let result: Awaited<ReturnType<typeof ausweisSpeichern>> | Awaited<ReturnType<typeof nachweisSpeichern>> | null = null;
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) { if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen || ausweisart === Enums.Ausweisart.GEGNachweisGewerbe || ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
result = await nachweisSpeichern({ ...ausweis, nachweistyp: ausweistyp }, objekt, aufnahme, bilder, unterlagen, ausweisart) result = await nachweisSpeichern({ ...ausweis as GEGNachweisWohnen, nachweistyp: ausweistyp }, objekt, aufnahme, bilder, unterlagen, ausweisart)
ausweis.id = result.nachweis_id; ausweis.id = result.nachweis_id;
} else { } else {
result = await ausweisSpeichern({ ...ausweis, ausweistyp }, objekt, aufnahme, bilder, ausweisart) result = await ausweisSpeichern({ ...ausweis as VerbrauchsausweisWohnen, ausweistyp }, objekt, aufnahme, bilder, ausweisart)
ausweis.id = result.ausweis_id; ausweis.id = result.ausweis_id;
} }
@@ -108,7 +109,7 @@
"", "",
`${location.pathname}?id=${ausweis.id}` `${location.pathname}?id=${ausweis.id}`
); );
blockLocalStorageSync = true;
localStorage.clear() localStorage.clear()
window.location.href = `/speichern-erfolgreich?id=${ausweis.id}` window.location.href = `/speichern-erfolgreich?id=${ausweis.id}`
} }

View File

@@ -183,7 +183,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={aufnahme.gebaeudeteil} bind:value={aufnahme.gebaeudeteil}
required required
> >
<option disabled selected value>Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
<option value="Gesamtgebäude">Gesamtgebäude</option> <option value="Gesamtgebäude">Gesamtgebäude</option>
<option value="Wohnen">Wohnen</option> <option value="Wohnen">Wohnen</option>
</select> </select>
@@ -214,7 +214,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={aufnahme.dachgeschoss} bind:value={aufnahme.dachgeschoss}
required required
> >
<option disabled selected >Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
<option value={Enums.Heizungsstatus.NICHT_VORHANDEN} <option value={Enums.Heizungsstatus.NICHT_VORHANDEN}
>nicht vorhanden</option >nicht vorhanden</option
> >
@@ -243,7 +243,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
bind:value={aufnahme.keller} bind:value={aufnahme.keller}
> >
<option disabled selected >Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
<option value={Enums.Heizungsstatus.NICHT_VORHANDEN} <option value={Enums.Heizungsstatus.NICHT_VORHANDEN}
>nicht vorhanden</option >nicht vorhanden</option
> >

View File

@@ -1,68 +1,85 @@
<script lang="ts"> <script lang="ts">
import HelpLabel from "#components/labels/HelpLabel.svelte"; import HelpLabel from "#components/labels/HelpLabel.svelte";
import Inputlabel from "#components/labels/InputLabel.svelte"; import Inputlabel from "#components/labels/InputLabel.svelte";
export let ausweis; export let ausweis;
const arrayRange = (start: number, stop: number, step: number) => const arrayRange = (start: number, stop: number, step: number) =>
Array.from( Array.from(
{ length: (stop - start) / step + 1 }, { length: (stop - start) / step + 1 },
(value, index) => start + index * step (value, index) => start + index * step
); );
</script> </script>
<div <div
id="superBereich2" id="superBereich2"
class="grid w-full items-start class="grid w-full items-start
grid-cols-1 gap-x-4 gap-y-4 grid-cols-1 gap-x-4 gap-y-4
sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8 sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8
xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8
"> "
>
<div class="bereich-box col-span-2"> <div class="bereich-box col-span-2">
<div class="w-full grid grid-cols-2 sm:grid-cols-4 gap-4 justify-between justify-items-center items-center"> <div
<div class="ring-1 ring-black/15 bg-white rounded-md"><img src="/images/form-r.svg" alt="rechteck"/></div> class="w-full grid grid-cols-2 sm:grid-cols-4 gap-4 justify-between justify-items-center items-center"
<div class="ring-1 ring-black/15 bg-white rounded-md"><img src="/images/form-l.svg" alt="l-form" /></div> >
<div class="ring-1 ring-black/15 bg-white rounded-md"><img src="/images/form-t.svg" alt="t-form" /></div> <div class="ring-1 ring-black/15 bg-white rounded-md">
<div class="ring-1 ring-black/15 bg-white rounded-md"><img src="/images/form-u.svg" alt="u-form" /></div> <img src="/images/form-r.svg" alt="rechteck" />
</div>
<div class="ring-1 ring-black/15 bg-white rounded-md">
<img src="/images/form-l.svg" alt="l-form" />
</div>
<div class="ring-1 ring-black/15 bg-white rounded-md">
<img src="/images/form-t.svg" alt="t-form" />
</div>
<div class="ring-1 ring-black/15 bg-white rounded-md">
<img src="/images/form-u.svg" alt="u-form" />
</div>
</div>
</div> </div>
</div>
<div class="col-span-2 xl:col-span-1"> <div class="col-span-2 xl:col-span-1">
<div
<div
id="Berechnungshilfe2" id="Berechnungshilfe2"
class="bereich-box grid w-full class="bereich-box grid w-full
grid-cols-2 gap-x-4 gap-y-8 grid-cols-2 gap-x-4 gap-y-8
sm:grid-cols-3 sm:gap-x-6 sm:gap-y-8 sm:grid-cols-3 sm:gap-x-6 sm:gap-y-8
xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8 xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
" "
> >
<div class="input-standard col-span-2 sm:col-span-3">
<div class="input-standard col-span-2 sm:col-span-3"> <h4
<h4 class="m-0 font-bold p-1 pt-2 min-h-[38px] ring-1 bg-white ring-black/15 rounded-sm;">Berechnungshilfe - Eingabe der Grundfläche, Gechossanzahl und -höhe</h4> class="m-0 font-bold p-1 pt-2 min-h-[38px] ring-1 bg-white ring-black/15 rounded-sm;"
>
Berechnungshilfe - Eingabe der Grundfläche, Gechossanzahl
und -höhe
</h4>
<div class="help-label"> <div class="help-label">
<HelpLabel>Hier wählen Sie Ihren passenden Grundriss aus, und tragen die entsprechenden Maße unten ein. <HelpLabel
Bitte berücksichtigen Sie nur den Grundriss der zum beheizten Gebäude gehört. >Hier wählen Sie Ihren passenden Grundriss aus, und
Garagen oder Schuppen die an das Haus herangebaut sind aber keine Verbindung zum Wohnhaus haben bitte weglassen.</HelpLabel> tragen die entsprechenden Maße unten ein. Bitte
berücksichtigen Sie nur den Grundriss der zum beheizten
Gebäude gehört. Garagen oder Schuppen die an das Haus
herangebaut sind aber keine Verbindung zum Wohnhaus
haben bitte weglassen.</HelpLabel
>
</div>
</div> </div>
</div>
<div class="input-standard order-1 md:order-1 xl:order-1"> <div class="input-standard order-1 md:order-1 xl:order-1">
<Inputlabel title="A"></Inputlabel> <Inputlabel title="A"></Inputlabel>
<input <input
name="masse_a" name="masse_a"
type="number" type="number"
bind:value={ausweis.masse_a} bind:value={ausweis.masse_a}
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-2 md:order-2 xl:order-2"> <div class="input-standard order-2 md:order-2 xl:order-2">
<Inputlabel title="B"></Inputlabel> <Inputlabel title="B"></Inputlabel>
<input <input
@@ -71,12 +88,12 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.masse_b} bind:value={ausweis.masse_b}
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-3 md:order-3 xl:order-3"> <div class="input-standard order-3 md:order-3 xl:order-3">
<Inputlabel title="C"></Inputlabel> <Inputlabel title="C"></Inputlabel>
<input <input
@@ -85,12 +102,12 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.masse_c} bind:value={ausweis.masse_c}
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-4 md:order-4 xl:order-4"> <div class="input-standard order-4 md:order-4 xl:order-4">
<Inputlabel title="D"></Inputlabel> <Inputlabel title="D"></Inputlabel>
<input <input
@@ -99,13 +116,12 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.masse_d} bind:value={ausweis.masse_d}
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div>
</div> <div class="input-standard order-5 md:order-5 xl:order-5">
<div class="input-standard order-5 md:order-5 xl:order-5">
<Inputlabel title="E"></Inputlabel> <Inputlabel title="E"></Inputlabel>
<input <input
@@ -114,14 +130,12 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.masse_e} bind:value={ausweis.masse_e}
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div>
</div> <div class="input-standard order-6 md:order-6 xl:order-6">
<div class="input-standard order-6 md:order-6 xl:order-6">
<Inputlabel title="F"></Inputlabel> <Inputlabel title="F"></Inputlabel>
<input <input
@@ -130,24 +144,21 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.masse_f} bind:value={ausweis.masse_f}
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div>
</div>
</div> <div
</div>
<div
id="Berechnungshilfe1" id="Berechnungshilfe1"
class="bereich-box grid w-full mt-6 class="bereich-box grid w-full mt-6
grid-cols-1 gap-x-4 gap-y-8 grid-cols-1 gap-x-4 gap-y-8
sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8 sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8
xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8
" "
> >
<div class="input-standard order-1 md:order-1 xl:order-1">
<div class="input-standard order-1 md:order-1 xl:order-1">
<Inputlabel title="Anzahl Vollgeschosse *"></Inputlabel> <Inputlabel title="Anzahl Vollgeschosse *"></Inputlabel>
<input <input
@@ -157,14 +168,15 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8
required required
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel>Bitte geben Sie hier die Anzahl der Vollgeschosse <HelpLabel
an. Keller und Dachgeschoss mit Schrägen zählen >Bitte geben Sie hier die Anzahl der Vollgeschosse an.
nicht dazu.</HelpLabel> Keller und Dachgeschoss mit Schrägen zählen nicht dazu.</HelpLabel
</div> >
</div> </div>
</div>
<div class="input-standard order-2 md:order-2 xl:order-2"> <div class="input-standard order-2 md:order-2 xl:order-2">
<Inputlabel title="Geschosshöhe *"></Inputlabel> <Inputlabel title="Geschosshöhe *"></Inputlabel>
<select <select
@@ -174,103 +186,110 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8
> >
<option>Bitte auswählen</option> <option>Bitte auswählen</option>
{#each arrayRange(2.1, 4.5, 0.1) as step} {#each arrayRange(2.1, 4.5, 0.1) as step}
<option value={step}>{step.toFixed(2)} m</option <option value={step}>{step.toFixed(2)} m</option>
>
{/each} {/each}
</select> </select>
<div class="help-label"> <div class="help-label">
<HelpLabel>Bitte geben Sie hier die Geschosshöhe (lichte <HelpLabel
Raumhöhe + Deckenstärke) des Gebäudes ein. Bei >Bitte geben Sie hier die Geschosshöhe (lichte Raumhöhe
unterschiedlichen Geschosshöhen bilden Sie einen + Deckenstärke) des Gebäudes ein. Bei unterschiedlichen
Mittelwert.</HelpLabel> Geschosshöhen bilden Sie einen Mittelwert.</HelpLabel
</div> >
</div> </div>
</div>
<div class="input-standard order-3 md:order-3 xl:order-3"> <div class="input-standard order-3 md:order-3 xl:order-3">
<Inputlabel title="Gaubenanzahl"></Inputlabel> <Inputlabel title="Gaubenanzahl"></Inputlabel>
<input <input
name="anzahl_gauben" name="anzahl_gauben"
bind:value={ausweis.anzahl_gauben} bind:value={ausweis.anzahl_gauben}
type="number" type="number"
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel>Wenn Ihr Gebäude Dachgauben besitzt geben Sie hier <HelpLabel
die Anzahl ein.</HelpLabel> >Wenn Ihr Gebäude Dachgauben besitzt geben Sie hier die
</div> Anzahl ein.</HelpLabel
</div> >
</div>
</div>
<div class="input-standard order-4 md:order-4 xl:order-4"> <div class="input-standard order-4 md:order-4 xl:order-4">
<Inputlabel title="Breite aller Gauben in m"></Inputlabel> <Inputlabel title="Breite aller Gauben in m"></Inputlabel>
<select <select name="breite_gauben" bind:value={ausweis.breite_gauben}>
name="breite_gauben"
bind:value={ausweis.breite_gauben}
>
<option>Bitte auswählen</option> <option>Bitte auswählen</option>
{#each arrayRange(0.5, 10, 0.1) as step} {#each arrayRange(0.5, 10, 0.1) as step}
<option value={step}>{step.toFixed(2)} m</option <option value={step}>{step.toFixed(2)} m</option>
>
{/each} {/each}
</select> </select>
<div class="help-label"> <div class="help-label">
<HelpLabel>Bitte geben Sie hier die Gesamtbreite aller Gauben <HelpLabel
in m ein.</HelpLabel> >Bitte geben Sie hier die Gesamtbreite aller Gauben in m
</div> ein.</HelpLabel
>
</div>
</div>
</div>
</div>
<div class="bereich-box col-span-2 xl:col-span-1">
</div> <div
</div>
</div>
<div class="bereich-box col-span-2 xl:col-span-1">
<div
id="Berechnungstabelle" id="Berechnungstabelle"
class="grid w-full class="grid w-full
grid-cols-2 gap-x-4 gap-y-8 grid-cols-2 gap-x-4 gap-y-8
sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8 sm:grid-cols-2 sm:gap-x-6 sm:gap-y-8
xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1 xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
" "
> >
<div class="input-standard col-span-2"> <div class="input-standard col-span-2">
<h4 class="m-0 font-bold p-1 pt-2 min-h-[38px] ring-1 bg-white ring-black/15 rounded-sm ">Außenflächen, U-Werte und Volumen</h4> <h4
class="m-0 font-bold p-1 pt-2 min-h-[38px] ring-1 bg-white ring-black/15 rounded-sm"
>
Außenflächen, U-Werte und Volumen
</h4>
<div class="help-label"> <div class="help-label">
<HelpLabel>Die wärmeübertragende Umfassungsflächen sind die Hüllflächen des beheizten Gebäudes die an die Außenluft bzw. an unbeheizte Vorbauten grenzen. <HelpLabel
Wenn Ihnen die Außenwand-,Dach-,Decken- und Bodenflächen vorliegen können Sie die Eingabe direkt vornehmen. >Die wärmeübertragende Umfassungsflächen sind die
Hier können Sie auch das von den Umfassungsflächen eingeschlossene Volumen des Gebäudes eingeben. Hüllflächen des beheizten Gebäudes die an die Außenluft
Die ermittelten Werte der Berechnungshilfe können hier präzisiert werden.</HelpLabel> bzw. an unbeheizte Vorbauten grenzen. Wenn Ihnen die
</div> Außenwand-,Dach-,Decken- und Bodenflächen vorliegen
</div> können Sie die Eingabe direkt vornehmen. Hier können Sie
auch das von den Umfassungsflächen eingeschlossene
Volumen des Gebäudes eingeben. Die ermittelten Werte der
Berechnungshilfe können hier präzisiert werden.</HelpLabel
>
</div>
</div>
<div class="input-standard col-span-2"> <div class="input-standard col-span-2">
<Inputlabel title="Tabellenwerte"></Inputlabel> <Inputlabel title="Tabellenwerte"></Inputlabel>
<div class="input-checkboxen"> <div class="input-checkboxen">
<div <div
class="grid grid-cols-[25px_max-content] items-center justify-items-start" class="grid grid-cols-[25px_max-content] items-center justify-items-start"
> >
<input <input
id="tabellenwerte_aendern" id="tabellenwerte_aendern"
type="checkbox" type="checkbox"
bind:checked={ausweis.tabellenwerte_aendern} bind:checked={ausweis.tabellenwerte_aendern}
name="tabellenwerte_aendern" name="tabellenwerte_aendern"
/> />
<label for="tabellenwerte_aendern">Tabellenwerte manuell ändern</label> <label for="tabellenwerte_aendern"
>Tabellenwerte manuell ändern</label
>
</div> </div>
</div> </div>
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-1 md:order-1 xl:order-1"> <div class="input-standard order-1 md:order-1 xl:order-1">
<Inputlabel title="Dachfläche in m²"></Inputlabel> <Inputlabel title="Dachfläche in m²"></Inputlabel>
<input <input
@@ -278,14 +297,14 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
bind:value={ausweis.dachflaeche} bind:value={ausweis.dachflaeche}
readonly={!ausweis.tabellenwerte_aendern} readonly={!ausweis.tabellenwerte_aendern}
type="number" type="number"
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-2 md:order-2 xl:order-2"> <div class="input-standard order-2 md:order-2 xl:order-2">
<Inputlabel title="U-Wert in W/m²K"></Inputlabel> <Inputlabel title="U-Wert in W/m²K"></Inputlabel>
<input <input
@@ -298,9 +317,9 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-3 md:order-3 xl:order-3"> <div class="input-standard order-3 md:order-3 xl:order-3">
<Inputlabel title="Geschoßdecke&nbsp;in&nbsp;m²"></Inputlabel> <Inputlabel title="Geschoßdecke&nbsp;in&nbsp;m²"></Inputlabel>
<input <input
@@ -313,9 +332,9 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-4 md:order-4 xl:order-4"> <div class="input-standard order-4 md:order-4 xl:order-4">
<Inputlabel title="U-Wert in W/m²K"></Inputlabel> <Inputlabel title="U-Wert in W/m²K"></Inputlabel>
<input <input
@@ -323,14 +342,14 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
bind:value={ausweis.decke_u_wert} bind:value={ausweis.decke_u_wert}
readonly={!ausweis.tabellenwerte_aendern} readonly={!ausweis.tabellenwerte_aendern}
type="number" type="number"
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-5 md:order-5 xl:order-5"> <div class="input-standard order-5 md:order-5 xl:order-5">
<Inputlabel title="Außenwand in m²"></Inputlabel> <Inputlabel title="Außenwand in m²"></Inputlabel>
<input <input
@@ -343,9 +362,9 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-6 md:order-6 xl:order-6"> <div class="input-standard order-6 md:order-6 xl:order-6">
<Inputlabel title="U-Wert in W/m²K"></Inputlabel> <Inputlabel title="U-Wert in W/m²K"></Inputlabel>
<input <input
@@ -353,14 +372,14 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
bind:value={ausweis.aussenwand_u_wert} bind:value={ausweis.aussenwand_u_wert}
readonly={!ausweis.tabellenwerte_aendern} readonly={!ausweis.tabellenwerte_aendern}
type="number" type="number"
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-7 md:order-7 xl:order-7"> <div class="input-standard order-7 md:order-7 xl:order-7">
<Inputlabel title="Fußboden in m²"></Inputlabel> <Inputlabel title="Fußboden in m²"></Inputlabel>
<input <input
@@ -373,9 +392,9 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-8 md:order-8 xl:order-8"> <div class="input-standard order-8 md:order-8 xl:order-8">
<Inputlabel title="U-Wert in W/m²K"></Inputlabel> <Inputlabel title="U-Wert in W/m²K"></Inputlabel>
<input <input
@@ -383,15 +402,18 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
bind:value={ausweis.fussboden_u_wert} bind:value={ausweis.fussboden_u_wert}
readonly={!ausweis.tabellenwerte_aendern} readonly={!ausweis.tabellenwerte_aendern}
type="number" type="number"
/> />
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-9 md:order-9 xl:order-9 col-span-2"> <div
<Inputlabel title="eingeschlossenes Gebäudevolumen in m³"></Inputlabel> class="input-standard order-9 md:order-9 xl:order-9 col-span-2"
>
<Inputlabel title="eingeschlossenes Gebäudevolumen in m³"
></Inputlabel>
<input <input
name="volumen" name="volumen"
@@ -403,28 +425,33 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div> </div>
<div class="input-standard order-10 md:order-10 xl:order-10 col-span-2"> <div
<Inputlabel title="Blower-Door-Test erfolgreich durchgeführt:"></Inputlabel> class="input-standard order-10 md:order-10 xl:order-10 col-span-2"
>
<Inputlabel title="Blower-Door-Test erfolgreich durchgeführt:"
></Inputlabel>
<div
<div class="grid grid-cols-[max-content_max-content] bg-white gap-x-12 p-1 min-h-[38px] ring-1 ring-black/15 rounded-sm"> class="grid grid-cols-[max-content_max-content] bg-white gap-x-12 p-1 min-h-[38px] ring-1 ring-black/15 rounded-sm"
>
<div class="grid grid-cols-[25px_1fr] items-center justify-items-start"> <div
class="grid grid-cols-[25px_1fr] items-center justify-items-start"
>
<input <input
id="bow-yes" id="bow-yes"
type="radio" type="radio"
value={true} value={true}
bind:group={ausweis.dicht} bind:group={ausweis.dicht}
name="dichtheit" name="dichtheit"
/> />
<label for="bow-yes" class="radio-inline">Ja</label> <label for="bow-yes" class="radio-inline">Ja</label>
</div> </div>
<div class="grid grid-cols-[25px_1fr] items-center justify-items-start"> <div
class="grid grid-cols-[25px_1fr] items-center justify-items-start"
>
<input <input
id="bow-no" id="bow-no"
type="radio" type="radio"
@@ -432,24 +459,18 @@ xl:grid-cols-2 xl:gap-x-8 xl:gap-y-8 xl:col-span-1
bind:group={ausweis.dicht} bind:group={ausweis.dicht}
name="dichtheit" name="dichtheit"
/> />
<label for="bow-no" class="radio-inline">Nein</label> <label for="bow-no" class="radio-inline">Nein</label>
</div>
</div> </div>
</div>
<div class="help-label"> <div class="help-label">
<HelpLabel></HelpLabel> <HelpLabel></HelpLabel>
</div> </div>
</div>
</div>
</div>
</div> </div>
</div>
</div>
</div>
<!--<div class="grid grid-cols-[3fr_2fr] gap-4"> <!--<div class="grid grid-cols-[3fr_2fr] gap-4">
<div class="GRB3 gap-4"> <div class="GRB3 gap-4">
<HelpLabel <HelpLabel

View File

@@ -50,7 +50,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
bind:value={aufnahme.lueftung} bind:value={aufnahme.lueftung}
> >
<option disabled selected >Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
<option value="Fensterlueftung">Fensterlüftung</option> <option value="Fensterlueftung">Fensterlüftung</option>
<option value="Schachtlueftung">Schachtlüftung</option> <option value="Schachtlueftung">Schachtlüftung</option>
<option value="LueftungsanlageOhneWaermerueckgewinnung" <option value="LueftungsanlageOhneWaermerueckgewinnung"
@@ -83,7 +83,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
bind:value={aufnahme.kuehlung} bind:value={aufnahme.kuehlung}
> >
<option disabled selected value>Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
<option value="1">vorhanden</option> <option value="1">vorhanden</option>
<option value="0">nicht vorhanden</option> <option value="0">nicht vorhanden</option>
</select> </select>

View File

@@ -1,6 +1,4 @@
<script lang="ts"> <script lang="ts">
import HelpLabel from "#components/labels/HelpLabel.svelte";
import Inputlabel from "#components/labels/InputLabel.svelte";
import FensterImage from "./FensterImage.svelte"; import FensterImage from "./FensterImage.svelte";
@@ -13,12 +11,12 @@
VerbrauchsausweisGewerbeClient, VerbrauchsausweisGewerbeClient,
VerbrauchsausweisWohnenClient, VerbrauchsausweisWohnenClient,
} from "./types.js"; } from "./types.js";
import { boolean } from "astro:schema";
import SanierungsOption from "#components/Ausweis/SanierungsOption.svelte"; import SanierungsOption from "#components/Ausweis/SanierungsOption.svelte";
import { BedarfsausweisWohnen } from "#lib/client/prisma.js";
export let objekt: ObjektClient; export let objekt: ObjektClient;
export let aufnahme: AufnahmeClient; export let aufnahme: AufnahmeClient;
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient; export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnen;
export let images: BildClient[]; export let images: BildClient[];
</script> </script>

View File

@@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { Enums } from "#lib/client/prisma.js"; import { BedarfsausweisWohnen, Enums } from "#lib/client/prisma.js";
import HeizungImage from "./HeizungImage.svelte"; import HeizungImage from "./HeizungImage.svelte";
import { import {
@@ -14,7 +14,7 @@
export let objekt: ObjektClient; export let objekt: ObjektClient;
export let aufnahme: AufnahmeClient; export let aufnahme: AufnahmeClient;
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient; export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnen;
export let images: BildClient[]; export let images: BildClient[];
export let ausweisart: Enums.Ausweisart; export let ausweisart: Enums.Ausweisart;

View File

@@ -265,7 +265,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
disabled={!ausweis.brennstoff_1} disabled={!ausweis.brennstoff_1}
required required
> >
<option disabled selected >Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
{#each fuelMap.hasOwnProperty(ausweis.brennstoff_1) ? fuelMap[ausweis.brennstoff_1] : [] as unit} {#each fuelMap.hasOwnProperty(ausweis.brennstoff_1) ? fuelMap[ausweis.brennstoff_1] : [] as unit}
<option value={unit}>{unit}</option> <option value={unit}>{unit}</option>
{/each} {/each}
@@ -423,7 +423,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.brennstoff_2} bind:value={ausweis.brennstoff_2}
required required
> >
<option disabled selected <option disabled selected value={null}
>Bitte auswählen</option >Bitte auswählen</option
> >
{#each Object.keys(fuelMap) as fuel} {#each Object.keys(fuelMap) as fuel}
@@ -458,7 +458,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
disabled={!ausweis.brennstoff_2} disabled={!ausweis.brennstoff_2}
required required
> >
<option disabled selected <option disabled selected value={null}
>Bitte auswählen</option >Bitte auswählen</option
> >
{#each fuelMap.hasOwnProperty(ausweis.brennstoff_2) ? fuelMap[ausweis.brennstoff_2] : [] as unit} {#each fuelMap.hasOwnProperty(ausweis.brennstoff_2) ? fuelMap[ausweis.brennstoff_2] : [] as unit}

View File

@@ -236,7 +236,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
bind:value={ausweis.brennstoff_1} bind:value={ausweis.brennstoff_1}
required required
> >
<option disabled selected value>Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
{#each Object.keys(fuelMap) as fuel} {#each Object.keys(fuelMap) as fuel}
<option value={fuel}>{fuel}</option> <option value={fuel}>{fuel}</option>
{/each} {/each}
@@ -276,7 +276,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
disabled={!ausweis.brennstoff_1} disabled={!ausweis.brennstoff_1}
required required
> >
<option disabled selected value>Bitte auswählen</option> <option disabled selected value={null}>Bitte auswählen</option>
{#each fuelMap.hasOwnProperty(ausweis.brennstoff_1) ? fuelMap[ausweis.brennstoff_1] : [] as unit} {#each fuelMap.hasOwnProperty(ausweis.brennstoff_1) ? fuelMap[ausweis.brennstoff_1] : [] as unit}
<option value={unit}>{unit}</option> <option value={unit}>{unit}</option>
{/each} {/each}
@@ -440,7 +440,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
required required
data-cy="brennstoff_2" data-cy="brennstoff_2"
> >
<option disabled selected <option disabled selected value={null}
>Bitte auswählen</option >Bitte auswählen</option
> >
{#each Object.keys(fuelMap) as fuel} {#each Object.keys(fuelMap) as fuel}
@@ -483,7 +483,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
disabled={!ausweis.brennstoff_2} disabled={!ausweis.brennstoff_2}
required required
> >
<option disabled selected <option disabled selected value={null}
>Bitte auswählen</option >Bitte auswählen</option
> >
{#each fuelMap.hasOwnProperty(ausweis.brennstoff_2) ? fuelMap[ausweis.brennstoff_2] : [] as unit} {#each fuelMap.hasOwnProperty(ausweis.brennstoff_2) ? fuelMap[ausweis.brennstoff_2] : [] as unit}

View File

@@ -7,7 +7,7 @@
export let objekt: ObjektKomplettClient; export let objekt: ObjektKomplettClient;
</script> </script>
<div class=" bg-white grid grid-cols-3 md:grid-cols-3 lg:grid-cols-3 gap-4"> <div class=" bg-white grid grid-cols-1 md:grid-cols-3 lg:grid-cols-3 gap-4">
{#if objekt.aufnahmen.length > 0} {#if objekt.aufnahmen.length > 0}
{@const bild = objekt.aufnahmen[0].bilder.find(bild => bild.kategorie === Enums.BilderKategorie.Gebaeude)} {@const bild = objekt.aufnahmen[0].bilder.find(bild => bild.kategorie === Enums.BilderKategorie.Gebaeude)}
<div> <div>
@@ -21,18 +21,14 @@
{/if} {/if}
<div class="flex gap-4"> <div class="flex gap-4">
<div> {#if objekt.aufnahmen.at(-1)?.verbrauchsausweise_wohnen.length}
<a href="/pdf/ansichtsausweis?id={objekt.aufnahmen.at(-1)?.verbrauchsausweise_wohnen.at(-1).id}" target="_blank">
<div class="inline-block border rounded-lg bg-white"> <div class="inline-block border rounded-lg bg-white">
<img src="/public/images/dashboard/ausweishaken.jpg" class="h-auto w-auto max-h-[150px] max-w-full object-contain p-1" alt="Energieausweis ausgestellt"> <img src="/images/dashboard/ausweishaken.jpg" class="h-auto w-auto max-h-[150px] max-w-full object-contain p-1" alt="Energieausweis ausgestellt">
</div> </div>
<div class="text-sm text-center">Energieausweis</div> <div class="text-sm text-center">Energieausweis</div>
</div> </a>
<div> {/if}
<div class="inline-block border rounded-lg bg-white">
<img src="/public/images/dashboard/ausweishaken.jpg" class="h-auto w-auto max-h-[150px] max-w-full object-contain p-1" alt="Energieausweis ausgestellt">
</div>
<div class="text-sm text-center">Energieausweis</div>
</div>
</div> </div>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
{#each objekt.aufnahmen as aufnahme} {#each objekt.aufnahmen as aufnahme}
@@ -42,12 +38,6 @@
<a href="/dashboard/aufnahme/{aufnahme.id}" class="rounded-lg p-2 hover:bg-gray-100"><OpenInNewWindow size={30}></OpenInNewWindow></a> <a href="/dashboard/aufnahme/{aufnahme.id}" class="rounded-lg p-2 hover:bg-gray-100"><OpenInNewWindow size={30}></OpenInNewWindow></a>
</div> </div>
</div> </div>
<div class="inline-block border rounded-lg px-4 py-2 w-full">
<div class="flex justify-between items-center w-full">
<span class="text-sm">Detailübersicht<br>Stand vom {moment(aufnahme.erstellungsdatum).format("DD.MM.YYYY")}</span>
<a href="/dashboard/aufnahme/{aufnahme.id}" class="rounded-lg p-2 hover:bg-gray-100"><OpenInNewWindow size={30}></OpenInNewWindow></a>
</div>
</div>
{/each} {/each}
</div> </div>
</div> </div>

View File

@@ -28,7 +28,6 @@
AufnahmeClient AufnahmeClient
} from "#components/Ausweis/types.js"; } from "#components/Ausweis/types.js";
import ButtonSpaeterHilfe from "#components/Ausweis/ButtonSpaeterHilfe.svelte";
export let ausweis: BedarfsausweisWohnenClient; export let ausweis: BedarfsausweisWohnenClient;
export let objekt: ObjektClient export let objekt: ObjektClient
@@ -36,9 +35,9 @@
export let user: BenutzerClient = {} as BenutzerClient; export let user: BenutzerClient = {} as BenutzerClient;
export let ausweistyp: Enums.AusweisTyp export let ausweistyp: Enums.AusweisTyp
export let bilder: BildClient[] = [] export let bilder: BildClient[] = []
export let uid: string; export let id: string;
if (!uid && (!ausweis.updated_at || moment(localStorage.getItem("bedarfsausweis-wohnen.updated_at") || new Date()).isAfter(ausweis.updated_at))) { if (((user && user.rolle !== Enums.BenutzerRolle.ADMIN) || !user) && !id && (!ausweis.updated_at || moment(localStorage.getItem("bedarfsausweis-wohnen.updated_at") || new Date()).isAfter(ausweis.updated_at))) {
const localStorageAusweis = localStorage.getItem("bedarfsausweis-wohnen.ausweis"); const localStorageAusweis = localStorage.getItem("bedarfsausweis-wohnen.ausweis");
if (localStorageAusweis) { if (localStorageAusweis) {
ausweis = JSON.parse(localStorageAusweis) ausweis = JSON.parse(localStorageAusweis)
@@ -61,68 +60,21 @@
} }
$: { $: {
if (!blockLocalStorageSync) {
localStorage.setItem("bedarfsausweis-wohnen.ausweis", JSON.stringify(ausweis)) localStorage.setItem("bedarfsausweis-wohnen.ausweis", JSON.stringify(ausweis))
localStorage.setItem("bedarfsausweis-wohnen.aufnahme", JSON.stringify(aufnahme)) localStorage.setItem("bedarfsausweis-wohnen.aufnahme", JSON.stringify(aufnahme))
localStorage.setItem("bedarfsausweis-wohnen.objekt", JSON.stringify(objekt)) localStorage.setItem("bedarfsausweis-wohnen.objekt", JSON.stringify(objekt))
localStorage.setItem("bedarfsausweis-wohnen.bilder", JSON.stringify(bilder)) localStorage.setItem("bedarfsausweis-wohnen.bilder", JSON.stringify(bilder))
localStorage.setItem("bedarfsausweis-wohnen.updated_at", moment().toString()) localStorage.setItem("bedarfsausweis-wohnen.updated_at", moment().toString())
} }
let daemmungsBreiten = [0, 0.02, 0.05, 0.08, 0.12, 0.16, 0.2, 0.3, 0.4];
let fensterArten = {
Einfachverglasung: 5,
"Holzfenster Doppelverglasung": 2.7,
"Kunststofffenster Doppelverglasung": 3,
"Alu- oder Stahlfenster Doppelverglasung": 4.3,
"Fenster Doppelverglasung (ab 1995)": 1.8,
"Fenster Doppelverglasung (U-Wert 1,1)": 1.1,
"Dreifach-Wärmeschutzverglasung(U-Wert 0,9)": 0.9,
"Dreifach-Wärmeschutzverglasung(U-Wert 0,85)": 0.85,
"Passivhausfenster(U-Wert 0,7)": 0.7,
"Passivhausfenster(U-Wert 0,6)": 0.6,
"Fenster mit U-Wert 2,3": 2.3,
"Fenster mit U-Wert 1,6": 1.6,
"Fenster mit U-Wert 1,7": 1.7,
"Fenster mit U-Wert 1,3": 1.3,
"Fenster mit U-Wert 1": 1,
};
async function spaeterWeitermachen() {
// const result = await verbrauchsausweisWohnenSpeichern(
// ausweis,
// gebaeude,
// aufnahme,
// images,
// user
// );
// if (result !== null) {
// // Falls der Nutzer zurück navigiert, sollte er wieder auf seinen Vorgang kommen.
// // Sonst müsste er alles neu eingeben...
// ausweis.uid = result.uid;
// gebaeude.uid = result.gebaeude_uid;
// aufnahme.uid = result.gebaeude_aufnahme_uid;
// window.history.pushState(
// {},
// "",
// `${location.pathname}?uid=${result.uid}`
// );
// speichernOverlayHidden = false;
// }
} }
const arrayRange = (start: number, stop: number, step: number) =>
Array.from(
{ length: (stop - start) / step + 1 },
(value, index) => start + index * step
);
const ausweisart = Enums.Ausweisart.BedarfsausweisWohnen const ausweisart = Enums.Ausweisart.BedarfsausweisWohnen
const anliegen = "Energieausweis erstellen"; const anliegen = "Energieausweis erstellen";
let form: HTMLFormElement; let form: HTMLFormElement;
let skala: HTMLDivElement; let skala: HTMLDivElement;
let blockLocalStorageSync: boolean = false;
</script> </script>
@@ -143,7 +95,19 @@
<div id="formular-box" class="formular-boxen ring-0"> <div id="formular-box" class="formular-boxen ring-0">
<ButtonSpaeterHilfe {spaeterWeitermachen} /> <ButtonWeiterHilfe
bind:ausweis
bind:bilder
bind:user
bind:objekt
bind:aufnahme
bind:blockLocalStorageSync
{ausweisart}
showWeiter={false}
{form}
{skala}
>
</ButtonWeiterHilfe>
<!-- A Prüfung der Ausweisart --> <!-- A Prüfung der Ausweisart -->
@@ -240,16 +204,19 @@ title="Angabe zu Lüftung und Kühlung"
</div> </div>
<ButtonWeiterHilfe {spaeterWeitermachen} <ButtonWeiterHilfe
bind:ausweis bind:ausweis
bind:bilder bind:bilder
bind:user bind:user
bind:objekt bind:objekt
bind:aufnahme bind:aufnahme
ausweisart={Enums.Ausweisart.BedarfsausweisWohnen} bind:blockLocalStorageSync
{ausweisart}
showWeiter={true}
{form} {form}
{skala} {skala}
/> >
</ButtonWeiterHilfe>
</form> </form>

View File

@@ -42,16 +42,17 @@
} from "#components/Notifications/index.js"; } from "#components/Notifications/index.js";
export let ausweis: VerbrauchsausweisGewerbeClient; export let ausweis: VerbrauchsausweisGewerbeClient;
export let user: BenutzerClient; export let user: BenutzerClient | null;
export let objekt: ObjektClient; export let objekt: ObjektClient;
export let ausweistyp: Enums.AusweisTyp; export let ausweistyp: Enums.AusweisTyp;
export let aufnahme: AufnahmeClient; export let aufnahme: AufnahmeClient;
export let bilder: BildClient[]; export let bilder: BildClient[];
export let id: string | null;
const ausweisart = Enums.Ausweisart.VerbrauchsausweisGewerbe const ausweisart = Enums.Ausweisart.VerbrauchsausweisGewerbe
const anliegen = "Energieausweis erstellen"; const anliegen = "Energieausweis erstellen";
if (!ausweis.updated_at || moment(localStorage.getItem("verbrauchsausweis-gewerbe.updated_at") || new Date()).isAfter(ausweis.updated_at)) { if (((user && user.rolle !== Enums.BenutzerRolle.ADMIN) || !user) && !id && (!ausweis.updated_at || moment(localStorage.getItem("verbrauchsausweis-gewerbe.updated_at") || new Date()).isAfter(ausweis.updated_at))) {
const localStorageAusweis = localStorage.getItem("verbrauchsausweis-gewerbe.ausweis"); const localStorageAusweis = localStorage.getItem("verbrauchsausweis-gewerbe.ausweis");
if (localStorageAusweis) { if (localStorageAusweis) {
ausweis = JSON.parse(localStorageAusweis) ausweis = JSON.parse(localStorageAusweis)
@@ -74,13 +75,16 @@
} }
$: { $: {
if (!blockLocalStorageSync) {
localStorage.setItem("verbrauchsausweis-gewerbe.ausweis", JSON.stringify(ausweis)) localStorage.setItem("verbrauchsausweis-gewerbe.ausweis", JSON.stringify(ausweis))
localStorage.setItem("verbrauchsausweis-gewerbe.aufnahme", JSON.stringify(aufnahme)) localStorage.setItem("verbrauchsausweis-gewerbe.aufnahme", JSON.stringify(aufnahme))
localStorage.setItem("verbrauchsausweis-gewerbe.objekt", JSON.stringify(objekt)) localStorage.setItem("verbrauchsausweis-gewerbe.objekt", JSON.stringify(objekt))
localStorage.setItem("verbrauchsausweis-gewerbe.bilder", JSON.stringify(bilder)) localStorage.setItem("verbrauchsausweis-gewerbe.bilder", JSON.stringify(bilder))
localStorage.setItem("verbrauchsausweis-gewerbe.updated_at", moment().toString()) localStorage.setItem("verbrauchsausweis-gewerbe.updated_at", moment().toString())
} }
}
let blockLocalStorageSync: boolean = false;
let form: HTMLFormElement; let form: HTMLFormElement;
let skala: HTMLDivElement; let skala: HTMLDivElement;
</script> </script>
@@ -114,6 +118,7 @@
bind:user bind:user
bind:objekt bind:objekt
bind:aufnahme bind:aufnahme
bind:blockLocalStorageSync
ausweisart={Enums.Ausweisart.VerbrauchsausweisGewerbe} ausweisart={Enums.Ausweisart.VerbrauchsausweisGewerbe}
showWeiter={false} showWeiter={false}
{form} {form}
@@ -229,6 +234,7 @@
bind:user bind:user
bind:objekt bind:objekt
bind:aufnahme bind:aufnahme
bind:blockLocalStorageSync
ausweisart={Enums.Ausweisart.VerbrauchsausweisGewerbe} ausweisart={Enums.Ausweisart.VerbrauchsausweisGewerbe}
showWeiter={true} showWeiter={true}
{form} {form}

View File

@@ -3,6 +3,8 @@ import { prisma } from "#lib/server/prisma.js";
import { defineApiRoute } from "astro-typesafe-api/server"; import { defineApiRoute } from "astro-typesafe-api/server";
import { UUidWithPrefix } from "#components/Ausweis/types.js"; import { UUidWithPrefix } from "#components/Ausweis/types.js";
import { TicketsSchema } from "src/generated/zod/tickets.js"; import { TicketsSchema } from "src/generated/zod/tickets.js";
import { generatePrefixedId } from "#lib/db.js";
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
export const PUT = defineApiRoute({ export const PUT = defineApiRoute({
meta: { meta: {
@@ -20,23 +22,22 @@ export const PUT = defineApiRoute({
id: true, id: true,
prioritaet: true, prioritaet: true,
status: true, status: true,
uid: true,
updated_at: true, updated_at: true,
}), }),
output: z.object({ output: z.object({
uid: UUidWithPrefix, id: UUidWithPrefix,
}), }),
async fetch(input, ctx) { async fetch(input, ctx) {
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.Ticket)
const ticket = await prisma.tickets.create({ const ticket = await prisma.tickets.create({
data: { data: {
id,
beschreibung: input.beschreibung, beschreibung: input.beschreibung,
email: input.email, email: input.email,
titel: input.titel, titel: input.titel,
metadata: input.metadata, metadata: input.metadata,
}, }
select: {
uid: true,
},
}); });
// Das sind die Label IDs von Trello // Das sind die Label IDs von Trello
@@ -71,7 +72,7 @@ export const PUT = defineApiRoute({
return { return {
uid: ticket.uid, id: ticket.id,
}; };
}, },
}); });

View File

@@ -1,112 +1,85 @@
--- ---
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro"; import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
import { AufnahmeClient, ObjektClient, BildClient, VerbrauchsausweisGewerbeClient } from "#components/Ausweis/types"; import { AufnahmeClient, ObjektClient, BildClient, VerbrauchsausweisGewerbeClient } from "#components/Ausweis/types";
import { createCaller } from "src/astro-typesafe-api-caller";
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
import VerbrauchsausweisGewerbeModule from "#modules/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbeModule.svelte"; import VerbrauchsausweisGewerbeModule from "#modules/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbeModule.svelte";
import { Enums } from "#lib/server/prisma"; import { Aufnahme, Enums, Objekt, VerbrauchsausweisGewerbe } from "#lib/server/prisma";
import { getAufnahme, getObjekt, getBilder, getVerbrauchsausweisGewerbe } from "#lib/server/db";
import { getCurrentUser } from "#lib/server/user";
const id = Astro.url.searchParams.get("uid"); const id = Astro.url.searchParams.get("id");
const aufnahme_id = Astro.url.searchParams.get("aufnahme") const aufnahme_id = Astro.url.searchParams.get("aufnahme")
const ausweistyp = Astro.url.searchParams.get("ausweistyp") || Enums.AusweisTyp.Standard; let ausweistyp = Astro.url.searchParams.get("ausweistyp") as Enums.AusweisTyp || Enums.AusweisTyp.Standard;
let ausweis: VerbrauchsausweisGewerbeClient = {} as VerbrauchsausweisGewerbeClient; let ausweis: VerbrauchsausweisGewerbeClient = {} as VerbrauchsausweisGewerbeClient;
let aufnahme: AufnahmeClient = {} as AufnahmeClient; let aufnahme: AufnahmeClient = {} as AufnahmeClient;
let objekt: ObjektClient = {} as ObjektClient; let objekt: ObjektClient = {} as ObjektClient;
let bilder: BildClient[] = [] let bilder: BildClient[] = []
const valid = validateAccessTokenServer(Astro); const user = await getCurrentUser(Astro)
const caller = createCaller(Astro);
if (id) { if (id) {
if (!valid) { if (!user) {
return Astro.redirect( return Astro.redirect(
`/auth/login?redirect=${Astro.url.toString()}` `/auth/login?redirect=${Astro.url.toString()}`
); );
} }
try { ausweis = await getVerbrauchsausweisGewerbe(id) as VerbrauchsausweisGewerbe
let { aufnahme_id, objekt_id, benutzer_id, ...result } = await caller["verbrauchsausweis-gewerbe"]._id.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
id
}
});
ausweis = result if (!ausweis || ausweis.benutzer_id !== user.id) {
aufnahme = await caller.aufnahme._id.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
id: aufnahme_id
}
})
objekt = await caller.objekt._id.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
id: objekt_id
}
})
bilder = await caller.aufnahme._id.bilder.GET.fetch(null, {
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
id: aufnahme_id
}
})
if (!ausweis) {
// Der Ausweis scheint nicht zu existieren. // Der Ausweis scheint nicht zu existieren.
// Wir leiten auf die generische Ausweisseite ohne UID weiter. // Wir leiten auf die generische Ausweisseite ohne ID weiter.
return Astro.redirect( return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-gewerbe" "/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
); );
} }
} catch(e) {
aufnahme = await getAufnahme(ausweis.aufnahme_id) as Aufnahme
if (!aufnahme) {
// Die Aufnahme existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
return Astro.redirect( return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-gewerbe" "/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
); );
} }
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
if (!objekt) {
// Das Objekt existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
}
bilder = await getBilder(aufnahme.id);
} else if (aufnahme_id) { } else if (aufnahme_id) {
if (!valid) { if (!user) {
return Astro.redirect( return Astro.redirect(
`/auth/login?redirect=${Astro.url.toString()}` `/auth/login?redirect=${Astro.url.toString()}`
); );
} }
let { objekt_id, ...result} = await caller.aufnahme._id.GET.fetch(null, { aufnahme = await getAufnahme(ausweis.aufnahme_id) as Aufnahme
headers: {
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
},
params: {
id: aufnahme_id
}
})
aufnahme = result; if (!aufnahme) {
// Die Aufnahme existiert wohl nicht.
objekt = await caller.objekt._id.GET.fetch(null, { return Astro.redirect(
headers: { "/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}` );
}, }
params: {
id: objekt_id objekt = await getObjekt(aufnahme.objekt_id) as Objekt
if (!objekt) {
// Das Objekt existiert nicht.
return Astro.redirect(
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
);
} }
})
} }
--- ---
<AusweisLayout title="Verbrauchsausweis Gewerbe erstellen | IBCornelsen"> <AusweisLayout title="Verbrauchsausweis Gewerbe erstellen | IBCornelsen">
<VerbrauchsausweisGewerbeModule client:only {ausweis} {objekt} {aufnahme} {bilder} {ausweistyp} /> <VerbrauchsausweisGewerbeModule client:only {ausweis} {objekt} {aufnahme} {bilder} {ausweistyp} {user} {id} />
</AusweisLayout> </AusweisLayout>