This commit is contained in:
Moritz Utcke
2025-03-16 22:22:34 -03:00
parent 310794a049
commit 661a75ee9c
6 changed files with 64 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
import express from 'express';
// @ts-ignore
import { handler as ssrHandler } from './dist/server/entry.mjs';

View File

@@ -285,6 +285,11 @@
}
}
if (rechnung && rechnung.status === "paid") {
window.location.href = "/dashboard"
return;
}
try {
let uid: string, checkout_url: string | undefined;
@@ -311,9 +316,6 @@
},
})
console.log(result);
uid = result.uid
checkout_url = result.checkout_url
} else {
@@ -897,6 +899,15 @@ sm:grid-cols-[min-content_min-content_min-content] sm:justify-self-end sm:mt-8"
<button class="order-2 button" type="button" on:click={speichern}>Speichern</button>
{#if rechnung && rechnung.status === "paid"}
<!-- Von einer GEG Anfrage sollte man sowieso nicht noch mal auf die Kundendaten Seite gelangen, also brauchen wir das hier nicht. -->
<button
class="order-1 sm:order-2 button cursor-pointer"
data-cy="bestellen"
type="button"
on:click={bestellen}>Absenden</button
>
{:else}
{#if gegAnfrage}
<button
class="order-1 sm:order-2 button cursor-pointer"
@@ -912,6 +923,7 @@ sm:grid-cols-[min-content_min-content_min-content] sm:justify-self-end sm:mt-8"
on:click={bestellen}>Kostenpflichtig bestellen</button
>
{/if}
{/if}
</div>
</div>

View File

@@ -7,7 +7,7 @@ import {
authorizationHeaders,
authorizationMiddleware,
} from "#lib/middleware/authorization.js";
import { getAusweisartFromUUID, UUidWithPrefix } from "#components/Ausweis/types.js";
import { UUidWithPrefix } from "#components/Ausweis/types.js";
import { getPrismaAusweisAdapter } from "#lib/server/ausweis.js";
import { PRICES, SERVICES } from "#lib/constants.js";
import { Rechnung } from "#lib/client/prisma.js";

View File

@@ -1,7 +1,8 @@
import { z } from "zod";
import { TicketsSchema, prisma } from "#lib/server/prisma.js";
import { prisma } from "#lib/server/prisma.js";
import { defineApiRoute } from "astro-typesafe-api/server";
import { UUidWithPrefix } from "#components/Ausweis/types.js";
import { TicketsSchema } from "src/generated/zod/tickets.js";
export const PUT = defineApiRoute({
meta: {
@@ -38,6 +39,37 @@ export const PUT = defineApiRoute({
},
});
// Das sind die Label IDs von Trello
const labels = {
"Technischer Fehler": "67d75d797c0884eeb3873623",
"Fehlende Funktionalität": "67d75d60b1c1b1037e7444c4",
};
const category = (input.metadata as Record<string, string>).category
const url = new URL("https://api.trello.com/1/cards")
url.searchParams.append("name", input.titel)
url.searchParams.append("desc", `User: ${input.email}\n\nDescription: ${input.beschreibung}\n\nCategory: ${category}`)
url.searchParams.append("pos", "top")
url.searchParams.append("idLabels",
(category &&
labels[category as keyof typeof labels]) ||
"650e909fdc09629a4d6d495d")
url.searchParams.append("key", "e057eb39018368ea96e456c753ac41b4")
url.searchParams.append("idList", "67d75ca7403fd22c49bc7447")
url.searchParams.append("token", "ATTA8b65b3587ab627167038cc32a3460650973eb181cde01dabb208ca1e90ed5467AC06A4F2")
// Wir laden das Ticket zu Trello hoch.
const result = await fetch(url, {
headers: {
Accept: "application/json"
},
method: "POST"
});
console.log(await result.text());
return {
uid: ticket.uid,
};

View File

@@ -5,7 +5,7 @@
*/
import { z } from "zod";
import { Enums, prisma } from "#lib/server/prisma";
import { Enums, prisma } from "#lib/server/prisma.js";
import { mollieClient } from "#lib/mollie.js";
import { APIError, defineApiRoute } from "astro-typesafe-api/server";

View File

@@ -41,10 +41,10 @@ if (!rechnung || !ausweis) {
return Astro.redirect("/")
}
if (rechnung.status === "paid") {
sendPaymentSuccessMail(ausweis, rechnung, user)
} else if (rechnung.bezahlmethode === Enums.Bezahlmethoden.rechnung) {
if (rechnung.bezahlmethode === Enums.Bezahlmethoden.rechnung) {
sendInvoiceMail(ausweis, rechnung, user)
} else {
sendPaymentSuccessMail(ausweis, rechnung, user)
}
---