diff --git a/package.json b/package.json index 3ebb24c6..a07f804e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "GPL V3.0", "type": "module", "scripts": { - "dev": "bun --bun astro dev", + "dev": "pnpm astro dev", "build": "bun --bun astro build", "preview": "bun --bun astro preview", "astro": "astro", @@ -22,12 +22,15 @@ "@astrojs/svelte": "^2.2.0", "@astrojs/tailwind": "^3.1.3", "@ibcornelsen/database": "link:@ibcornelsen/database", + "@ibcornelsen/api": "link:@ibcornelsen/api", "@ibcornelsen/ui": "^0.0.2", "@mollie/api-client": "^3.7.0", "@trpc/client": "^10.45.0", "@trpc/server": "^10.45.0", + "@types/body-scroll-lock": "^3.1.2", "astro": "^2.5.1", "astro-i18next": "1.0.0-beta.21", + "body-scroll-lock": "^4.0.0-beta.0", "buffer": "^6.0.3", "bun": "^1.0.2", "cookiejs": "^2.1.2", diff --git a/src/components/Bedarfsausweis/BedarfsausweisContent.svelte b/src/components/Bedarfsausweis/BedarfsausweisContent.svelte index b1979310..5effb71c 100644 --- a/src/components/Bedarfsausweis/BedarfsausweisContent.svelte +++ b/src/components/Bedarfsausweis/BedarfsausweisContent.svelte @@ -7,11 +7,9 @@ import HelpLabel from "#components/HelpLabel.svelte"; import ZipSearch from "#components/ZIPSearch.svelte"; import { hotWaterProductionTypes } from "./HotWaterProductionTypes"; - import { Bedarfsausweis } from "src/lib/Ausweis/Bedarfsausweis"; import BilderZusatzsysteme from "../Ausweis/BilderZusatzsysteme.svelte"; import moment from "moment"; import { BitChecker } from "src/lib/BitChecker"; - import { Dachgeschoss } from "src/lib/Ausweis/types"; let ausweis = new Bedarfsausweis(); diff --git a/src/components/Label.svelte b/src/components/Label.svelte index 92c3fc95..62e3a0d2 100644 --- a/src/components/Label.svelte +++ b/src/components/Label.svelte @@ -2,6 +2,6 @@ export let name: string = ""; -
+
\ No newline at end of file diff --git a/src/components/Overlay.svelte b/src/components/Overlay.svelte new file mode 100644 index 00000000..7d02411d --- /dev/null +++ b/src/components/Overlay.svelte @@ -0,0 +1,16 @@ + + +
+ +
\ No newline at end of file diff --git a/src/layouts/BlankLayout.astro b/src/layouts/BlankLayout.astro new file mode 100644 index 00000000..17518447 --- /dev/null +++ b/src/layouts/BlankLayout.astro @@ -0,0 +1,125 @@ +--- +import i18next from "i18next"; + +import "../style/global.scss"; +import { NotificationWrapper } from "@ibcornelsen/ui"; + +export interface Props { + title: string; +} + +const { title } = Astro.props; + +const schema = JSON.stringify({ + "@context": "http://schema.org", + "@type": "Corporation", + name: "IB Cornelsen", + alternateName: "online-energieausweis.org", + url: "https://online-energieausweis.org", + logo: "https://online-energieausweis.org/ib-cornelsen.png", + address: { + "@type": "PostalAddress", + streetAddress: "Katendeich 5A", + addressLocality: "Hamburg", + postalCode: "21035", + addressCountry: "Deutschland", + email: "info@online-energieausweis.org", + }, + contactPoint: { + "@type": "ContactPoint", + telephone: "+49-040-209339850", + faxNumber: "+49-040-209339859", + contactType: "customer service", + areaServed: "DE", + availableLanguage: "German", + }, +}); +--- + + + + + + + - +
@@ -94,7 +159,7 @@ class="bg-[rgba(252,234,187,0.2)] border-2 p-4 rounded-lg border-[#ffcc03]" >
- Später Weitermachen +
@@ -273,7 +345,7 @@ autocomplete="off" bind:value={ausweis.anteil_warmwasser_2} disabled={!ausweis.zusaetzliche_heizquelle || - !ausweis.warmwasser_enthalten} + !ausweis.warmwasser_anteil_bekannt} />
diff --git a/src/modules/EmbeddedLoginModule.svelte b/src/modules/EmbeddedLoginModule.svelte new file mode 100644 index 00000000..bd4b84e6 --- /dev/null +++ b/src/modules/EmbeddedLoginModule.svelte @@ -0,0 +1,56 @@ + + +
+

Login

+
+
+

Email

+ +
+
+

Passwort

+ +
+ + +
+
diff --git a/src/modules/KundendatenModule.svelte b/src/modules/KundendatenModule.svelte index a8ebba20..530500f1 100644 --- a/src/modules/KundendatenModule.svelte +++ b/src/modules/KundendatenModule.svelte @@ -6,6 +6,7 @@ import PriceContainer from "#components/Kaufabschluss/PriceContainer.svelte"; import { Benutzer, Bezahlmethoden, Enums, Rechnungen, VerbrauchsausweisWohnen } from "@ibcornelsen/database"; import PaymentOption from "#components/PaymentOption.svelte"; + import { client } from "src/trpc"; export let user: Benutzer; export let ausweis: VerbrauchsausweisWohnen @@ -15,6 +16,17 @@ let agbAkzeptiert: boolean; let datenschutzAkzeptiert: boolean; + + async function createPayment() { + const response = await client.v1.payments.create.mutate({ + ausweisart: "VerbrauchsausweisWohnen", + uid: ausweis.uid, + payment_method: selectedPaymentType, + services: [] + }) + + window.location.href = response.checkout_url + }
@@ -303,6 +315,7 @@
diff --git a/src/modules/LoginModule.svelte b/src/modules/LoginModule.svelte index ba1fd72f..e7936a43 100644 --- a/src/modules/LoginModule.svelte +++ b/src/modules/LoginModule.svelte @@ -1,26 +1,16 @@ @@ -59,8 +56,8 @@
- Registrieren - Passwort Vergessen? + Registrieren + Passwort Vergessen?
diff --git a/src/modules/RegisterModule.svelte b/src/modules/RegisterModule.svelte index 5563ec3f..b945ea77 100644 --- a/src/modules/RegisterModule.svelte +++ b/src/modules/RegisterModule.svelte @@ -7,14 +7,22 @@ let vorname: string; let name: string; + export let redirect: string | null = null; + async function login() { try { - const response = await client.v1.benutzer.erstellen.query({ + const response = await client.v1.benutzer.erstellen.mutate({ email, passwort, vorname, name }) + + if (redirect) { + window.location.href = redirect + return + } + window.location.href = "/login"; } catch (e) { addNotification({ @@ -78,9 +86,9 @@ >
EinloggenEinloggen - Passwort Vergessen? + Passwort Vergessen?
\ No newline at end of file diff --git a/src/pages/ausweis-gespeichert.astro b/src/pages/ausweis-gespeichert.astro new file mode 100644 index 00000000..68915375 --- /dev/null +++ b/src/pages/ausweis-gespeichert.astro @@ -0,0 +1,29 @@ +--- +import AusweisLayout from "#layouts/AusweisLayout.astro"; +import { prisma } from "@ibcornelsen/database"; + +const uid = Astro.url.searchParams.get("uid"); + +if (!uid) { + return Astro.redirect("/404"); +} + +const ausweis = await prisma.verbrauchsausweisWohnen.findUnique({ + where: { + uid, + }, +}); + +if (!ausweis) { + return Astro.redirect("/404"); +} + +const url = `https://ibcornelsen.de/verbrauchsausweis?uid=${uid}` +--- + + +

Ausweis Gespeichert

+

+ Der Ausweis wurde erfolgreich gespeichert. Sie können ihn nun unter {url} fortsetzen. +

+
\ No newline at end of file diff --git a/src/pages/auth/embedded-login.astro b/src/pages/auth/embedded-login.astro new file mode 100644 index 00000000..343114a1 --- /dev/null +++ b/src/pages/auth/embedded-login.astro @@ -0,0 +1,9 @@ +--- +import BlankLayout from "#layouts/BlankLayout.astro"; +import EmbeddedLoginModule from "#modules/EmbeddedLoginModule.svelte"; + +--- + + + + \ No newline at end of file diff --git a/src/pages/kundendaten.astro b/src/pages/kundendaten.astro index f2fbd8f9..1bd37e78 100644 --- a/src/pages/kundendaten.astro +++ b/src/pages/kundendaten.astro @@ -4,34 +4,34 @@ import KundendatenModule from "#modules/KundendatenModule.svelte"; import AusweisLayout from "#layouts/AusweisLayout.astro"; import { Benutzer, Enums, prisma } from "@ibcornelsen/database"; +// Man sollte nur auf diese Seite kommen, wenn ein Ausweis bereits vorliegt und in der Datenbank abgespeichert wurde. +const uidAusweis = Astro.url.searchParams.get("uid"); + +if (!uidAusweis) { + return Astro.redirect("/404"); +} + +const uid = Astro.cookies.get("uid").value; + +if (!uid) { + return Astro.redirect("/401"); +} + const user = await prisma.benutzer.findUnique({ where: { - id: 1, + uid }, }) as Benutzer; -// Man sollte nur auf diese Seite kommen, wenn ein Ausweis bereits vorliegt und in der Datenbank abgespeichert wurde. -const uid = Astro.url.searchParams.get("uid"); - -if (!uid) { - return Astro.redirect("/"); -} - -// NOTE: Muss umgestellt werden, wir brauchen einen Kundendaten Abschluss für jede Ausweisart. const ausweis = await prisma.verbrauchsausweisWohnen.findUnique({ where: { - uid, + uid: uidAusweis, }, }); if (!ausweis) { - return Astro.redirect("/"); + return Astro.redirect("/404"); } - - - - - --- diff --git a/src/pages/login.astro b/src/pages/login.astro index 3c1dd4e4..03dba960 100644 --- a/src/pages/login.astro +++ b/src/pages/login.astro @@ -2,8 +2,10 @@ import moment from "moment"; import LoginModule from "../modules/LoginModule.svelte"; import Layout from "../layouts/Layout.astro"; + +const redirect = Astro.url.searchParams.get("redirect") --- - + diff --git a/src/pages/signup.astro b/src/pages/signup.astro index b45a99a0..45ab020e 100644 --- a/src/pages/signup.astro +++ b/src/pages/signup.astro @@ -1,16 +1,10 @@ --- -import moment from "moment"; -import RegisterView from "../modules/RegisterModule.svelte"; +import RegisterModule from "../modules/RegisterModule.svelte"; import Layout from "../layouts/Layout.astro"; -const token = Astro.cookies.get("token").value; -const expires = Astro.cookies.get("expires").number(); -const now = moment().unix(); -if (token && now < expires) { - return Astro.redirect("/user"); -} +const redirect = Astro.url.searchParams.get("redirect"); --- - + diff --git a/src/pages/verbrauchsausweis/index.astro b/src/pages/verbrauchsausweis/index.astro index 4d4d0b04..2fd906a1 100644 --- a/src/pages/verbrauchsausweis/index.astro +++ b/src/pages/verbrauchsausweis/index.astro @@ -2,12 +2,28 @@ import AusweisLayout from "#layouts/AusweisLayout.astro"; import VerbrauchsausweisWohnenModule from "#modules/Ausweise/VerbrauchsausweisWohnenModule.svelte"; +import { GebaeudeStammdaten, VerbrauchsausweisWohnen, prisma } from "@ibcornelsen/database"; -const uid = Astro.cookies.get("ausweis_uid").value; +const uid = Astro.url.searchParams.get("uid"); +let ausweis: VerbrauchsausweisWohnen = {} as VerbrauchsausweisWohnen; +let gebaeude: GebaeudeStammdaten = {} as GebaeudeStammdaten; + +if (uid) { + const request = await prisma.verbrauchsausweisWohnen.findUnique({ + where: { uid }, + include: { gebaeude_stammdaten: true }, + }) + + if (request) { + ausweis = request; + gebaeude = request.gebaeude_stammdaten; + } +} + --- - + diff --git a/src/trpc.ts b/src/trpc.ts index dde0260f..59949437 100644 --- a/src/trpc.ts +++ b/src/trpc.ts @@ -1,14 +1,21 @@ import { createTRPCProxyClient, httpBatchLink } from '@trpc/client'; import cookies from 'js-cookie'; import type { AppRouter } from '@ibcornelsen/api'; +import { Buffer } from 'buffer'; export const client = createTRPCProxyClient({ links: [ httpBatchLink({ url: 'http://localhost:3001/', headers() { + const accessToken = cookies.get('accessToken'); + if (!accessToken) return {}; + + const buffer = Buffer.from(accessToken, 'utf-8'); + const base64 = buffer.toString('base64') + return { - 'Authorization': `Bearer ${cookies.get('accessToken')}`, + 'Authorization': `Bearer ${base64}`, }; }, }),