From 37d02ea0bcd289718826bcff891e99a006b41e9d Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Sat, 15 Mar 2025 11:09:55 -0700 Subject: [PATCH] completed user admin page --- apps/dispatch/app/(dispatch)/layout.tsx | 1 - apps/dispatch/app/_store/connectionStore.ts | 2 - apps/hub-server/.env.example | 1 + apps/hub-server/index.ts | 16 +- .../mail-templates/PasswordChanged.tsx | 202 ++++++++++++++++++ apps/hub-server/modules/mail.ts | 50 +++-- apps/hub-server/package.json | 2 + apps/hub-server/routes/mail.ts | 56 +++++ apps/hub-server/routes/router.ts | 8 + apps/hub/app/(app)/_components/Events.tsx | 1 - .../event/_components/AppointmentModal.tsx | 3 +- .../admin/user/[id]/_components/forms.tsx | 105 ++++++--- apps/hub/app/(app)/admin/user/[id]/page.tsx | 7 +- apps/hub/app/(app)/admin/user/action.ts | 35 +++ .../app/(app)/events/_components/modalBtn.tsx | 7 - .../(auth)/register/_components/Register.tsx | 2 +- apps/hub/app/_components/Error.tsx | 11 + apps/hub/app/_components/ui/Button.tsx | 56 +++-- apps/hub/app/_components/ui/Select.tsx | 9 +- apps/hub/app/api/user/route.ts | 2 - apps/hub/helper/mail.ts | 40 ++++ package-lock.json | 27 +++ packages/database/prisma/schema/user.prisma | 30 +-- 23 files changed, 567 insertions(+), 106 deletions(-) create mode 100644 apps/hub-server/modules/mail-templates/PasswordChanged.tsx create mode 100644 apps/hub-server/routes/mail.ts create mode 100644 apps/hub-server/routes/router.ts create mode 100644 apps/hub/app/(app)/admin/user/action.ts create mode 100644 apps/hub/app/_components/Error.tsx create mode 100644 apps/hub/helper/mail.ts diff --git a/apps/dispatch/app/(dispatch)/layout.tsx b/apps/dispatch/app/(dispatch)/layout.tsx index 30116e52..feae307f 100644 --- a/apps/dispatch/app/(dispatch)/layout.tsx +++ b/apps/dispatch/app/(dispatch)/layout.tsx @@ -14,7 +14,6 @@ export default async function RootLayout({ children: React.ReactNode; }>) { const session = await getServerSession(); - console.log(session); if (!session) { redirect("/login"); } diff --git a/apps/dispatch/app/_store/connectionStore.ts b/apps/dispatch/app/_store/connectionStore.ts index 1ebfaeaf..1ba1764a 100644 --- a/apps/dispatch/app/_store/connectionStore.ts +++ b/apps/dispatch/app/_store/connectionStore.ts @@ -1,8 +1,6 @@ import { create } from "zustand"; import { socket } from "../(dispatch)/socket"; -console.log("connectionStore"); - interface ConnectionStore { isConnected: boolean; connect: (uid: string) => Promise; diff --git a/apps/hub-server/.env.example b/apps/hub-server/.env.example index b08a718f..959cea51 100644 --- a/apps/hub-server/.env.example +++ b/apps/hub-server/.env.example @@ -1,3 +1,4 @@ +API_PORT= MOODLE_TOKEN= MOODLE_URL= MAIL_SERVER= diff --git a/apps/hub-server/index.ts b/apps/hub-server/index.ts index 7cc534dc..d2e43551 100644 --- a/apps/hub-server/index.ts +++ b/apps/hub-server/index.ts @@ -1,5 +1,17 @@ import "dotenv/config"; import "modules/chron"; +import express from "express"; +import cors from "cors"; +import router from "routes/router"; -// Add API eventually -console.log("VAR hub Server started"); +const app = express(); + +app.use(express.json()); +app.use(cors()); + +app.use(router); + +const port = process.env.API_PORT || 3003; +app.listen(port, () => { + console.log(`Server is running on port ${port}`); +}); diff --git a/apps/hub-server/modules/mail-templates/PasswordChanged.tsx b/apps/hub-server/modules/mail-templates/PasswordChanged.tsx new file mode 100644 index 00000000..5cd48499 --- /dev/null +++ b/apps/hub-server/modules/mail-templates/PasswordChanged.tsx @@ -0,0 +1,202 @@ +import * as React from "react"; +import { User } from "@repo/db"; +import { Html, render } from "@react-email/components"; + +const styles = ` + * { + box-sizing: border-box; + } + + body { + margin: 0; + padding: 0; + } + + a[x-apple-data-detectors] { + color: inherit !important; + text-decoration: inherit !important; + } + + #MessageViewBody a { + color: inherit; + text-decoration: none; + } + + p { + line-height: inherit; + } + + .desktop_hide, + .desktop_hide table { + mso-hide: all; + display: none; + max-height: 0px; + overflow: hidden; + } + + .image_block img + div { + display: none; + } + + sup, + sub { + font-size: 75%; + line-height: 0; + } + + .menu_block.desktop_hide .menu-links span { + mso-hide: all; + } + + @media (max-width: 700px) { + .desktop_hide table.icons-inner { + display: inline-block !important; + } + + .icons-inner { + text-align: center; + } + + .icons-inner td { + margin: 0 auto; + } + } +`; + +const Template = ({ user, password }: { user: User; password: string }) => ( + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ Logo +
+ Passwort geändert +
+ Hallo {user.firstname}, +
+ Dein Passwort wurde erfolgreich geändert. Wenn du diese + Änderung nicht vorgenommen hast, kontaktiere bitte sofort + unseren Support. +
+ Dein neues Passwort lautet: {password} +
+ + Impressum + + | + + Datenschutzerklärung + + | + + Knowledgebase + +
+
+ + +); + +export function renderPasswordChanged({ + user, + password, +}: { + user: User; + password: string; +}) { + return render(