Kundendaten Rechnung Typ Aktualisiert

This commit is contained in:
Moritz Utcke
2024-01-13 14:03:24 +07:00
parent 97bc8bedbb
commit 5809cfc0ef
8 changed files with 125 additions and 108 deletions

View File

@@ -8,10 +8,12 @@
import { Enums } from "@ibcornelsen/database/client"
import PaymentOption from "#components/PaymentOption.svelte";
import { client } from "src/trpc";
import type { inferProcedureInput } from "@trpc/server";
import type { AppRouter } from "@ibcornelsen/api";
export let user: Benutzer;
export let ausweis: VerbrauchsausweisWohnen | BedarfsausweisWohnen | VerbrauchsausweisGewerbe;
let rechnung: Rechnungen = {} as Rechnungen;
let rechnung: inferProcedureInput<AppRouter["v1"]["rechnungen"]["erstellen"]> = {};
let services = [{
name: "Qualitätsdruck per Post (zusätzlich zur PDF Version) für 9€ inkl. MwSt.",
@@ -40,16 +42,25 @@
let agbAkzeptiert: boolean;
let datenschutzAkzeptiert: boolean;
async function createPayment() {
async function createPayment(e: SubmitEvent) {
e.preventDefault()
if (form.checkValidity() === false) {
form.reportValidity();
return;
}
const response = await client.v1.rechnungen.erstellen.mutate({
...rechnung,
ausweisart: ausweis.ausweisart,
uid: ausweis.uid,
payment_method: selectedPaymentType,
bezahlmethode: selectedPaymentType,
services: services.filter(service => service.selected).map(service => service.id)
})
window.location.href = response.checkout_url
//window.location.href = response.checkout_url
}
let form: HTMLFormElement;
</script>
<div class="w-full px-8">
@@ -63,7 +74,7 @@
<div
class="w-full"
>
<div class="flex flex-row gap-8">
<form class="flex flex-row gap-8" bind:this={form}>
<div class="w-3/5">
<div class="GRB3">
<HelpLabel title="Ansprechpartner" />
@@ -337,7 +348,7 @@
>
</div>
</div>
<button class="pay-button" disabled={!agbAkzeptiert || !datenschutzAkzeptiert}
<button type="submit" class="pay-button" disabled={!agbAkzeptiert || !datenschutzAkzeptiert}
on:click={createPayment}
>Kostenpflichtig Bestellen</button
>
@@ -353,7 +364,7 @@
<div class="w-2/5">
<PriceContainer {ausweis} bind:services />
</div>
</div>
</form>
</div>
</div>