From b573d7cd5a1d9d219646739ceb6d3777496e643a Mon Sep 17 00:00:00 2001
From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com>
Date: Wed, 12 Mar 2025 17:44:53 -0700
Subject: [PATCH] added suer to p-log, HUB_URL in hub-server, dynamic badges in
email
---
apps/hub-server/.env.example | 3 +-
.../modules/mail-templates/Badge.tsx | 21 +++++++
.../mail-templates/CourseCompleted.tsx | 12 ++--
.../event/_components/AppointmentModal.tsx | 57 ++++++++++---------
.../event/_components/ParticipantModal.tsx | 11 ++--
.../app/(app)/events/_components/modalBtn.tsx | 1 +
apps/hub/tsconfig.json | 3 +-
apps/hub/types/prisma.d.ts | 3 +
packages/database/index.ts | 1 +
.../database/prisma/json/ParticipantLog.ts | 7 +++
packages/database/prisma/json/index.ts | 1 +
11 files changed, 79 insertions(+), 41 deletions(-)
create mode 100644 apps/hub-server/modules/mail-templates/Badge.tsx
create mode 100644 packages/database/prisma/json/ParticipantLog.ts
create mode 100644 packages/database/prisma/json/index.ts
diff --git a/apps/hub-server/.env.example b/apps/hub-server/.env.example
index 7780c708..b08a718f 100644
--- a/apps/hub-server/.env.example
+++ b/apps/hub-server/.env.example
@@ -3,4 +3,5 @@ MOODLE_URL=
MAIL_SERVER=
MAIL_USER=
MAIL_PASSWORD=
-MAIL_PORT=
\ No newline at end of file
+MAIL_PORT=
+HUB_URL=http://localhost:3000
\ No newline at end of file
diff --git a/apps/hub-server/modules/mail-templates/Badge.tsx b/apps/hub-server/modules/mail-templates/Badge.tsx
new file mode 100644
index 00000000..ff7b32f3
--- /dev/null
+++ b/apps/hub-server/modules/mail-templates/Badge.tsx
@@ -0,0 +1,21 @@
+import { BADGES } from "@repo/db";
+import React from "react";
+
+const badgeImageMapping = {
+ [BADGES.P1]: "p-1.png",
+ [BADGES.P2]: "p-2.png",
+ [BADGES.P3]: "p-3.png",
+ [BADGES.D1]: "d-1.png",
+ [BADGES.D2]: "d-2.png",
+ [BADGES.D3]: "d-3.png",
+ [BADGES.DAY1]: "day-1-member.png",
+};
+
+export const Badge = ({ badge }: { badge: BADGES }) => (
+
+);
diff --git a/apps/hub-server/modules/mail-templates/CourseCompleted.tsx b/apps/hub-server/modules/mail-templates/CourseCompleted.tsx
index 2572003d..69f2e138 100644
--- a/apps/hub-server/modules/mail-templates/CourseCompleted.tsx
+++ b/apps/hub-server/modules/mail-templates/CourseCompleted.tsx
@@ -1,6 +1,7 @@
import * as React from "react";
import { Event, User } from "@repo/db";
import { Html, Button, render } from "@react-email/components";
+import { Badge } from "./Badge";
const styles = `
* {
@@ -87,7 +88,7 @@ const Template = ({ event, user }: { user: User; event: Event }) => (
(
|
-
+ {event.finishedBadges.map((badge) => (
+
+ ))}
|
diff --git a/apps/hub/app/(app)/admin/event/_components/AppointmentModal.tsx b/apps/hub/app/(app)/admin/event/_components/AppointmentModal.tsx
index c7373b3e..1fbaa380 100644
--- a/apps/hub/app/(app)/admin/event/_components/AppointmentModal.tsx
+++ b/apps/hub/app/(app)/admin/event/_components/AppointmentModal.tsx
@@ -123,7 +123,7 @@ export const AppointmentModal = ({
);
} else {
- return Abwarten;
+ return ?;
}
},
},
@@ -149,7 +149,7 @@ export const AppointmentModal = ({
onClick={async () => {
await upsertParticipant({
eventId: event!.id,
- userId: participantForm.watch("userId"),
+ userId: row.original.userId,
attended: true,
appointmentCancelled: false,
});
@@ -160,32 +160,33 @@ export const AppointmentModal = ({
Anwesend
)}
- {!row.original.attended && event?.hasPresenceEvents && (
-
- )}
+ {!row.original.appointmentCancelled &&
+ event?.hasPresenceEvents && (
+
+ )}
);
},
diff --git a/apps/hub/app/(app)/admin/event/_components/ParticipantModal.tsx b/apps/hub/app/(app)/admin/event/_components/ParticipantModal.tsx
index 84106d59..ab12c784 100644
--- a/apps/hub/app/(app)/admin/event/_components/ParticipantModal.tsx
+++ b/apps/hub/app/(app)/admin/event/_components/ParticipantModal.tsx
@@ -1,6 +1,6 @@
import { Switch } from "../../../../_components/ui/Switch";
import { Button } from "../../../../_components/ui/Button";
-import { Participant, Prisma } from "@repo/db";
+import { Participant, ParticipantLog, Prisma } from "@repo/db";
import { UseFormReturn } from "react-hook-form";
import { upsertParticipant } from "../../../events/actions";
import { RefObject } from "react";
@@ -59,7 +59,7 @@ export const ParticipantModal = ({
Termine
- Termin ausgewählt
+ Termin ausgewählt am
{new Date(
participantForm.watch("enscriptionDate"),
@@ -69,9 +69,12 @@ export const ParticipantModal = ({
Verlauf
- {participantForm.watch("statusLog")?.map((s) => (
+ {(
+ participantForm.watch("statusLog") as unknown as ParticipantLog[]
+ )?.map((s) => (
-
{(s as any).event}
+
{s.event}
+
{s.user}
{new Date((s as any).timestamp).toLocaleString()}
))}
diff --git a/apps/hub/app/(app)/events/_components/modalBtn.tsx b/apps/hub/app/(app)/events/_components/modalBtn.tsx
index 302e7a57..31c24565 100644
--- a/apps/hub/app/(app)/events/_components/modalBtn.tsx
+++ b/apps/hub/app/(app)/events/_components/modalBtn.tsx
@@ -214,6 +214,7 @@ const ModalBtn = ({
appointmentDate:
selectedAppointment.appointmentDate,
},
+ user: `${user?.firstname} ${user?.lastname} - ${user?.publicId}`,
event: "Termin abgesagt",
timestamp: new Date(),
},
diff --git a/apps/hub/tsconfig.json b/apps/hub/tsconfig.json
index 97f2df71..14e65d00 100644
--- a/apps/hub/tsconfig.json
+++ b/apps/hub/tsconfig.json
@@ -12,7 +12,8 @@
"**/*.tsx",
"next-env.d.ts",
"next.config.js",
- ".next/types/**/*.ts"
+ ".next/types/**/*.ts",
+ "types/.d.ts"
],
"exclude": ["node_modules"]
}
diff --git a/apps/hub/types/prisma.d.ts b/apps/hub/types/prisma.d.ts
index a97b5f14..bc0723f6 100644
--- a/apps/hub/types/prisma.d.ts
+++ b/apps/hub/types/prisma.d.ts
@@ -1,4 +1,5 @@
import { Prisma } from "@prisma/client";
+import { JsonArray, JsonObject } from "@prisma/client/runtime/library";
declare module "@prisma/client" {
export type InputJsonValue =
@@ -8,4 +9,6 @@ declare module "@prisma/client" {
| null
| JsonObject
| JsonArray;
+
+ export type JsonValue = any; // Erzwingt Flexibilität
}
diff --git a/packages/database/index.ts b/packages/database/index.ts
index 8b2355be..6f4845c2 100644
--- a/packages/database/index.ts
+++ b/packages/database/index.ts
@@ -4,3 +4,4 @@ export * from "./generated/client"; // exports generated types from prisma
import * as zodTypes from "./generated/zod";
export const zod = zodTypes;
+export * from "./prisma/json";
diff --git a/packages/database/prisma/json/ParticipantLog.ts b/packages/database/prisma/json/ParticipantLog.ts
new file mode 100644
index 00000000..afe62ec1
--- /dev/null
+++ b/packages/database/prisma/json/ParticipantLog.ts
@@ -0,0 +1,7 @@
+import { JsonValue } from "@prisma/client/runtime/library";
+
+export interface ParticipantLog {
+ event: string;
+ timestamp: Date;
+ user: string;
+}
diff --git a/packages/database/prisma/json/index.ts b/packages/database/prisma/json/index.ts
new file mode 100644
index 00000000..dcdbeb9a
--- /dev/null
+++ b/packages/database/prisma/json/index.ts
@@ -0,0 +1 @@
+export type { ParticipantLog } from "./ParticipantLog";