From c8d91b684fc9fa63127ad0330f4790d63ec3129a Mon Sep 17 00:00:00 2001 From: PxlLoewe <72106766+PxlLoewe@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:04:15 -0700 Subject: [PATCH] Error boundary --- .../hub/app/(app)/admin/keyword/[id]/page.tsx | 20 +- .../(app)/admin/keyword/_components/Form.tsx | 211 ++++-------------- apps/hub/app/(app)/admin/keyword/action.ts | 20 +- apps/hub/app/(app)/admin/keyword/layout.tsx | 2 +- apps/hub/app/(app)/admin/keyword/new/page.tsx | 4 +- apps/hub/app/(app)/admin/keyword/page.tsx | 84 ++++--- .../(app)/admin/station/_components/Form.tsx | 26 ++- apps/hub/app/(auth)/layout.tsx | 31 ++- .../app/(auth)/login/_components/Login.tsx | 39 ++-- .../(auth)/oauth/_components/Authorize.tsx | 22 +- .../_components/PasswortReset.tsx | 97 ++++++++ apps/hub/app/(auth)/passwort-reset/action.ts | 42 ++++ apps/hub/app/(auth)/passwort-reset/page.tsx | 9 + .../(auth)/register/_components/Register.tsx | 34 +-- apps/hub/app/_components/Error.tsx | 33 ++- apps/hub/app/_components/Nav.tsx | 3 + apps/hub/package.json | 1 + grafana/grafana.db | Bin 1122304 -> 1122304 bytes package-lock.json | 13 ++ .../database/prisma/schema/keyword.prisma | 20 +- packages/database/prisma/schema/user.prisma | 1 + 21 files changed, 414 insertions(+), 298 deletions(-) create mode 100644 apps/hub/app/(auth)/passwort-reset/_components/PasswortReset.tsx create mode 100644 apps/hub/app/(auth)/passwort-reset/action.ts create mode 100644 apps/hub/app/(auth)/passwort-reset/page.tsx diff --git a/apps/hub/app/(app)/admin/keyword/[id]/page.tsx b/apps/hub/app/(app)/admin/keyword/[id]/page.tsx index 399adf90..7cfeaf45 100644 --- a/apps/hub/app/(app)/admin/keyword/[id]/page.tsx +++ b/apps/hub/app/(app)/admin/keyword/[id]/page.tsx @@ -1,13 +1,13 @@ -import { prisma } from '@repo/db'; -import { StationForm } from '../_components/Form'; +import { prisma } from "@repo/db"; +import { KeywordForm } from "../_components/Form"; export default async ({ params }: { params: Promise<{ id: string }> }) => { - const { id } = await params; - const station = await prisma.station.findUnique({ - where: { - id: parseInt(id), - }, - }); - if (!station) return
Station not found
; - return ; + const { id } = await params; + const keyword = await prisma.keyword.findUnique({ + where: { + id: parseInt(id), + }, + }); + if (!keyword) return
Station not found
; + return ; }; diff --git a/apps/hub/app/(app)/admin/keyword/_components/Form.tsx b/apps/hub/app/(app)/admin/keyword/_components/Form.tsx index c604dfa9..e54d0189 100644 --- a/apps/hub/app/(app)/admin/keyword/_components/Form.tsx +++ b/apps/hub/app/(app)/admin/keyword/_components/Form.tsx @@ -1,20 +1,20 @@ "use client"; import { zodResolver } from "@hookform/resolvers/zod"; -import { StationOptionalDefaultsSchema } from "@repo/db/zod"; +import { KeywordOptionalDefaultsSchema } from "@repo/db/zod"; import { set, useForm } from "react-hook-form"; import { z } from "zod"; -import { BosUse, Country, Station } from "@repo/db"; +import { BosUse, Country, KEYWORD_CATEGORY, Keyword } from "@repo/db"; import { FileText, LocateIcon, PlaneIcon } from "lucide-react"; import { Input } from "../../../../_components/ui/Input"; import { useState } from "react"; -import { deleteStation, upsertStation } from "../action"; +import { deleteKeyword, upsertKeyword } from "../action"; import { Button } from "../../../../_components/ui/Button"; import { redirect } from "next/navigation"; -export const StationForm = ({ station }: { station?: Station }) => { - const form = useForm>({ - resolver: zodResolver(StationOptionalDefaultsSchema), - defaultValues: station, +export const KeywordForm = ({ keyword }: { keyword?: Keyword }) => { + const form = useForm>({ + resolver: zodResolver(KeywordOptionalDefaultsSchema), + defaultValues: keyword, }); const [loading, setLoading] = useState(false); const [deleteLoading, setDeleteLoading] = useState(false); @@ -23,85 +23,26 @@ export const StationForm = ({ station }: { station?: Station }) => {
{ setLoading(true); - const createdStation = await upsertStation(values, station?.id); + const createdKeyword = await upsertKeyword(values, keyword?.id); setLoading(false); - if (!station) redirect(`/admin/station`); + if (!keyword) redirect(`/admin/keyword`); })} className="grid grid-cols-6 gap-3" > -
+

Allgemeines

- - - - - - - -
-
-
-
-

- Standort + Ausrüstung -

-
+
- - - -
- -
-
-

- Hubschrauber -

- - - -
-
@@ -223,13 +88,13 @@ export const StationForm = ({ station }: { station?: Station }) => { > Speichern - {station && ( + {keyword && ( - -

- } - /> - - ); + return ( + <> + + Stichwörter + + } + rightOfSearch={ +

+ + + +

+ } + /> + + ); }; diff --git a/apps/hub/app/(app)/admin/station/_components/Form.tsx b/apps/hub/app/(app)/admin/station/_components/Form.tsx index c604dfa9..0cf23c93 100644 --- a/apps/hub/app/(app)/admin/station/_components/Form.tsx +++ b/apps/hub/app/(app)/admin/station/_components/Form.tsx @@ -123,33 +123,35 @@ export const StationForm = ({ station }: { station?: Station }) => { Ausgerüstet mit: -
-