diff --git a/apps/hub/app/(app)/admin/page.tsx b/apps/hub/app/(app)/admin/page.tsx deleted file mode 100644 index cb20f8f8..00000000 --- a/apps/hub/app/(app)/admin/page.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default () => { - return
Admin Page
; -}; diff --git a/apps/hub/app/(app)/layout.tsx b/apps/hub/app/(app)/layout.tsx index efdb3bbe..d169595b 100644 --- a/apps/hub/app/(app)/layout.tsx +++ b/apps/hub/app/(app)/layout.tsx @@ -1,15 +1,15 @@ -import type { Metadata } from 'next'; +import type { Metadata } from "next"; import { DiscordLogoIcon, InstagramLogoIcon, ReaderIcon, -} from '@radix-ui/react-icons'; -import { HorizontalNav, VerticalNav } from '../_components/ui/Nav'; -import { Toaster } from 'react-hot-toast'; +} from "@radix-ui/react-icons"; +import { HorizontalNav, VerticalNav } from "../_components/ui/Nav"; +import { Toaster } from "react-hot-toast"; export const metadata: Metadata = { - title: 'Create Next App', - description: 'Generated by create next app', + title: "Create Next App", + description: "Generated by create next app", }; export default async function RootLayout({ @@ -21,8 +21,7 @@ export default async function RootLayout({
diff --git a/apps/hub/app/(app)/page.tsx b/apps/hub/app/(app)/page.tsx index 4a6b72b8..8c33e8b4 100644 --- a/apps/hub/app/(app)/page.tsx +++ b/apps/hub/app/(app)/page.tsx @@ -1,6 +1,6 @@ -import Link from 'next/link'; -import { PaginatedTable } from '../_components/PaginatedTable'; -import { Header } from '../_components/ui/Header'; +import Link from "next/link"; +import { PaginatedTable } from "../_components/PaginatedTable"; +import { Header } from "../_components/ui/Header"; export default async function Home() { return ( @@ -8,24 +8,25 @@ export default async function Home() {
diff --git a/apps/hub/app/(app)/settings/account/_components/forms.tsx b/apps/hub/app/(app)/settings/_components/forms.tsx similarity index 59% rename from apps/hub/app/(app)/settings/account/_components/forms.tsx rename to apps/hub/app/(app)/settings/_components/forms.tsx index b4701a2c..4d5fe7ec 100644 --- a/apps/hub/app/(app)/settings/account/_components/forms.tsx +++ b/apps/hub/app/(app)/settings/_components/forms.tsx @@ -1,14 +1,14 @@ -'use client'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { DiscordAccount, User } from '@repo/db'; -import { useState } from 'react'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; -import { unlinkDiscord, updateUser } from '../actions'; -import { Toaster, toast } from 'react-hot-toast'; -import { useSession } from 'next-auth/react'; -import { useRouter } from 'next/navigation'; -import { Button } from '../../../../_components/ui/Button'; +"use client"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { DiscordAccount, User } from "@repo/db"; +import { useState } from "react"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; +import { unlinkDiscord, updateUser, changePassword } from "../actions"; +import { Toaster, toast } from "react-hot-toast"; +import { useSession } from "next-auth/react"; +import { useRouter } from "next/navigation"; +import { Button } from "../../../_components/ui/Button"; import { PersonIcon, EnvelopeClosedIcon, @@ -17,14 +17,17 @@ import { PaperPlaneIcon, Link2Icon, MixerHorizontalIcon, -} from '@radix-ui/react-icons'; + LockClosedIcon, + LockOpen2Icon, + LockOpen1Icon, +} from "@radix-ui/react-icons"; export const ProfileForm = ({ user }: { user: User }) => { const schema = z.object({ firstname: z.string().min(2).max(30), lastname: z.string().min(2).max(30), email: z.string().email({ - message: 'Bitte gebe eine gültige E-Mail Adresse ein', + message: "Bitte gebe eine gültige E-Mail Adresse ein", }), }); const [isLoading, setIsLoading] = useState(false); @@ -46,12 +49,12 @@ export const ProfileForm = ({ user }: { user: User }) => { await updateUser(values); form.reset(values); setIsLoading(false); - toast.success('Deine Änderungen wurden gespeichert!', { + toast.success("Deine Änderungen wurden gespeichert!", { style: { background: - 'var(--fallback-b1, oklch(var(--b1) / var(--tw-bg-opacity, 1)))', + "var(--fallback-b1, oklch(var(--b1) / var(--tw-bg-opacity, 1)))", color: - 'var(--fallback-nc, oklch(var(--nc) / var(--tw-text-opacity, 1)))', + "var(--fallback-nc, oklch(var(--nc) / var(--tw-text-opacity, 1)))", }, }); })} @@ -67,7 +70,7 @@ export const ProfileForm = ({ user }: { user: User }) => {
{ { - Verbindung trennen{isLoading && '...'} + Verbindung trennen{isLoading && "..."} ) : ( @@ -228,7 +231,7 @@ export const SocialForm = ({ className="input input-bordered w-full" placeholder="1445241" defaultValue={user.vatsimCid as number | undefined} - {...form.register('vatsimCid', { + {...form.register("vatsimCid", { valueAsNumber: true, })} /> @@ -252,3 +255,105 @@ export const SocialForm = ({ ); }; + +export const PasswordForm = ({ user }: { user: User }) => { + const schema = z.object({ + password: z.string().min(2).max(30), + newPassword: z.string().min(2).max(30), + newPasswordConfirm: z.string().min(2).max(30), + }); + const [isLoading, setIsLoading] = useState(false); + type IFormInput = z.infer; + + const form = useForm({ + defaultValues: {}, + resolver: zodResolver(schema), + }); + return ( +
{ + setIsLoading(true); + await changePassword(values); + form.reset(values); + setIsLoading(false); + toast.success("Dein Passwort wurde geändert!", { + style: { + background: + "var(--fallback-b1, oklch(var(--b1) / var(--tw-bg-opacity, 1)))", + color: + "var(--fallback-nc, oklch(var(--nc) / var(--tw-text-opacity, 1)))", + }, + }); + })} + > +

+ Password Ändern +

+
+ + {form.formState.errors.password && ( +

{form.formState.errors.password.message}

+ )} + + {form.formState.errors.newPassword && ( +

+ {form.formState.errors.newPassword?.message} +

+ )} + + {form.formState.errors.newPasswordConfirm && ( +

+ {form.formState.errors.newPasswordConfirm?.message} +

+ )} +
+ +
+
+
+ ); +}; diff --git a/apps/hub/app/(app)/settings/account/actions.ts b/apps/hub/app/(app)/settings/actions.ts similarity index 65% rename from apps/hub/app/(app)/settings/account/actions.ts rename to apps/hub/app/(app)/settings/actions.ts index a3c6dcdc..3bfb3fc7 100644 --- a/apps/hub/app/(app)/settings/account/actions.ts +++ b/apps/hub/app/(app)/settings/actions.ts @@ -1,6 +1,6 @@ -'use server'; -import { Prisma, PrismaClient } from '@repo/db'; -import { getServerSession } from '../../../api/auth/[...nextauth]/auth'; +"use server"; +import { Prisma, PrismaClient } from "@repo/db"; +import { getServerSession } from "../../api/auth/[...nextauth]/auth"; export const unlinkDiscord = async (userId: string) => { const client = new PrismaClient(); @@ -24,3 +24,7 @@ export const updateUser = async (changes: Prisma.UserUpdateInput) => { data: changes, }); }; + +export const changePassword = async (changes: Prisma.UserUpdateInput) => { + // TODO: Add password change logic +}; diff --git a/apps/hub/app/(app)/settings/account/page.tsx b/apps/hub/app/(app)/settings/page.tsx similarity index 71% rename from apps/hub/app/(app)/settings/account/page.tsx rename to apps/hub/app/(app)/settings/page.tsx index f81673c1..adc32eb8 100644 --- a/apps/hub/app/(app)/settings/account/page.tsx +++ b/apps/hub/app/(app)/settings/page.tsx @@ -1,7 +1,7 @@ -import { getServerSession } from '../../../api/auth/[...nextauth]/auth'; -import { PrismaClient } from '@repo/db'; -import { ProfileForm, SocialForm } from './_components/forms'; -import { GearIcon } from '@radix-ui/react-icons'; +import { getServerSession } from "../../api/auth/[...nextauth]/auth"; +import { PrismaClient } from "@repo/db"; +import { ProfileForm, SocialForm, PasswordForm } from "./_components/forms"; +import { GearIcon } from "@radix-ui/react-icons"; export default async () => { const prisma = new PrismaClient(); @@ -30,6 +30,9 @@ export default async () => {
+
+ +
); }; diff --git a/apps/hub/app/(app)/settings/privacy/page.tsx b/apps/hub/app/(app)/settings/privacy/page.tsx deleted file mode 100644 index a8c6cee3..00000000 --- a/apps/hub/app/(app)/settings/privacy/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -export default () => { - return ( -
-

Settings

-

Settings page content

-
- ); -}; diff --git a/apps/hub/app/_components/ui/Nav.tsx b/apps/hub/app/_components/ui/Nav.tsx index 17090ff3..47d6475f 100644 --- a/apps/hub/app/_components/ui/Nav.tsx +++ b/apps/hub/app/_components/ui/Nav.tsx @@ -4,8 +4,8 @@ import { GearIcon, ExitIcon, LockClosedIcon, -} from '@radix-ui/react-icons'; -import Link from 'next/link'; +} from "@radix-ui/react-icons"; +import Link from "next/link"; export const VerticalNav = () => { return ( @@ -38,7 +38,7 @@ export const VerticalNav = () => {
  • - + Einstellungen diff --git a/apps/hub/public/bg.png b/apps/hub/public/bg.png new file mode 100644 index 00000000..de32b8c6 Binary files /dev/null and b/apps/hub/public/bg.png differ