Fix dev
This commit is contained in:
@@ -1,68 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { getZodBaseType } from "#client/lib/helpers.js";
|
|
||||||
import { filterAusweise } from "#lib/filters.js";
|
|
||||||
import { ZodTypeAny } from "astro:schema";
|
|
||||||
import { Cross1 } from "radix-svelte-icons";
|
|
||||||
import z, { ZodBoolean, ZodNativeEnum, ZodNumber } from "zod"
|
|
||||||
|
|
||||||
export let filters: { name: keyof z.infer<typeof filterAusweise>, type: ZodTypeAny, value: any }[] = []
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#each filters as filter, i}
|
|
||||||
{@const type = getZodBaseType(filter.type)}
|
|
||||||
<div class="flex flex-row bg-white gap-4 px-2 py-2 rounded-lg">
|
|
||||||
{#if i === 0}
|
|
||||||
<span class="badge">where</span>
|
|
||||||
{:else}
|
|
||||||
<span class="badge">and</span>
|
|
||||||
{/if}
|
|
||||||
<select on:change={function(e) {
|
|
||||||
delete filters[filter.name]
|
|
||||||
filter.name = e.target.value;
|
|
||||||
filter.type = filterAusweise._def.shape()[filter.name]
|
|
||||||
filters = filters.filter(Boolean);
|
|
||||||
}}>
|
|
||||||
<option value={filter.name} selected>{filter.name}</option>
|
|
||||||
{#each Object.keys(filterAusweise._def.shape()) as n}
|
|
||||||
{#if !filters.find(filter => filter.name === n)}
|
|
||||||
<option value={n}>{n}</option>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
<span class="badge">equals</span>
|
|
||||||
{#if type instanceof ZodNumber}
|
|
||||||
<input type="number" bind:value={filter.value}>
|
|
||||||
{:else if type instanceof ZodBoolean}
|
|
||||||
<select bind:value={filter.value}>
|
|
||||||
<option value={true}>true</option>
|
|
||||||
<option value={false}>false</option>
|
|
||||||
</select>
|
|
||||||
{:else if type instanceof ZodNativeEnum}
|
|
||||||
<select bind:value={filter.value}>
|
|
||||||
{#each Object.entries(type._def.values) as [key, value]}
|
|
||||||
<option {value}>{key}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
{:else}
|
|
||||||
<input type="text" bind:value={filter.value}>
|
|
||||||
{/if}
|
|
||||||
<Cross1 size={24} class="cursor-pointer"></Cross1>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
|
|
||||||
<button on:click={() => {
|
|
||||||
const entry = Object.entries(filterAusweise._def.shape())[0]
|
|
||||||
filters.push({
|
|
||||||
name: entry[0],
|
|
||||||
type: entry[1],
|
|
||||||
value: null
|
|
||||||
})
|
|
||||||
filters = filters
|
|
||||||
}}>Filter Hinzufügen</button>
|
|
||||||
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.badge {
|
|
||||||
@apply rounded-lg px-2 py-1 bg-gray-500 text-white;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -198,14 +198,6 @@
|
|||||||
></CaretDown></summary
|
></CaretDown></summary
|
||||||
>
|
>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
|
||||||
<a
|
|
||||||
class="button-tab"
|
|
||||||
href="/dashboard/admin/ausweise-pruefen"
|
|
||||||
>
|
|
||||||
Ausweise Prüfen
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
class="button-tab"
|
class="button-tab"
|
||||||
|
|||||||
@@ -1,126 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import AusweisPruefenBox from "#components/AusweisPruefenBox.svelte";
|
|
||||||
import NotificationProvider from "#components/NotificationProvider/NotificationProvider.svelte";
|
|
||||||
import { endEnergieVerbrauchVerbrauchsausweis_2016 } from "#lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.js";
|
|
||||||
import AusweisPruefenNotification from "#components/AusweisPruefenNotification.svelte";
|
|
||||||
import DashboardAusweisSkeleton from "#components/Dashboard/DashboardAusweisSkeleton.svelte"
|
|
||||||
import { Event } from "#lib/client/prisma";
|
|
||||||
import Pagination from "#components/Pagination.svelte";
|
|
||||||
import { api } from "astro-typesafe-api/client";
|
|
||||||
import Cookies from "js-cookie"
|
|
||||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js"
|
|
||||||
import AusweisePruefenFilter from "#components/Dashboard/AusweisePruefenFilter.svelte";
|
|
||||||
import { z, ZodTypeAny } from "zod";
|
|
||||||
import { filterAusweise } from "#lib/filters.js";
|
|
||||||
|
|
||||||
export let page: number;
|
|
||||||
export let totalPages: number;
|
|
||||||
|
|
||||||
let filters: { name: keyof z.infer<typeof filterAusweise>, type: ZodTypeAny, value: any }[] = []
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="flex flex-col mb-4">
|
|
||||||
<AusweisePruefenFilter bind:filters={filters}></AusweisePruefenFilter>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gap-4 flex flex-col">
|
|
||||||
{#await api.ausweise.GET.fetch({
|
|
||||||
limit: 10,
|
|
||||||
skip: (page - 1) * 10,
|
|
||||||
filters: filters.reduce((acc, filter) => {
|
|
||||||
acc[filter.name] = filter.value
|
|
||||||
return acc
|
|
||||||
}, {})
|
|
||||||
}, {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
<DashboardAusweisSkeleton></DashboardAusweisSkeleton>
|
|
||||||
{:then ausweise}
|
|
||||||
{#each ausweise as { ausweis, objekt, aufnahme, bilder, events }}
|
|
||||||
{#await endEnergieVerbrauchVerbrauchsausweis_2016(ausweis, aufnahme, objekt)}
|
|
||||||
<div class="rounded-lg border w-full h-20 p-2.5 gap-4 flex flex-row items-center">
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-8 h-8 rounded-full"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="w-1/12 h-full flex flex-col gap-2">
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
<div class="skeleton w-full h-4"></div>
|
|
||||||
</div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
<div class="skeleton w-4 h-4"></div>
|
|
||||||
</div>
|
|
||||||
{:then calculations}
|
|
||||||
<AusweisPruefenBox {ausweis} {aufnahme} {objekt} {bilder} {events} {calculations}></AusweisPruefenBox>
|
|
||||||
{/await}
|
|
||||||
{/each}
|
|
||||||
{/await}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Pagination pages={totalPages} current={page} prev="/dashboard/admin/ausweise-pruefen/{page - 1}" next="/dashboard/admin/ausweise-pruefen/{page + 1}"></Pagination>
|
|
||||||
|
|
||||||
<div class="fixed bottom-8 right-8 flex flex-col gap-4">
|
|
||||||
<NotificationProvider component={AusweisPruefenNotification}></NotificationProvider>
|
|
||||||
</div>
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
---
|
|
||||||
import { AufnahmeClient, BenutzerClient, ObjektClient, BildClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
|
||||||
import UserLayout from "#layouts/DashboardLayout.astro";
|
|
||||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
|
|
||||||
import { omit } from "#lib/helpers";
|
|
||||||
import DashboardAusweisePruefenModule from "#modules/Dashboard/DashboardAusweisePruefenModule.svelte";
|
|
||||||
import { Enums, prisma } from "#lib/server/prisma";
|
|
||||||
import { createCaller } from "src/astro-typesafe-api-caller";
|
|
||||||
|
|
||||||
const caller = createCaller(Astro)
|
|
||||||
|
|
||||||
const params = Astro.params;
|
|
||||||
const page = Number(params.page)
|
|
||||||
|
|
||||||
|
|
||||||
let user: BenutzerClient;
|
|
||||||
try {
|
|
||||||
user = (await caller.user.self.GET.fetch(undefined, {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
||||||
}
|
|
||||||
})) || {} as BenutzerClient;
|
|
||||||
} catch(e) {
|
|
||||||
return Astro.redirect("/auth/login")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.rolle !== Enums.BenutzerRolle.ADMIN) {
|
|
||||||
return Astro.redirect("/dashboard")
|
|
||||||
}
|
|
||||||
|
|
||||||
const ausweise = await prisma.verbrauchsausweisWohnen.findMany({
|
|
||||||
where: {
|
|
||||||
benutzer: {
|
|
||||||
id: user.id
|
|
||||||
}
|
|
||||||
},
|
|
||||||
include: {
|
|
||||||
aufnahme: {
|
|
||||||
include: {
|
|
||||||
objekt: true,
|
|
||||||
bilder: true,
|
|
||||||
events: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
skip: (page - 1) * 10,
|
|
||||||
take: 10
|
|
||||||
})
|
|
||||||
|
|
||||||
const totalPages = await prisma.verbrauchsausweisWohnen.count({
|
|
||||||
where: {
|
|
||||||
benutzer: {
|
|
||||||
id: user.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const reformedAusweise = ausweise.map(ausweis => ({
|
|
||||||
ausweis: omit(ausweis, ["aufnahme"]) as VerbrauchsausweisWohnenClient,
|
|
||||||
aufnahme: omit(omit(ausweis.aufnahme, ["events"]), ["objekt"]) as AufnahmeClient,
|
|
||||||
objekt: omit(ausweis.aufnahme.objekt, ["bilder"]) as ObjektClient,
|
|
||||||
bilder: ausweis.aufnahme.bilder as unknown as BildClient[],
|
|
||||||
events: ausweis.aufnahme.events
|
|
||||||
}))
|
|
||||||
---
|
|
||||||
|
|
||||||
<UserLayout title="Ausweise Prüfen" {user}>
|
|
||||||
<DashboardAusweisePruefenModule totalPages={Math.ceil(totalPages / 10)} page={page} ausweise={reformedAusweise} client:load></DashboardAusweisePruefenModule>
|
|
||||||
</UserLayout>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
return Astro.redirect("/dashboard/admin/ausweise-pruefen/1");
|
|
||||||
---
|
|
||||||
Reference in New Issue
Block a user