Verbesserungen
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient;
|
||||
export let aufnahme: AufnahmeKomplettClient;
|
||||
export let objekt: Objekt;
|
||||
export let progress: number;
|
||||
const progress = ausweis.ausgestellt ? 100 : ausweis.bestellt ? 66 : 33;
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis.uid);
|
||||
|
||||
@@ -39,14 +39,25 @@
|
||||
});
|
||||
|
||||
if (result === true) {
|
||||
await api["verbrauchsausweis-wohnen"]._uid.DELETE.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`,
|
||||
},
|
||||
});
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
await api["verbrauchsausweis-wohnen"]._uid.DELETE.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`,
|
||||
},
|
||||
});
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
await api["verbrauchsausweis-gewerbe"]._uid.DELETE.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid,
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
ausweis.storniert
|
||||
ausweis = ausweis;
|
||||
@@ -138,8 +149,9 @@
|
||||
</div>
|
||||
<div class="badge badge-accent font-semibold text-black text-m">{objekt.adresse}</div>
|
||||
<div class="mb-4 flex flex-row items-center gap-4">
|
||||
<progress class="progress w-full" value={progress} max="100"
|
||||
></progress>
|
||||
<div class="w-full border rounded-lg my-2">
|
||||
<div class="bg-green-600 h-4 rounded-lg" class:bg-red-600={progress == 33} class:bg-primary={progress == 66} style="width: {progress}%;"></div>
|
||||
</div>
|
||||
<!-- TODO: Metrics für den Fortschritt festlegen -->
|
||||
<span class="text-sm font-semibold text-base-content"
|
||||
>{progress}%</span
|
||||
@@ -202,12 +214,19 @@
|
||||
{/if}
|
||||
|
||||
|
||||
{#if !ausweis.ausgestellt}
|
||||
{#if !ausweis.ausgestellt && !ausweis.bestellt}
|
||||
<!-- TODO -->
|
||||
<a
|
||||
class="button text-sm"
|
||||
href="/energieausweis-erstellen/verbrauchsausweis-wohngebaeude?uid={ausweis.uid}"
|
||||
>Bearbeiten</a>
|
||||
{#if ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen}
|
||||
<a
|
||||
class="button text-sm"
|
||||
href="/energieausweis-erstellen/verbrauchsausweis-wohngebaeude?uid={ausweis.uid}"
|
||||
>Bearbeiten</a>
|
||||
{:else if ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe}
|
||||
<a
|
||||
class="button text-sm"
|
||||
href="/energieausweis-erstellen/verbrauchsausweis-gewerbe?uid={ausweis.uid}"
|
||||
>Bearbeiten</a>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<a
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
<a href="/dashboard/aufnahme/{aufnahme.uid}" class="rounded-lg p-2 hover:bg-gray-100 transition-all"><OpenInNewWindow size={20}></OpenInNewWindow></a>
|
||||
</div>
|
||||
<div class="flex flex-row gap-2">
|
||||
{#if aufnahme.verbrauchsausweise_wohnen}
|
||||
{#if aufnahme.verbrauchsausweise_wohnen.length > 0}
|
||||
<a href="/dashboard/aufnahme/{aufnahme.uid}" class="rounded-lg p-2 hover:bg-gray-100 transition-all"><File size={20}></File></a>
|
||||
{/if}
|
||||
{#if aufnahme.verbrauchsausweis_gewerbe}
|
||||
{#if aufnahme.verbrauchsausweise_gewerbe.length > 0}
|
||||
<a href="/dashboard/aufnahme/{aufnahme.uid}" class="rounded-lg p-2 hover:bg-gray-100 transition-all"><File size={20}></File></a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<script lang="ts">
|
||||
import UploadImages from "./UploadImages.svelte";
|
||||
import type { Enums } from "#lib/client/prisma";
|
||||
import { BedarfsausweisWohnenClient, BildClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "./Ausweis/types.js";
|
||||
import type { Enums } from "#lib/client/prisma.js";
|
||||
import { BedarfsausweisWohnenClient, BildClient, ObjektClient, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "./Ausweis/types.js";
|
||||
import { RotateCounterClockwise, Trash, Upload } from "radix-svelte-icons";
|
||||
import { api } from "astro-typesafe-api/client";
|
||||
import Cookies from "js-cookie";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
|
||||
export let images: BildClient[] = [];
|
||||
export let max: number = Infinity;
|
||||
@@ -12,24 +15,16 @@
|
||||
export let objekt: ObjektClient;
|
||||
export let kategorie: Enums.BilderKategorie
|
||||
|
||||
async function rotateImage(image: UploadedGebaeudeBild): Promise<UploadedGebaeudeBild> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let img = new Image();
|
||||
img.src = image.data ? image.data : `/bilder/${image.uid}.jpg`;
|
||||
img.onload = () => {
|
||||
let canvas = document.createElement("canvas");
|
||||
let ctx = canvas.getContext("2d");
|
||||
canvas.width = img.height;
|
||||
canvas.height = img.width;
|
||||
ctx?.translate(img.height / 2, img.width / 2);
|
||||
ctx?.rotate((-90 * Math.PI) / 180);
|
||||
ctx?.drawImage(img, -img.width / 2, -img.height / 2);
|
||||
const clone = Object.assign({}, image)
|
||||
clone.data = canvas.toDataURL("image/jpeg");
|
||||
clone.update = true;
|
||||
resolve(clone)
|
||||
};
|
||||
async function deleteImage(image: BildClient) {
|
||||
await api.bild.DELETE.fetch({
|
||||
uid: image.uid
|
||||
}, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
||||
}
|
||||
})
|
||||
|
||||
images = images.filter((x) => x.uid !== image.uid);
|
||||
}
|
||||
|
||||
let upload: () => void;
|
||||
@@ -51,13 +46,12 @@
|
||||
type="button"
|
||||
class="rounded-full w-[30px] h-[30px] flex items-center justify-center p-0 bg-[rgba(0,0,0,0.4)]"
|
||||
on:click={() => {
|
||||
delete images[i];
|
||||
images = images.filter((x) => x);
|
||||
deleteImage(images[i])
|
||||
}}
|
||||
>
|
||||
<Trash size={20} color="#fff"></Trash>
|
||||
</button>
|
||||
<button
|
||||
<!-- <button
|
||||
type="button"
|
||||
class="rounded-full w-[30px] h-[30px] flex items-center justify-center p-0 bg-[rgba(0,0,0,0.4)]"
|
||||
on:click={async () => {
|
||||
@@ -67,7 +61,7 @@
|
||||
}}
|
||||
>
|
||||
<RotateCounterClockwise size={20} color="#fff"></RotateCounterClockwise>
|
||||
</button>
|
||||
</button> -->
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user