From e4072b0c12d5b2f374c6fd508df62976b4c1c5b3 Mon Sep 17 00:00:00 2001 From: Aimsucks Date: Sat, 5 Oct 2024 16:43:04 -0400 Subject: [PATCH] chore(formatting): order imports with prettier --- .github/workflows/deploy.yml | 2 +- .prettierrc.json | 23 +- TODO.md | 46 +- app/_actions/category.ts | 9 +- app/_actions/plugin.ts | 6 +- app/_actions/preset.ts | 9 +- app/api/v1/plugins/[slug]/presets/route.ts | 1 + app/api/v1/plugins/[slug]/route.ts | 1 + app/api/v1/plugins/[slug]/updates/route.ts | 1 + app/layout.tsx | 9 +- .../[slug]/_components/PresetBrowser.tsx | 7 +- .../[slug]/_components/_info/PluginButton.tsx | 7 +- .../_components/_info/PluginButtonRow.tsx | 7 +- .../_components/_info/PluginEditButton.tsx | 3 +- .../[slug]/_components/_info/PluginEditor.tsx | 29 +- .../_components/_info/PluginEditorWrapper.tsx | 5 +- .../[slug]/_components/_info/PluginInfo.tsx | 13 +- .../[slug]/_components/_list/CategoryList.tsx | 12 +- .../_components/_list/CategoryListItem.tsx | 7 +- .../_components/_list/PresetListItem.tsx | 5 +- .../_viewer/CategoryItemViewer.tsx | 38 +- .../_components/_viewer/ListItemViewer.tsx | 6 +- .../_components/_viewer/PresetItemViewer.tsx | 30 +- app/plugins/[slug]/page.tsx | 10 +- auth.config.ts | 2 +- auth.ts | 5 +- components/auth/SessionWrapper.tsx | 1 - components/auth/SignIn.tsx | 1 + components/auth/SignOut.tsx | 1 + components/base/HeaderBar.tsx | 5 +- components/home/PluginCard.tsx | 12 +- components/home/PluginList.tsx | 3 +- components/shared/buttons/Add.tsx | 3 +- components/shared/buttons/Cancel.tsx | 3 +- components/shared/buttons/ConfirmDelete.tsx | 3 +- components/shared/buttons/Copy.tsx | 3 +- components/shared/buttons/Edit.tsx | 3 +- components/shared/buttons/Save.tsx | 3 +- components/ui/avatar.tsx | 2 +- components/ui/badge.tsx | 2 +- components/ui/button.tsx | 2 +- components/ui/command.tsx | 246 +- components/ui/dialog.tsx | 192 +- components/ui/form.tsx | 276 +- components/ui/label.tsx | 36 +- components/ui/multi-select.tsx | 1 + components/ui/popover.tsx | 48 +- components/ui/separator.tsx | 2 +- components/ui/tooltip.tsx | 2 +- lib/s3-file-management.ts | 3 +- lib/utils.ts | 2 +- middleware.ts | 1 + package.json | 127 +- pnpm-lock.yaml | 13312 +++++++++------- tsconfig.json | 21 +- 55 files changed, 8416 insertions(+), 6193 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 67c6fd0..68c2e14 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,7 +55,7 @@ jobs: uses: SethCohen/github-releases-to-discord@v1.13.1 with: webhook_url: ${{ secrets.RELEASE_WEBHOOK_URL }} - color: "2125803" + color: '2125803' pull-and-start-container: needs: build-and-push-image diff --git a/.prettierrc.json b/.prettierrc.json index 59a86df..d5dcd20 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -4,5 +4,26 @@ "tabWidth": 4, "singleQuote": true, "jsxSingleQuote": true, - "plugins": ["prettier-plugin-tailwindcss"] + "plugins": [ + "prettier-plugin-tailwindcss", + "@ianvs/prettier-plugin-sort-imports" + ], + "importOrder": [ + "", + "", + "", + "", + "^@/prisma$", + "^@prisma/(.*)$", + "", + "^@/app/(.*)$", + "", + "^@/components/(.*)$", + "", + "^@/lib/(.*)$", + "", + "^[./]" + ], + "importOrderParserPlugins": ["typescript", "jsx", "decorators-legacy"], + "importOrderTypeScriptVersion": "5.0.0" } diff --git a/TODO.md b/TODO.md index f91a3cc..3edc37b 100644 --- a/TODO.md +++ b/TODO.md @@ -2,35 +2,35 @@ ## Short-term -- Add pending/loading to the plugin editing form +- Add pending/loading to the plugin editing form ## Medium-term -- Fix the development environment to actually function on a computer instead of relying on my home server. -- To solve some of the errors during build when no database is - available: https://www.reddit.com/r/nextjs/comments/16yh4xs/will_nextjs_always_require_database_access_at/ -- Integrate https://trpc.io/, check T3 stack docs: https://create.t3.gg/en/introduction -- Add "pluginOwner" to UserPlugin table to prevent a user from deleting themselves when editing plugin permissions. -- Give preset descriptions markdown and multi-line support. -- Provide an endpoint to check for "any presets updated since XYZ date" so plugins can store a date and feed it into the - API if they want to present users a list of the updated presets since their last visit. -- Provide an update endpoint that receives preset IDs and version numbers for each one, so I can do the version check - processing on my end, saving bandwidth for plugins that have _a lot_ of presets. -- Mimic the functionality of the GitHub file browser for presets so there can be descriptions, separators, and ordering, - for categories, subcategories, presets, etc. -- Add loading to most of the buttons. +- Fix the development environment to actually function on a computer instead of relying on my home server. +- To solve some of the errors during build when no database is + available: https://www.reddit.com/r/nextjs/comments/16yh4xs/will_nextjs_always_require_database_access_at/ +- Integrate https://trpc.io/, check T3 stack docs: https://create.t3.gg/en/introduction +- Add "pluginOwner" to UserPlugin table to prevent a user from deleting themselves when editing plugin permissions. +- Give preset descriptions markdown and multi-line support. +- Provide an endpoint to check for "any presets updated since XYZ date" so plugins can store a date and feed it into the + API if they want to present users a list of the updated presets since their last visit. +- Provide an update endpoint that receives preset IDs and version numbers for each one, so I can do the version check + processing on my end, saving bandwidth for plugins that have _a lot_ of presets. +- Mimic the functionality of the GitHub file browser for presets so there can be descriptions, separators, and ordering, + for categories, subcategories, presets, etc. +- Add loading to most of the buttons. ## Long-term -- Change the versioning model to support rolling back presets or selecting a preset version when importing. This would - have to change either the way presets are unique inside the presets table or it would mean a new table has to be - created to store the preset versions. This might be better to implement only on the web UI considering it would be - annoying to implement in-game. -- Add permissions per-preset and per-category so plugin authors can determine who can edit their presets. +- Change the versioning model to support rolling back presets or selecting a preset version when importing. This would + have to change either the way presets are unique inside the presets table or it would mean a new table has to be + created to store the preset versions. This might be better to implement only on the web UI considering it would be + annoying to implement in-game. +- Add permissions per-preset and per-category so plugin authors can determine who can edit their presets. ## Setup Documentation -- Traefik -- PostgreSQL should basically set itself up -- Minio needs a bucket created from admin panel - - Also needs an access key and secret key generated \ No newline at end of file +- Traefik +- PostgreSQL should basically set itself up +- Minio needs a bucket created from admin panel + - Also needs an access key and secret key generated diff --git a/app/_actions/category.ts b/app/_actions/category.ts index b08c041..8f944c3 100644 --- a/app/_actions/category.ts +++ b/app/_actions/category.ts @@ -1,12 +1,15 @@ 'use server'; -import { Session } from 'next-auth'; import { auth } from '@/auth'; -import { checkUserCanEditPlugin } from '@/lib/authentication'; -import { prisma } from '@/prisma'; +import { Session } from 'next-auth'; import { revalidatePath } from 'next/cache'; + +import { prisma } from '@/prisma'; + import { categoryFormSchema } from '@/app/_validation/category'; +import { checkUserCanEditPlugin } from '@/lib/authentication'; + export type FormState = { message: string; error?: boolean; diff --git a/app/_actions/plugin.ts b/app/_actions/plugin.ts index d4e1e31..8ac7d8b 100644 --- a/app/_actions/plugin.ts +++ b/app/_actions/plugin.ts @@ -1,20 +1,20 @@ 'use server'; +import { auth } from '@/auth'; import mime from 'mime'; - import { Session } from 'next-auth'; import { revalidatePath } from 'next/cache'; +import { z } from 'zod'; -import { auth } from '@/auth'; import { prisma } from '@/prisma'; import { pluginPermissionsOptionSchema, pluginUpdateFormSchema, } from '@/app/_validation/plugin'; + import { checkUserCanEditPlugin } from '@/lib/authentication'; import { saveFileInBucket } from '@/lib/s3-file-management'; -import { z } from 'zod'; export type FormState = { message: string; diff --git a/app/_actions/preset.ts b/app/_actions/preset.ts index 7b76725..34f931c 100644 --- a/app/_actions/preset.ts +++ b/app/_actions/preset.ts @@ -1,11 +1,14 @@ 'use server'; -import { Session } from 'next-auth'; import { auth } from '@/auth'; -import { checkUserCanEditPlugin } from '@/lib/authentication'; +import { Session } from 'next-auth'; +import { revalidatePath } from 'next/cache'; + import { prisma } from '@/prisma'; + import { presetFormSchema } from '@/app/_validation/preset'; -import { revalidatePath } from 'next/cache'; + +import { checkUserCanEditPlugin } from '@/lib/authentication'; export type FormState = { message: string; diff --git a/app/api/v1/plugins/[slug]/presets/route.ts b/app/api/v1/plugins/[slug]/presets/route.ts index e41ef9d..1dff9df 100644 --- a/app/api/v1/plugins/[slug]/presets/route.ts +++ b/app/api/v1/plugins/[slug]/presets/route.ts @@ -1,4 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; + import { prisma } from '@/prisma'; export async function GET( diff --git a/app/api/v1/plugins/[slug]/route.ts b/app/api/v1/plugins/[slug]/route.ts index d091023..1d735c5 100644 --- a/app/api/v1/plugins/[slug]/route.ts +++ b/app/api/v1/plugins/[slug]/route.ts @@ -1,4 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; + import { prisma } from '@/prisma'; import { Plugin } from '@prisma/client'; diff --git a/app/api/v1/plugins/[slug]/updates/route.ts b/app/api/v1/plugins/[slug]/updates/route.ts index 90aec85..29bed73 100644 --- a/app/api/v1/plugins/[slug]/updates/route.ts +++ b/app/api/v1/plugins/[slug]/updates/route.ts @@ -1,4 +1,5 @@ import { NextRequest, NextResponse } from 'next/server'; + import { prisma } from '@/prisma'; export async function GET( diff --git a/app/layout.tsx b/app/layout.tsx index f4b3ecb..5a32818 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,12 +1,17 @@ import type { Metadata, Viewport } from 'next'; import { Inter as FontSans } from 'next/font/google'; + import { cn } from '@/lib/utils'; + import './globals.css'; -import SessionWrapper from '@/components/auth/SessionWrapper'; + +import { config } from '@fortawesome/fontawesome-svg-core'; import { NextIntlClientProvider } from 'next-intl'; import { getLocale, getMessages } from 'next-intl/server'; + +import SessionWrapper from '@/components/auth/SessionWrapper'; import TopBar from '@/components/base/HeaderBar'; -import { config } from '@fortawesome/fontawesome-svg-core'; + import '@fortawesome/fontawesome-svg-core/styles.css'; const fontSans = FontSans({ diff --git a/app/plugins/[slug]/_components/PresetBrowser.tsx b/app/plugins/[slug]/_components/PresetBrowser.tsx index bc2607f..29b900d 100644 --- a/app/plugins/[slug]/_components/PresetBrowser.tsx +++ b/app/plugins/[slug]/_components/PresetBrowser.tsx @@ -1,9 +1,12 @@ 'use client'; -import CategoryList from '@/app/plugins/[slug]/_components/_list/CategoryList'; -import ListItemViewer from '@/app/plugins/[slug]/_components/_viewer/ListItemViewer'; import { useState } from 'react'; + import { PluginType } from '@/prisma'; + +import CategoryList from '@/app/plugins/[slug]/_components/_list/CategoryList'; +import ListItemViewer from '@/app/plugins/[slug]/_components/_viewer/ListItemViewer'; + import { ItemViewerType, UserPermissionsType } from '@/lib/definitions'; type PresetBrowserProps = { diff --git a/app/plugins/[slug]/_components/_info/PluginButton.tsx b/app/plugins/[slug]/_components/_info/PluginButton.tsx index 14e3d31..e6c5751 100644 --- a/app/plugins/[slug]/_components/_info/PluginButton.tsx +++ b/app/plugins/[slug]/_components/_info/PluginButton.tsx @@ -1,8 +1,9 @@ -import React from 'react'; -import Link from 'next/link'; -import { Button } from '@/components/ui/button'; import { IconDefinition } from '@fortawesome/free-brands-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import Link from 'next/link'; +import React from 'react'; + +import { Button } from '@/components/ui/button'; interface PluginButtonProps { icon: IconDefinition; diff --git a/app/plugins/[slug]/_components/_info/PluginButtonRow.tsx b/app/plugins/[slug]/_components/_info/PluginButtonRow.tsx index 6c49d00..b8bbda5 100644 --- a/app/plugins/[slug]/_components/_info/PluginButtonRow.tsx +++ b/app/plugins/[slug]/_components/_info/PluginButtonRow.tsx @@ -1,10 +1,13 @@ -import React from 'react'; import { faDiscord, faGithub } from '@fortawesome/free-brands-svg-icons'; +import React from 'react'; + import { PluginType } from '@/prisma'; + import PluginButton from '@/app/plugins/[slug]/_components/_info/PluginButton'; -import { UserPermissionsType } from '@/lib/definitions'; import PluginEditButton from '@/app/plugins/[slug]/_components/_info/PluginEditButton'; +import { UserPermissionsType } from '@/lib/definitions'; + type PluginButtonRowProps = { plugin: PluginType; userPermissions: UserPermissionsType; diff --git a/app/plugins/[slug]/_components/_info/PluginEditButton.tsx b/app/plugins/[slug]/_components/_info/PluginEditButton.tsx index 1887788..25c2242 100644 --- a/app/plugins/[slug]/_components/_info/PluginEditButton.tsx +++ b/app/plugins/[slug]/_components/_info/PluginEditButton.tsx @@ -1,8 +1,9 @@ 'use client'; +import { faEdit } from '@fortawesome/free-regular-svg-icons'; + import PluginButton from '@/app/plugins/[slug]/_components/_info/PluginButton'; import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext'; -import { faEdit } from '@fortawesome/free-regular-svg-icons'; export default function PluginEditButton() { const { isPluginEditorOpen, setIsPluginEditorOpen } = usePluginContext(); diff --git a/app/plugins/[slug]/_components/_info/PluginEditor.tsx b/app/plugins/[slug]/_components/_info/PluginEditor.tsx index 1d6b6f7..ac526a9 100644 --- a/app/plugins/[slug]/_components/_info/PluginEditor.tsx +++ b/app/plugins/[slug]/_components/_info/PluginEditor.tsx @@ -1,6 +1,19 @@ -import { Textarea } from '@/components/ui/textarea'; -import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { SaveIcon, XCircle } from 'lucide-react'; +import { useSession } from 'next-auth/react'; +import { useRef } from 'react'; +import { useFormState } from 'react-dom'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; + +import { PluginType, UserPluginType } from '@/prisma'; import { User } from '@prisma/client'; + +import { updatePluginAction } from '@/app/_actions/plugin'; +import { pluginUpdateFormSchema } from '@/app/_validation/plugin'; +import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext'; + +import { Button } from '@/components/ui/button'; import { Form, FormControl, @@ -9,19 +22,9 @@ import { FormLabel, FormMessage, } from '@/components/ui/form'; -import { useForm } from 'react-hook-form'; -import { zodResolver } from '@hookform/resolvers/zod'; import { Input } from '@/components/ui/input'; import MultipleSelector, { Option } from '@/components/ui/multi-select'; -import { Button } from '@/components/ui/button'; -import { SaveIcon, XCircle } from 'lucide-react'; -import { useRef } from 'react'; -import { pluginUpdateFormSchema } from '@/app/_validation/plugin'; -import { z } from 'zod'; -import { useFormState } from 'react-dom'; -import { updatePluginAction } from '@/app/_actions/plugin'; -import { useSession } from 'next-auth/react'; -import { PluginType, UserPluginType } from '@/prisma'; +import { Textarea } from '@/components/ui/textarea'; type PluginEditorProps = { plugin: PluginType; diff --git a/app/plugins/[slug]/_components/_info/PluginEditorWrapper.tsx b/app/plugins/[slug]/_components/_info/PluginEditorWrapper.tsx index 831937b..684901a 100644 --- a/app/plugins/[slug]/_components/_info/PluginEditorWrapper.tsx +++ b/app/plugins/[slug]/_components/_info/PluginEditorWrapper.tsx @@ -1,10 +1,11 @@ 'use client'; -import PluginEditor from '@/app/plugins/[slug]/_components/_info/PluginEditor'; -import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext'; import { PluginType } from '@/prisma'; import { User } from '@prisma/client'; +import PluginEditor from '@/app/plugins/[slug]/_components/_info/PluginEditor'; +import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext'; + type PluginEditorWrapperProps = { plugin: PluginType; users: User[]; diff --git a/app/plugins/[slug]/_components/_info/PluginInfo.tsx b/app/plugins/[slug]/_components/_info/PluginInfo.tsx index e248571..6417218 100644 --- a/app/plugins/[slug]/_components/_info/PluginInfo.tsx +++ b/app/plugins/[slug]/_components/_info/PluginInfo.tsx @@ -1,12 +1,15 @@ -import Image from 'next/image'; import { BookText, Clock, Sparkles } from 'lucide-react'; +import { getFormatter } from 'next-intl/server'; +import Image from 'next/image'; + import { PluginType, prisma } from '@/prisma'; -import { UserPermissionsType } from '@/lib/definitions'; -import PluginFact from '@/app/plugins/[slug]/_components/_info/PluginFact'; +import { User } from '@prisma/client'; + import PluginButtonRow from '@/app/plugins/[slug]/_components/_info/PluginButtonRow'; import PluginEditorWrapper from '@/app/plugins/[slug]/_components/_info/PluginEditorWrapper'; -import { getFormatter } from 'next-intl/server'; -import { User } from '@prisma/client'; +import PluginFact from '@/app/plugins/[slug]/_components/_info/PluginFact'; + +import { UserPermissionsType } from '@/lib/definitions'; type PluginInfoProps = { plugin: PluginType; diff --git a/app/plugins/[slug]/_components/_list/CategoryList.tsx b/app/plugins/[slug]/_components/_list/CategoryList.tsx index 48d9135..133343a 100644 --- a/app/plugins/[slug]/_components/_list/CategoryList.tsx +++ b/app/plugins/[slug]/_components/_list/CategoryList.tsx @@ -1,8 +1,12 @@ -import { Category, Preset } from '@prisma/client'; import { useState } from 'react'; -import PresetListItem from '@/app/plugins/[slug]/_components/_list/PresetListItem'; + +import { Category, Preset } from '@prisma/client'; + import CategoryListItem from '@/app/plugins/[slug]/_components/_list/CategoryListItem'; +import PresetListItem from '@/app/plugins/[slug]/_components/_list/PresetListItem'; + import Add from '@/components/shared/buttons/Add'; + import { ItemViewerType, UserPermissionsType } from '@/lib/definitions'; type CategoryListProps = { @@ -51,9 +55,7 @@ export default function CategoryList({ - onItemOpen({ categoryId: 0, newCategory: true }) - } + onClick={() => onItemOpen({ categoryId: 0 })} /> )} diff --git a/app/plugins/[slug]/_components/_list/CategoryListItem.tsx b/app/plugins/[slug]/_components/_list/CategoryListItem.tsx index b1cb09b..20563f0 100644 --- a/app/plugins/[slug]/_components/_list/CategoryListItem.tsx +++ b/app/plugins/[slug]/_components/_list/CategoryListItem.tsx @@ -1,7 +1,10 @@ -import { Category, Preset } from '@prisma/client'; import { ChevronUp, ExternalLink } from 'lucide-react'; -import { Button } from '@/components/ui/button'; + +import { Category, Preset } from '@prisma/client'; + import Add from '@/components/shared/buttons/Add'; +import { Button } from '@/components/ui/button'; + import { ItemViewerType, UserPermissionsType } from '@/lib/definitions'; type CategoryProps = { diff --git a/app/plugins/[slug]/_components/_list/PresetListItem.tsx b/app/plugins/[slug]/_components/_list/PresetListItem.tsx index df5af37..acb7e9b 100644 --- a/app/plugins/[slug]/_components/_list/PresetListItem.tsx +++ b/app/plugins/[slug]/_components/_list/PresetListItem.tsx @@ -1,6 +1,9 @@ +import { ExternalLink } from 'lucide-react'; + import { Preset } from '@prisma/client'; + import { Button } from '@/components/ui/button'; -import { ExternalLink } from 'lucide-react'; + import { ItemViewerType } from '@/lib/definitions'; type PresetListItemProps = { diff --git a/app/plugins/[slug]/_components/_viewer/CategoryItemViewer.tsx b/app/plugins/[slug]/_components/_viewer/CategoryItemViewer.tsx index 2a6db26..bda8d18 100644 --- a/app/plugins/[slug]/_components/_viewer/CategoryItemViewer.tsx +++ b/app/plugins/[slug]/_components/_viewer/CategoryItemViewer.tsx @@ -1,12 +1,25 @@ +import { zodResolver } from '@hookform/resolvers/zod'; +import { useRef, useState } from 'react'; +import { useFormState } from 'react-dom'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; + +import { PluginType } from '@/prisma'; import { Preset } from '@prisma/client'; + +import { + createCategoryAction, + deleteCategoryAction, + updateCategoryAction, +} from '@/app/_actions/category'; +import { categoryFormSchema } from '@/app/_validation/category'; import PresetItemViewer from '@/app/plugins/[slug]/_components/_viewer/PresetItemViewer'; -import { Separator } from '@/components/ui/separator'; -import { PluginType } from '@/prisma'; -import { ItemViewerType, UserPermissionsType } from '@/lib/definitions'; -import { useRef, useState } from 'react'; + import Add from '@/components/shared/buttons/Add'; -import Edit from '@/components/shared/buttons/Edit'; +import Cancel from '@/components/shared/buttons/Cancel'; import ConfirmDelete from '@/components/shared/buttons/ConfirmDelete'; +import Edit from '@/components/shared/buttons/Edit'; +import Save from '@/components/shared/buttons/Save'; import { Form, FormControl, @@ -15,18 +28,9 @@ import { FormMessage, } from '@/components/ui/form'; import { Input } from '@/components/ui/input'; -import Save from '@/components/shared/buttons/Save'; -import Cancel from '@/components/shared/buttons/Cancel'; -import { - createCategoryAction, - deleteCategoryAction, - updateCategoryAction, -} from '@/app/_actions/category'; -import { useFormState } from 'react-dom'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { categoryFormSchema } from '@/app/_validation/category'; +import { Separator } from '@/components/ui/separator'; + +import { ItemViewerType, UserPermissionsType } from '@/lib/definitions'; type CategoryViewerProps = { categoryId: number; diff --git a/app/plugins/[slug]/_components/_viewer/ListItemViewer.tsx b/app/plugins/[slug]/_components/_viewer/ListItemViewer.tsx index bf497f5..7b5dc2b 100644 --- a/app/plugins/[slug]/_components/_viewer/ListItemViewer.tsx +++ b/app/plugins/[slug]/_components/_viewer/ListItemViewer.tsx @@ -1,7 +1,9 @@ -import PresetItemViewer from '@/app/plugins/[slug]/_components/_viewer/PresetItemViewer'; +import { PluginType } from '@/prisma'; + import CategoryItemViewer from '@/app/plugins/[slug]/_components/_viewer/CategoryItemViewer'; +import PresetItemViewer from '@/app/plugins/[slug]/_components/_viewer/PresetItemViewer'; + import { ItemViewerType, UserPermissionsType } from '@/lib/definitions'; -import { PluginType } from '@/prisma'; type ItemViewerProps = { item: ItemViewerType | null; diff --git a/app/plugins/[slug]/_components/_viewer/PresetItemViewer.tsx b/app/plugins/[slug]/_components/_viewer/PresetItemViewer.tsx index 002a191..cb8dfec 100644 --- a/app/plugins/[slug]/_components/_viewer/PresetItemViewer.tsx +++ b/app/plugins/[slug]/_components/_viewer/PresetItemViewer.tsx @@ -1,20 +1,25 @@ +import { zodResolver } from '@hookform/resolvers/zod'; import { useFormatter } from 'next-intl'; -import { Badge } from '@/components/ui/badge'; -import { Textarea } from '@/components/ui/textarea'; -import { UserPermissionsType } from '@/lib/definitions'; -import { PluginType } from '@/prisma'; +import { useRef, useState } from 'react'; import { useFormState } from 'react-dom'; +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; + +import { PluginType } from '@/prisma'; +import { Preset } from '@prisma/client'; + import { createPresetAction, deletePresetAction, updatePresetAction, } from '@/app/_actions/preset'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; -import { zodResolver } from '@hookform/resolvers/zod'; import { presetFormSchema } from '@/app/_validation/preset'; -import { useRef, useState } from 'react'; -import { Preset } from '@prisma/client'; + +import Cancel from '@/components/shared/buttons/Cancel'; +import ConfirmDelete from '@/components/shared/buttons/ConfirmDelete'; +import Edit from '@/components/shared/buttons/Edit'; +import Save from '@/components/shared/buttons/Save'; +import { Badge } from '@/components/ui/badge'; import { Form, FormControl, @@ -23,10 +28,9 @@ import { FormMessage, } from '@/components/ui/form'; import { Input } from '@/components/ui/input'; -import Save from '@/components/shared/buttons/Save'; -import Cancel from '@/components/shared/buttons/Cancel'; -import Edit from '@/components/shared/buttons/Edit'; -import ConfirmDelete from '@/components/shared/buttons/ConfirmDelete'; +import { Textarea } from '@/components/ui/textarea'; + +import { UserPermissionsType } from '@/lib/definitions'; type PresetViewerProps = { presetId: number; diff --git a/app/plugins/[slug]/page.tsx b/app/plugins/[slug]/page.tsx index 6ca0d5f..e2b11ed 100644 --- a/app/plugins/[slug]/page.tsx +++ b/app/plugins/[slug]/page.tsx @@ -1,10 +1,12 @@ -import { PluginProvider } from '@/app/plugins/[slug]/_components/PluginContext'; -import PresetBrowser from '@/app/plugins/[slug]/_components/PresetBrowser'; -import Image from 'next/image'; -import { PluginType, prisma, UserType } from '@/prisma'; import { auth } from '@/auth'; import { Session } from 'next-auth'; +import Image from 'next/image'; + +import { PluginType, prisma, UserType } from '@/prisma'; + import PluginInfo from '@/app/plugins/[slug]/_components/_info/PluginInfo'; +import { PluginProvider } from '@/app/plugins/[slug]/_components/PluginContext'; +import PresetBrowser from '@/app/plugins/[slug]/_components/PresetBrowser'; type PluginPageProps = { params: { slug: string }; diff --git a/auth.config.ts b/auth.config.ts index 8e612eb..57c483a 100644 --- a/auth.config.ts +++ b/auth.config.ts @@ -1,5 +1,5 @@ -import Discord from 'next-auth/providers/discord'; import type { NextAuthConfig } from 'next-auth'; +import Discord from 'next-auth/providers/discord'; export default { providers: [ diff --git a/auth.ts b/auth.ts index bf41bd9..39316eb 100644 --- a/auth.ts +++ b/auth.ts @@ -1,9 +1,10 @@ +import { PrismaAdapter } from '@auth/prisma-adapter'; import NextAuth, { DefaultSession } from 'next-auth'; -import authConfig from './auth.config'; -import { PrismaAdapter } from '@auth/prisma-adapter'; import { prisma } from '@/prisma'; +import authConfig from './auth.config'; + declare module 'next-auth' { interface User { isAdmin?: boolean; diff --git a/components/auth/SessionWrapper.tsx b/components/auth/SessionWrapper.tsx index 4a4e390..ae8ac37 100644 --- a/components/auth/SessionWrapper.tsx +++ b/components/auth/SessionWrapper.tsx @@ -1,7 +1,6 @@ 'use client'; import { SessionProvider } from 'next-auth/react'; - import React from 'react'; const SessionWrapper = ({ children }: { children: React.ReactNode }) => { diff --git a/components/auth/SignIn.tsx b/components/auth/SignIn.tsx index 6f51f47..4537f51 100644 --- a/components/auth/SignIn.tsx +++ b/components/auth/SignIn.tsx @@ -1,4 +1,5 @@ import { signIn } from '@/auth'; + import { Button } from '@/components/ui/button'; export default function SignIn() { diff --git a/components/auth/SignOut.tsx b/components/auth/SignOut.tsx index df1a5b6..d6a1e56 100644 --- a/components/auth/SignOut.tsx +++ b/components/auth/SignOut.tsx @@ -1,4 +1,5 @@ import { signOut } from '@/auth'; + import { Button } from '@/components/ui/button'; export default function SignOut() { diff --git a/components/base/HeaderBar.tsx b/components/base/HeaderBar.tsx index 5c57a1e..9e086ee 100644 --- a/components/base/HeaderBar.tsx +++ b/components/base/HeaderBar.tsx @@ -1,9 +1,10 @@ import { auth } from '@/auth'; import Image from 'next/image'; -import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import Link from 'next/link'; + import SignIn from '@/components/auth/SignIn'; import SignOut from '@/components/auth/SignOut'; -import Link from 'next/link'; +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; export default async function TopBar() { const session = await auth(); diff --git a/components/home/PluginCard.tsx b/components/home/PluginCard.tsx index bb1a742..d6b617c 100644 --- a/components/home/PluginCard.tsx +++ b/components/home/PluginCard.tsx @@ -1,3 +1,10 @@ +import { BookText, Clock, Sparkles } from 'lucide-react'; +import { useFormatter } from 'next-intl'; +import Image from 'next/image'; +import Link from 'next/link'; + +import type { Plugin, Preset } from '@prisma/client'; + import { Card, CardContent, @@ -5,11 +12,6 @@ import { CardHeader, CardTitle, } from '@/components/ui/card'; -import type { Plugin, Preset } from '@prisma/client'; -import { BookText, Clock, Sparkles } from 'lucide-react'; -import { useFormatter } from 'next-intl'; -import Image from 'next/image'; -import Link from 'next/link'; type PluginCardProps = { plugin: Plugin & { presets: Partial[] }; diff --git a/components/home/PluginList.tsx b/components/home/PluginList.tsx index 4fee141..b0a0175 100644 --- a/components/home/PluginList.tsx +++ b/components/home/PluginList.tsx @@ -1,7 +1,8 @@ import { prisma } from '@/prisma'; -import PluginCard from '@/components/home/PluginCard'; import { Plugin, Preset } from '@prisma/client'; +import PluginCard from '@/components/home/PluginCard'; + export default async function PluginList() { const plugins: (Plugin & { presets: Partial[] })[] = await prisma.plugin.findMany({ diff --git a/components/shared/buttons/Add.tsx b/components/shared/buttons/Add.tsx index 07addcf..5650d0e 100644 --- a/components/shared/buttons/Add.tsx +++ b/components/shared/buttons/Add.tsx @@ -1,4 +1,6 @@ +import { Plus } from 'lucide-react'; import React from 'react'; + import { Button } from '@/components/ui/button'; import { Tooltip, @@ -6,7 +8,6 @@ import { TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; -import { Plus } from 'lucide-react'; interface AddProps { type: string; diff --git a/components/shared/buttons/Cancel.tsx b/components/shared/buttons/Cancel.tsx index a2df0bb..24ff2bf 100644 --- a/components/shared/buttons/Cancel.tsx +++ b/components/shared/buttons/Cancel.tsx @@ -1,4 +1,6 @@ +import { XCircle } from 'lucide-react'; import React from 'react'; + import { Button } from '@/components/ui/button'; import { Tooltip, @@ -6,7 +8,6 @@ import { TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; -import { XCircle } from 'lucide-react'; export default function Cancel() { return ( diff --git a/components/shared/buttons/ConfirmDelete.tsx b/components/shared/buttons/ConfirmDelete.tsx index 41247ac..688f6b2 100644 --- a/components/shared/buttons/ConfirmDelete.tsx +++ b/components/shared/buttons/ConfirmDelete.tsx @@ -1,6 +1,7 @@ +import { Check, Trash } from 'lucide-react'; import React, { useState } from 'react'; + import { Button } from '@/components/ui/button'; -import { Check, Trash } from 'lucide-react'; import { Tooltip, TooltipContent, diff --git a/components/shared/buttons/Copy.tsx b/components/shared/buttons/Copy.tsx index 9aab961..8933c13 100644 --- a/components/shared/buttons/Copy.tsx +++ b/components/shared/buttons/Copy.tsx @@ -1,4 +1,6 @@ +import { CopyIcon } from 'lucide-react'; import React from 'react'; + import { Button } from '@/components/ui/button'; import { Tooltip, @@ -6,7 +8,6 @@ import { TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; -import { CopyIcon } from 'lucide-react'; interface CopyProps { className?: string; diff --git a/components/shared/buttons/Edit.tsx b/components/shared/buttons/Edit.tsx index 3548d0a..b9802eb 100644 --- a/components/shared/buttons/Edit.tsx +++ b/components/shared/buttons/Edit.tsx @@ -1,3 +1,5 @@ +import { EditIcon } from 'lucide-react'; + import { Button } from '@/components/ui/button'; import { Tooltip, @@ -5,7 +7,6 @@ import { TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; -import { EditIcon } from 'lucide-react'; interface EditProps { onClick: () => void; diff --git a/components/shared/buttons/Save.tsx b/components/shared/buttons/Save.tsx index 3a49e34..4d2c1d3 100644 --- a/components/shared/buttons/Save.tsx +++ b/components/shared/buttons/Save.tsx @@ -1,4 +1,6 @@ +import { SaveIcon } from 'lucide-react'; import React from 'react'; + import { Button } from '@/components/ui/button'; import { Tooltip, @@ -6,7 +8,6 @@ import { TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; -import { SaveIcon } from 'lucide-react'; export default function Save() { return ( diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx index 70a6d12..5baa983 100644 --- a/components/ui/avatar.tsx +++ b/components/ui/avatar.tsx @@ -1,7 +1,7 @@ 'use client'; -import * as React from 'react'; import * as AvatarPrimitive from '@radix-ui/react-avatar'; +import * as React from 'react'; import { cn } from '@/lib/utils'; diff --git a/components/ui/badge.tsx b/components/ui/badge.tsx index 68d18c3..1534c41 100644 --- a/components/ui/badge.tsx +++ b/components/ui/badge.tsx @@ -1,5 +1,5 @@ -import * as React from 'react'; import { cva, type VariantProps } from 'class-variance-authority'; +import * as React from 'react'; import { cn } from '@/lib/utils'; diff --git a/components/ui/button.tsx b/components/ui/button.tsx index b6edcd0..4a824f1 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -1,6 +1,6 @@ -import * as React from 'react'; import { Slot } from '@radix-ui/react-slot'; import { cva, type VariantProps } from 'class-variance-authority'; +import * as React from 'react'; import { cn } from '@/lib/utils'; diff --git a/components/ui/command.tsx b/components/ui/command.tsx index 1a37e67..604eb05 100644 --- a/components/ui/command.tsx +++ b/components/ui/command.tsx @@ -1,155 +1,159 @@ -"use client" +'use client'; -import * as React from "react" -import { type DialogProps } from "@radix-ui/react-dialog" -import { Command as CommandPrimitive } from "cmdk" -import { Search } from "lucide-react" +import { type DialogProps } from '@radix-ui/react-dialog'; +import { Command as CommandPrimitive } from 'cmdk'; +import { Search } from 'lucide-react'; +import * as React from 'react'; -import { cn } from "@/lib/utils" -import { Dialog, DialogContent } from "@/components/ui/dialog" +import { Dialog, DialogContent } from '@/components/ui/dialog'; + +import { cn } from '@/lib/utils'; const Command = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) -Command.displayName = CommandPrimitive.displayName + +)); +Command.displayName = CommandPrimitive.displayName; interface CommandDialogProps extends DialogProps {} const CommandDialog = ({ children, ...props }: CommandDialogProps) => { - return ( - - - - {children} - - - - ) -} + return ( + + + + {children} + + + + ); +}; const CommandInput = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( -
- - -
-)) - -CommandInput.displayName = CommandPrimitive.Input.displayName +
+ + +
+)); + +CommandInput.displayName = CommandPrimitive.Input.displayName; const CommandList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) + +)); -CommandList.displayName = CommandPrimitive.List.displayName +CommandList.displayName = CommandPrimitive.List.displayName; const CommandEmpty = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >((props, ref) => ( - -)) + +)); -CommandEmpty.displayName = CommandPrimitive.Empty.displayName +CommandEmpty.displayName = CommandPrimitive.Empty.displayName; const CommandGroup = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) - -CommandGroup.displayName = CommandPrimitive.Group.displayName + +)); + +CommandGroup.displayName = CommandPrimitive.Group.displayName; const CommandSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) -CommandSeparator.displayName = CommandPrimitive.Separator.displayName + +)); +CommandSeparator.displayName = CommandPrimitive.Separator.displayName; const CommandItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) - -CommandItem.displayName = CommandPrimitive.Item.displayName + +)); + +CommandItem.displayName = CommandPrimitive.Item.displayName; const CommandShortcut = ({ - className, - ...props + className, + ...props }: React.HTMLAttributes) => { - return ( - - ) -} -CommandShortcut.displayName = "CommandShortcut" + return ( + + ); +}; +CommandShortcut.displayName = 'CommandShortcut'; export { - Command, - CommandDialog, - CommandInput, - CommandList, - CommandEmpty, - CommandGroup, - CommandItem, - CommandShortcut, - CommandSeparator, -} + Command, + CommandDialog, + CommandInput, + CommandList, + CommandEmpty, + CommandGroup, + CommandItem, + CommandShortcut, + CommandSeparator, +}; diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx index f38593b..f432e31 100644 --- a/components/ui/dialog.tsx +++ b/components/ui/dialog.tsx @@ -1,122 +1,122 @@ -"use client" +'use client'; -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { X } from "lucide-react" +import * as DialogPrimitive from '@radix-ui/react-dialog'; +import { X } from 'lucide-react'; +import * as React from 'react'; -import { cn } from "@/lib/utils" +import { cn } from '@/lib/utils'; -const Dialog = DialogPrimitive.Root +const Dialog = DialogPrimitive.Root; -const DialogTrigger = DialogPrimitive.Trigger +const DialogTrigger = DialogPrimitive.Trigger; -const DialogPortal = DialogPrimitive.Portal +const DialogPortal = DialogPrimitive.Portal; -const DialogClose = DialogPrimitive.Close +const DialogClose = DialogPrimitive.Close; const DialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName + +)); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const DialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, children, ...props }, ref) => ( - - - - {children} - - - Close - - - -)) -DialogContent.displayName = DialogPrimitive.Content.displayName + + + + {children} + + + Close + + + +)); +DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({ - className, - ...props + className, + ...props }: React.HTMLAttributes) => ( -
-) -DialogHeader.displayName = "DialogHeader" +
+); +DialogHeader.displayName = 'DialogHeader'; const DialogFooter = ({ - className, - ...props + className, + ...props }: React.HTMLAttributes) => ( -
-) -DialogFooter.displayName = "DialogFooter" +
+); +DialogFooter.displayName = 'DialogFooter'; const DialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) -DialogTitle.displayName = DialogPrimitive.Title.displayName + +)); +DialogTitle.displayName = DialogPrimitive.Title.displayName; const DialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( - -)) -DialogDescription.displayName = DialogPrimitive.Description.displayName + +)); +DialogDescription.displayName = DialogPrimitive.Description.displayName; export { - Dialog, - DialogPortal, - DialogOverlay, - DialogClose, - DialogTrigger, - DialogContent, - DialogHeader, - DialogFooter, - DialogTitle, - DialogDescription, -} + Dialog, + DialogPortal, + DialogOverlay, + DialogClose, + DialogTrigger, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +}; diff --git a/components/ui/form.tsx b/components/ui/form.tsx index ce264ae..0a0ffd9 100644 --- a/components/ui/form.tsx +++ b/components/ui/form.tsx @@ -1,178 +1,180 @@ -"use client" +'use client'; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" +import * as LabelPrimitive from '@radix-ui/react-label'; +import { Slot } from '@radix-ui/react-slot'; +import * as React from 'react'; import { - Controller, - ControllerProps, - FieldPath, - FieldValues, - FormProvider, - useFormContext, -} from "react-hook-form" + Controller, + ControllerProps, + FieldPath, + FieldValues, + FormProvider, + useFormContext, +} from 'react-hook-form'; -import { cn } from "@/lib/utils" -import { Label } from "@/components/ui/label" +import { Label } from '@/components/ui/label'; -const Form = FormProvider +import { cn } from '@/lib/utils'; + +const Form = FormProvider; type FormFieldContextValue< - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, > = { - name: TName -} + name: TName; +}; const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) + {} as FormFieldContextValue +); const FormField = < - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TFieldValues extends FieldValues = FieldValues, + TName extends FieldPath = FieldPath, >({ - ...props + ...props }: ControllerProps) => { - return ( - - - - ) -} + return ( + + + + ); +}; const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState, formState } = useFormContext() + const fieldContext = React.useContext(FormFieldContext); + const itemContext = React.useContext(FormItemContext); + const { getFieldState, formState } = useFormContext(); - const fieldState = getFieldState(fieldContext.name, formState) + const fieldState = getFieldState(fieldContext.name, formState); - if (!fieldContext) { - throw new Error("useFormField should be used within ") - } + if (!fieldContext) { + throw new Error('useFormField should be used within '); + } - const { id } = itemContext + const { id } = itemContext; - return { - id, - name: fieldContext.name, - formItemId: `${id}-form-item`, - formDescriptionId: `${id}-form-item-description`, - formMessageId: `${id}-form-item-message`, - ...fieldState, - } -} + return { + id, + name: fieldContext.name, + formItemId: `${id}-form-item`, + formDescriptionId: `${id}-form-item-description`, + formMessageId: `${id}-form-item-message`, + ...fieldState, + }; +}; type FormItemContextValue = { - id: string -} + id: string; +}; const FormItemContext = React.createContext( - {} as FormItemContextValue -) + {} as FormItemContextValue +); const FormItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes + HTMLDivElement, + React.HTMLAttributes >(({ className, ...props }, ref) => { - const id = React.useId() + const id = React.useId(); - return ( - -
- - ) -}) -FormItem.displayName = "FormItem" + return ( + +
+ + ); +}); +FormItem.displayName = 'FormItem'; const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef + React.ElementRef, + React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => { - const { error, formItemId } = useFormField() - - return ( -