diff --git a/apps/dispatch/app/dispatch/_components/navbar/_components/Settings.tsx b/apps/dispatch/app/dispatch/_components/navbar/_components/Settings.tsx new file mode 100644 index 00000000..5a51934f --- /dev/null +++ b/apps/dispatch/app/dispatch/_components/navbar/_components/Settings.tsx @@ -0,0 +1,103 @@ +"use client"; +import { useRef } from "react"; +import { GearIcon } from "@radix-ui/react-icons"; +import { SettingsIcon, Volume2 } from "lucide-react"; + +export const SettingsBtn = () => { + const modalRef = useRef(null); + + return ( +
+ + + +
+

+ Einstellungen +

+
+
+ +
+ {/* FÜGE HIER BITTE DEN MIKROFONAUSSCHLAG EIN WIE IN DER V1 */} +
+
+

+ Ausgabelautstärke +

+
+ +
+ 0 + 25 + 50 + 75 + 100 +
+
+ +
+ + +
+
+
+
+ ); +}; + +export const Settings = () => { + return ( +
+ +
+ ); +}; diff --git a/apps/dispatch/package.json b/apps/dispatch/package.json index e40d738c..0cf245a8 100644 --- a/apps/dispatch/package.json +++ b/apps/dispatch/package.json @@ -16,7 +16,6 @@ "@livekit/track-processors": "^0.5.6", "@radix-ui/react-icons": "^1.3.2", "@repo/db": "*", - "@repo/ui": "*", "@tailwindcss/postcss": "^4.0.14", "@tanstack/react-query": "^5.75.4", "axios": "^1.9.0", diff --git a/apps/docs/.gitignore b/apps/docs/.gitignore deleted file mode 100644 index f886745c..00000000 --- a/apps/docs/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# env files (can opt-in for commiting if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts diff --git a/apps/docs/README.md b/apps/docs/README.md deleted file mode 100644 index a98bfa81..00000000 --- a/apps/docs/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load Inter, a custom Google Font. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/apps/docs/app/favicon.ico b/apps/docs/app/favicon.ico deleted file mode 100644 index 718d6fea..00000000 Binary files a/apps/docs/app/favicon.ico and /dev/null differ diff --git a/apps/docs/app/fonts/GeistMonoVF.woff b/apps/docs/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185c..00000000 Binary files a/apps/docs/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/apps/docs/app/fonts/GeistVF.woff b/apps/docs/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daac..00000000 Binary files a/apps/docs/app/fonts/GeistVF.woff and /dev/null differ diff --git a/apps/docs/app/globals.css b/apps/docs/app/globals.css deleted file mode 100644 index 83a188be..00000000 --- a/apps/docs/app/globals.css +++ /dev/null @@ -1,50 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -.imgDark { - display: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } - - .imgLight { - display: none; - } - .imgDark { - display: unset; - } -} diff --git a/apps/docs/app/layout.tsx b/apps/docs/app/layout.tsx deleted file mode 100644 index 13e03e1a..00000000 --- a/apps/docs/app/layout.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/apps/docs/app/page.module.css b/apps/docs/app/page.module.css deleted file mode 100644 index bd063b51..00000000 --- a/apps/docs/app/page.module.css +++ /dev/null @@ -1,194 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-synthesis: none; -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - font-family: var(--font-geist-sans); - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -button.secondary { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - font-family: var(--font-geist-sans); - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; - background: transparent; - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - font-family: var(--font-geist-sans); - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/apps/docs/app/page.tsx b/apps/docs/app/page.tsx deleted file mode 100644 index dd5ac8be..00000000 --- a/apps/docs/app/page.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import Image, { type ImageProps } from "next/image"; -import { Button } from "@repo/ui/button"; -import styles from "./page.module.css"; - -type Props = Omit & { - srcLight: string; - srcDark: string; -}; - -const ThemeImage = (props: Props) => { - const { srcLight, srcDark, ...rest } = props; - - return ( - <> - - - - ); -}; - -export default function Home() { - return ( -
-
- -
    -
  1. - Get started by editing apps/docs/app/page.tsx -
  2. -
  3. Save and see your changes instantly.
  4. -
- - - -
- -
- ); -} diff --git a/apps/docs/eslint.config.js b/apps/docs/eslint.config.js deleted file mode 100644 index e8759ff5..00000000 --- a/apps/docs/eslint.config.js +++ /dev/null @@ -1,4 +0,0 @@ -import { nextJsConfig } from "@repo/eslint-config/next-js"; - -/** @type {import("eslint").Linter.Config} */ -export default nextJsConfig; diff --git a/apps/docs/next.config.js b/apps/docs/next.config.js deleted file mode 100644 index 4678774e..00000000 --- a/apps/docs/next.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/apps/docs/package.json b/apps/docs/package.json deleted file mode 100644 index dad0c6ed..00000000 --- a/apps/docs/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "docs", - "version": "0.1.0", - "type": "module", - "private": true, - "scripts": { - "dev": "next dev --turbopack -p 4000", - "build": "next build", - "start": "next start", - "lint": "next lint --max-warnings 0", - "check-types": "tsc --noEmit" - }, - "dependencies": { - "@repo/ui": "*", - "next": "^15.1.0", - "react": "^19.0.0", - "react-dom": "^19.0.0" - }, - "devDependencies": { - "@repo/eslint-config": "*", - "@repo/typescript-config": "*", - "@types/node": "^22.13.10", - "@types/react": "^19.0.10", - "@types/react-dom": "^19.0.4", - "typescript": "^5.8.2" - } -} diff --git a/apps/docs/public/file-text.svg b/apps/docs/public/file-text.svg deleted file mode 100644 index 172a26c1..00000000 --- a/apps/docs/public/file-text.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/apps/docs/public/globe.svg b/apps/docs/public/globe.svg deleted file mode 100644 index ecf90bb2..00000000 --- a/apps/docs/public/globe.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/apps/docs/public/next.svg b/apps/docs/public/next.svg deleted file mode 100644 index 4f5db824..00000000 --- a/apps/docs/public/next.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/apps/docs/public/turborepo-dark.svg b/apps/docs/public/turborepo-dark.svg deleted file mode 100644 index d56dd064..00000000 --- a/apps/docs/public/turborepo-dark.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apps/docs/public/turborepo-light.svg b/apps/docs/public/turborepo-light.svg deleted file mode 100644 index 816e1b14..00000000 --- a/apps/docs/public/turborepo-light.svg +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apps/docs/public/vercel.svg b/apps/docs/public/vercel.svg deleted file mode 100644 index d0794ba2..00000000 --- a/apps/docs/public/vercel.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/apps/docs/public/window.svg b/apps/docs/public/window.svg deleted file mode 100644 index 7305ca03..00000000 --- a/apps/docs/public/window.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/apps/docs/tsconfig.json b/apps/docs/tsconfig.json deleted file mode 100644 index 97f2df71..00000000 --- a/apps/docs/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": "@repo/typescript-config/nextjs.json", - "compilerOptions": { - "plugins": [ - { - "name": "next" - } - ] - }, - "include": [ - "**/*.ts", - "**/*.tsx", - "next-env.d.ts", - "next.config.js", - ".next/types/**/*.ts" - ], - "exclude": ["node_modules"] -} diff --git a/apps/hub/app/(app)/_components/Events.tsx b/apps/hub/app/(app)/_components/Events.tsx index 6ca82aaa..88c7384b 100644 --- a/apps/hub/app/(app)/_components/Events.tsx +++ b/apps/hub/app/(app)/_components/Events.tsx @@ -1,11 +1,10 @@ import { getServerSession } from "../../api/auth/[...nextauth]/auth"; -import { PrismaClient } from "@repo/db"; +import { prisma } from "@repo/db"; import { KursItem } from "../events/_components/item"; import { RocketIcon } from "lucide-react"; -import { eventCompleted } from "@repo/ui"; +import { eventCompleted } from "../../../helper/events"; -export default async () => { - const prisma = new PrismaClient(); +const page = async () => { const session = await getServerSession(); if (!session) return null; const user = await prisma.user.findUnique({ @@ -63,10 +62,7 @@ export default async () => { const filteredEvents = events.filter((event) => { if (eventCompleted(event, event.participants[0])) return false; - if ( - event.type === "OBLIGATED_COURSE" && - !eventCompleted(event, event.participants[0]) - ) + if (event.type === "OBLIGATED_COURSE" && !eventCompleted(event, event.participants[0])) return true; return false; }); @@ -95,3 +91,5 @@ export default async () => { ); }; + +export default page; diff --git a/apps/hub/app/(app)/events/_components/modalBtn.tsx b/apps/hub/app/(app)/events/_components/modalBtn.tsx index 3cc9ec93..0be4ce18 100644 --- a/apps/hub/app/(app)/events/_components/modalBtn.tsx +++ b/apps/hub/app/(app)/events/_components/modalBtn.tsx @@ -1,32 +1,17 @@ "use client"; import { useEffect } from "react"; -import { - CheckCircledIcon, - CalendarIcon, - EnterIcon, -} from "@radix-ui/react-icons"; -import { Event, EventAppointment, Participant, prisma, User } from "@repo/db"; +import { CheckCircledIcon, CalendarIcon, EnterIcon } from "@radix-ui/react-icons"; +import { Event, EventAppointment, Participant, User } from "@repo/db"; import { cn } from "../../../../helper/cn"; import { inscribeToMoodleCourse, upsertParticipant } from "../actions"; -import { - Check, - Clock10Icon, - Cross, - EyeIcon, - MessageCircleWarning, - TriangleAlert, -} from "lucide-react"; +import { Check, Clock10Icon, EyeIcon, TriangleAlert } from "lucide-react"; import { useForm } from "react-hook-form"; -import { - ParticipantOptionalDefaults, - ParticipantOptionalDefaultsSchema, -} from "@repo/db/zod"; +import { ParticipantOptionalDefaults, ParticipantOptionalDefaultsSchema } from "@repo/db/zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { Select } from "../../../_components/ui/Select"; import toast from "react-hot-toast"; import { useRouter } from "next/navigation"; -import { eventCompleted } from "@repo/ui"; -import { se } from "date-fns/locale"; +import { eventCompleted } from "../../../../helper/events"; interface ModalBtnProps { title: string; @@ -91,12 +76,11 @@ const ModalBtn = ({ const selectedAppointment = selectedAppointments[0]; const selectedDate = dates.find( (date) => - date.id === selectAppointmentForm.watch("eventAppointmentId") || - selectedAppointment?.id, + date.id === selectAppointmentForm.watch("eventAppointmentId") || selectedAppointment?.id, + ); + const ownIndexInParticipantList = (selectedDate as any)?.Participants?.findIndex( + (p: Participant) => p.userId === user.id, ); - const ownIndexInParticipantList = ( - selectedDate as any - )?.Participants?.findIndex((p: Participant) => p.userId === user.id); const ownPlaceInParticipantList = ownIndexInParticipantList === -1 @@ -154,9 +138,7 @@ const ModalBtn = ({ )} {} {!dates.length && ( -

- Keine Termine verfügbar -

+

Keine Termine verfügbar

)} )} @@ -174,13 +156,9 @@ const ModalBtn = ({ role="alert" className="py-4 my-5 flex items-center gap-2 justify-center border alert alert-error alert-outline" > - - Dieser Termin ist ausgebucht, wahrscheinlich wirst du nicht - teilnehmen können. (Listenplatz: {ownPlaceInParticipantList}{" "} - , max. {event.maxParticipants}) + + Dieser Termin ist ausgebucht, wahrscheinlich wirst du nicht teilnehmen können. + (Listenplatz: {ownPlaceInParticipantList} , max. {event.maxParticipants})

)} {selectedAppointment && !participant?.appointmentCancelled && ( @@ -188,11 +166,7 @@ const ModalBtn = ({

Dein Ausgewähler Termin

-

- {new Date( - selectedAppointment.appointmentDate, - ).toLocaleString()} -

+

{new Date(selectedAppointment.appointmentDate).toLocaleString()}

); }; + +export default page; diff --git a/apps/hub/app/(app)/settings/actions.ts b/apps/hub/app/(app)/settings/actions.ts index 194c228d..7be0520d 100644 --- a/apps/hub/app/(app)/settings/actions.ts +++ b/apps/hub/app/(app)/settings/actions.ts @@ -1,11 +1,10 @@ "use server"; -import { prisma, Prisma, PrismaClient } from "@repo/db"; +import { prisma, Prisma } from "@repo/db"; import { getServerSession } from "../../api/auth/[...nextauth]/auth"; import bcrypt from "bcryptjs"; export const unlinkDiscord = async (userId: string) => { - const client = new PrismaClient(); - await client.discordAccount.deleteMany({ + await prisma.discordAccount.deleteMany({ where: { userId, }, @@ -16,9 +15,7 @@ export const updateUser = async (changes: Prisma.UserUpdateInput) => { const session = await getServerSession(); if (!session) return null; - const client = new PrismaClient(); - - await client.user.update({ + await prisma.user.update({ where: { id: session.user.id, }, @@ -26,10 +23,7 @@ export const updateUser = async (changes: Prisma.UserUpdateInput) => { }); }; -export const changePassword = async ( - oldPassword: string, - newPassword: string, -) => { +export const changePassword = async (oldPassword: string, newPassword: string) => { const session = await getServerSession(); if (!session) return { diff --git a/apps/hub/app/(app)/settings/page.tsx b/apps/hub/app/(app)/settings/page.tsx index c5a7a858..8c593f4f 100644 --- a/apps/hub/app/(app)/settings/page.tsx +++ b/apps/hub/app/(app)/settings/page.tsx @@ -1,15 +1,9 @@ +import { prisma } from "@repo/db"; import { getServerSession } from "../../api/auth/[...nextauth]/auth"; -import { PrismaClient } from "@repo/db"; -import { - ProfileForm, - SocialForm, - PasswordForm, - PilotForm, -} from "./_components/forms"; +import { ProfileForm, SocialForm, PasswordForm, PilotForm } from "./_components/forms"; import { GearIcon } from "@radix-ui/react-icons"; export const page = async () => { - const prisma = new PrismaClient(); const session = await getServerSession(); if (!session) return null; const user = await prisma.user.findFirst({ diff --git a/apps/hub/app/(auth)/oauth/_components/action.ts b/apps/hub/app/(auth)/oauth/_components/action.ts index 333ad6a0..7a272316 100644 --- a/apps/hub/app/(auth)/oauth/_components/action.ts +++ b/apps/hub/app/(auth)/oauth/_components/action.ts @@ -2,9 +2,7 @@ import { generateUUID } from "../../../../helper/uuid"; import { getServerSession } from "../../../api/auth/[...nextauth]/auth"; import { Service } from "../page"; -import { PrismaClient } from "@repo/db"; - -const prisma = new PrismaClient(); +import { prisma } from "@repo/db"; export const generateToken = async (service: Service) => { const session = await getServerSession(); diff --git a/apps/hub/app/_components/pagiantedTableActions.ts b/apps/hub/app/_components/pagiantedTableActions.ts index 8f03243d..b944503f 100644 --- a/apps/hub/app/_components/pagiantedTableActions.ts +++ b/apps/hub/app/_components/pagiantedTableActions.ts @@ -1,7 +1,5 @@ "use server"; -import { PrismaClient } from "@repo/db"; - -const prisma = new PrismaClient(); +import { prisma, PrismaClient } from "@repo/db"; export async function getData( model: keyof PrismaClient, diff --git a/apps/hub/app/api/auth/[...nextauth]/auth.ts b/apps/hub/app/api/auth/[...nextauth]/auth.ts index 8a828d8d..20e3b53a 100644 --- a/apps/hub/app/api/auth/[...nextauth]/auth.ts +++ b/apps/hub/app/api/auth/[...nextauth]/auth.ts @@ -1,12 +1,8 @@ -import { - AuthOptions, - getServerSession as getNextAuthServerSession, -} from "next-auth"; +import { AuthOptions, getServerSession as getNextAuthServerSession } from "next-auth"; import { PrismaAdapter } from "@next-auth/prisma-adapter"; import Credentials from "next-auth/providers/credentials"; -import { PrismaClient } from "@repo/db"; +import { prisma } from "@repo/db"; import bcrypt from "bcryptjs"; -const prisma = new PrismaClient(); export const options: AuthOptions = { providers: [ @@ -15,7 +11,7 @@ export const options: AuthOptions = { email: { label: "Email", type: "email", placeholder: "E-Mail" }, password: { label: "Password", type: "password" }, }, - async authorize(credentials, req) { + async authorize(credentials) { try { if (!credentials) throw new Error("No credentials provided"); const user = await prisma.user.findFirstOrThrow({ diff --git a/apps/hub/app/api/discord-redirect/route.ts b/apps/hub/app/api/discord-redirect/route.ts index 6fbb6f8f..464fb560 100644 --- a/apps/hub/app/api/discord-redirect/route.ts +++ b/apps/hub/app/api/discord-redirect/route.ts @@ -1,92 +1,82 @@ -import axios, { AxiosError } from 'axios'; -import { NextRequest, NextResponse } from 'next/server'; -import { DiscordAccount, PrismaClient } from '@repo/db'; -import { getServerSession } from '../auth/[...nextauth]/auth'; +import axios, { AxiosError } from "axios"; +import { NextRequest, NextResponse } from "next/server"; +import { DiscordAccount, prisma, PrismaClient } from "@repo/db"; +import { getServerSession } from "../auth/[...nextauth]/auth"; export const GET = async (req: NextRequest) => { - const session = await getServerSession(); - const prisma = new PrismaClient(); - const code = req.nextUrl.searchParams.get('code'); + const session = await getServerSession(); + const code = req.nextUrl.searchParams.get("code"); - if (!session) { - return NextResponse.redirect(`${process.env.NEXTAUTH_URL}/login`); - } + if (!session) { + return NextResponse.redirect(`${process.env.NEXTAUTH_URL}/login`); + } - if ( - !process.env.DISCORD_OAUTH_CLIENT_ID || - !process.env.DISCORD_OAUTH_SECRET || - !process.env.DISCORD_REDIRECT || - !code - ) { - return NextResponse.json( - { - error: 'Discord OAuth not configured', - }, - { - status: 500, - } - ); - } + if ( + !process.env.DISCORD_OAUTH_CLIENT_ID || + !process.env.DISCORD_OAUTH_SECRET || + !process.env.DISCORD_REDIRECT || + !code + ) { + return NextResponse.json( + { + error: "Discord OAuth not configured", + }, + { + status: 500, + }, + ); + } - const params = new URLSearchParams({ - client_id: process.env.DISCORD_OAUTH_CLIENT_ID, - client_secret: process.env.DISCORD_OAUTH_SECRET, - redirect_uri: process.env.DISCORD_REDIRECT, - grant_type: 'authorization_code', - code, - }); + const params = new URLSearchParams({ + client_id: process.env.DISCORD_OAUTH_CLIENT_ID, + client_secret: process.env.DISCORD_OAUTH_SECRET, + redirect_uri: process.env.DISCORD_REDIRECT, + grant_type: "authorization_code", + code, + }); - const headers = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; - try { - const { data: authData } = await axios.post( - 'https://discord.com/api/oauth2/token', - params, - { - headers, - } - ); + const headers = { + "Content-Type": "application/x-www-form-urlencoded", + }; + try { + const { data: authData } = await axios.post("https://discord.com/api/oauth2/token", params, { + headers, + }); - const { data: discordUser } = await axios.get( - 'https://discord.com/api/users/@me', - { - headers: { - Authorization: `Bearer ${authData.access_token}`, - }, - } - ); + const { data: discordUser } = await axios.get("https://discord.com/api/users/@me", { + headers: { + Authorization: `Bearer ${authData.access_token}`, + }, + }); - const discordObject = { - userId: session.user.id, - accessToken: authData.access_token, - refreshToken: authData.refresh_token, - discordId: discordUser.id, - email: discordUser.email, - avatar: discordUser.avatar, - username: discordUser.username, - globalName: discordUser.global_name, - verified: discordUser.verified, - tokenType: authData.token_type, - } as DiscordAccount; + const discordObject = { + userId: session.user.id, + accessToken: authData.access_token, + refreshToken: authData.refresh_token, + discordId: discordUser.id, + email: discordUser.email, + avatar: discordUser.avatar, + username: discordUser.username, + globalName: discordUser.global_name, + verified: discordUser.verified, + tokenType: authData.token_type, + } as DiscordAccount; - const discord = await prisma.discordAccount.upsert({ - where: { discordId: discordUser.id }, - update: discordObject, // Updates if found - create: discordObject, // Creates if not found - }); - return NextResponse.redirect( - `${process.env.NEXTAUTH_URL}/settings/account` - ); - } catch (error: any) { - console.error(error); - return NextResponse.json( - { - error: "Couldn't connect to Discord", - }, - { - status: 500, - } - ); - } + const discord = await prisma.discordAccount.upsert({ + where: { discordId: discordUser.id }, + update: discordObject, // Updates if found + create: discordObject, // Creates if not found + }); + return NextResponse.redirect(`${process.env.NEXTAUTH_URL}/settings/account`); + } catch (error: any) { + console.error(error); + return NextResponse.json( + { + error: "Couldn't connect to Discord", + }, + { + status: 500, + }, + ); + } }; diff --git a/packages/ui/src/helper/event.ts b/apps/hub/helper/events.ts similarity index 90% rename from packages/ui/src/helper/event.ts rename to apps/hub/helper/events.ts index bcc6236f..ba456620 100644 --- a/packages/ui/src/helper/event.ts +++ b/apps/hub/helper/events.ts @@ -2,8 +2,7 @@ import { Event, Participant } from "@repo/db"; export const eventCompleted = (event: Event, participant?: Participant) => { if (!participant) return false; - if (event.finisherMoodleCourseId && !participant.finisherMoodleCurseCompleted) - return false; + if (event.finisherMoodleCourseId && !participant.finisherMoodleCurseCompleted) return false; if (event.hasPresenceEvents && !participant.attended) return false; return true; }; diff --git a/packages/ui/eslint.config.mjs b/packages/ui/eslint.config.mjs deleted file mode 100644 index 19170f88..00000000 --- a/packages/ui/eslint.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import { config } from "@repo/eslint-config/react-internal"; - -/** @type {import("eslint").Linter.Config} */ -export default config; diff --git a/packages/ui/package.json b/packages/ui/package.json deleted file mode 100644 index cb47701c..00000000 --- a/packages/ui/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "@repo/ui", - "version": "0.0.0", - "private": true, - "exports": { - ".": "./src/index.ts", - "./helper": "./src/helper/index.ts" - }, - "scripts": { - "lint": "eslint . --max-warnings 0", - "generate:component": "turbo gen react-component", - "check-types": "tsc --noEmit" - }, - "devDependencies": { - "@repo/eslint-config": "*", - "@repo/db": "*", - "@repo/typescript-config": "*", - "@turbo/gen": "^1.12.4", - "@types/node": "^20.11.24", - "@types/react": "18.3.0", - "@types/react-dom": "18.3.1", - "typescript": "5.5.4" - }, - "dependencies": { - "react": "^19.0.0", - "react-dom": "^19.0.0" - } -} diff --git a/packages/ui/src/.d.ts b/packages/ui/src/.d.ts deleted file mode 100644 index 5685bb40..00000000 --- a/packages/ui/src/.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "*.png" { - const value: string; - export = value; -} diff --git a/packages/ui/src/components/Input.tsx b/packages/ui/src/components/Input.tsx deleted file mode 100644 index f104a49b..00000000 --- a/packages/ui/src/components/Input.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from "react"; -import { - FieldValues, - Path, - RegisterOptions, - UseFormReturn, -} from "react-hook-form"; -import { cn } from "../helper/cn"; - -interface InputProps - extends Omit, "form"> { - name: Path; - form: UseFormReturn; - formOptions?: RegisterOptions; - label?: string; - placeholder?: string; -} - -export const Input = ({ - name, - label = name, - placeholder = label, - form, - formOptions, - className, - ...inputProps -}: InputProps) => { - return ( - - ); -}; diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts deleted file mode 100644 index be66d766..00000000 --- a/packages/ui/src/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Input"; diff --git a/packages/ui/src/helper/cn.ts b/packages/ui/src/helper/cn.ts deleted file mode 100644 index 737e5944..00000000 --- a/packages/ui/src/helper/cn.ts +++ /dev/null @@ -1,6 +0,0 @@ -import clsx, { ClassValue } from "clsx"; -import { twMerge } from "tailwind-merge"; - -export const cn = (...inputs: ClassValue[]) => { - return twMerge(clsx(inputs)); -}; diff --git a/packages/ui/src/helper/index.ts b/packages/ui/src/helper/index.ts deleted file mode 100644 index 6bcf8f16..00000000 --- a/packages/ui/src/helper/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./event"; diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts deleted file mode 100644 index 5b89e88a..00000000 --- a/packages/ui/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./helper/event"; -export * from "./components"; diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json deleted file mode 100644 index 4fe4652a..00000000 --- a/packages/ui/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "@repo/typescript-config/react-library.json", - "compilerOptions": { - "outDir": "dist", - "allowImportingTsExtensions": false - }, - "include": ["src", "src/.d.ts"], - "exclude": ["node_modules", "dist"] -} diff --git a/packages/ui/turbo/generators/config.ts b/packages/ui/turbo/generators/config.ts deleted file mode 100644 index e51c2710..00000000 --- a/packages/ui/turbo/generators/config.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { PlopTypes } from "@turbo/gen"; - -// Learn more about Turborepo Generators at https://turbo.build/repo/docs/core-concepts/monorepos/code-generation - -export default function generator(plop: PlopTypes.NodePlopAPI): void { - // A simple generator to add a new React component to the internal UI library - plop.setGenerator("react-component", { - description: "Adds a new react component", - prompts: [ - { - type: "input", - name: "name", - message: "What is the name of the component?", - }, - ], - actions: [ - { - type: "add", - path: "src/{{kebabCase name}}.tsx", - templateFile: "templates/component.hbs", - }, - { - type: "append", - path: "package.json", - pattern: /"exports": {(?)/g, - template: ' "./{{kebabCase name}}": "./src/{{kebabCase name}}.tsx",', - }, - ], - }); -} diff --git a/packages/ui/turbo/generators/templates/component.hbs b/packages/ui/turbo/generators/templates/component.hbs deleted file mode 100644 index d968b9e3..00000000 --- a/packages/ui/turbo/generators/templates/component.hbs +++ /dev/null @@ -1,8 +0,0 @@ -export const {{ pascalCase name }} = ({ children }: { children: React.ReactNode }) => { - return ( -
-

{{ pascalCase name }} Component

- {children} -
- ); -}; diff --git a/turbo.json b/turbo.json index 341ecad3..a326738c 100644 --- a/turbo.json +++ b/turbo.json @@ -6,11 +6,11 @@ "tasks": { "generate": { "cache": false, - "persistent": true + "persistent": false }, "migrate": { "cache": false, - "persistent": true + "persistent": false }, "build": { "dependsOn": ["^build", "generate", "migrate"],