From 80bb8a108f29331cdb2f2695f6801beee104dc89 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Thu, 8 Feb 2024 15:14:23 +0000 Subject: [refactor] Move the different packages to the package subdir --- web/.env.sample | 8 - web/Dockerfile | 57 ------ web/README.md | 36 ---- web/app/api/auth/[...nextauth]/route.tsx | 3 - web/app/api/v1/links/[linkId]/route.ts | 32 ---- web/app/api/v1/links/route.ts | 49 ----- web/app/dashboard/bookmarks/components/AddLink.tsx | 67 ------- .../dashboard/bookmarks/components/LinkCard.tsx | 96 ---------- .../dashboard/bookmarks/components/LinksGrid.tsx | 21 --- web/app/dashboard/bookmarks/page.tsx | 20 --- web/app/dashboard/components/Sidebar.tsx | 56 ------ web/app/dashboard/layout.tsx | 15 -- web/app/favicon.ico | Bin 25931 -> 0 bytes web/app/globals.css | 76 -------- web/app/layout.tsx | 27 --- web/app/page.tsx | 19 -- web/bun.lockb | Bin 158558 -> 0 bytes web/components.json | 17 -- web/components/auth/login.tsx | 17 -- web/components/auth/logout.tsx | 17 -- web/components/ui/badge.tsx | 36 ---- web/components/ui/button.tsx | 56 ------ web/components/ui/card.tsx | 86 --------- web/components/ui/dropdown-menu.tsx | 200 --------------------- web/components/ui/form.tsx | 176 ------------------ web/components/ui/imageCard.tsx | 56 ------ web/components/ui/input.tsx | 25 --- web/components/ui/label.tsx | 26 --- web/components/ui/toast.tsx | 127 ------------- web/components/ui/toaster.tsx | 35 ---- web/components/ui/use-toast.ts | 189 ------------------- web/lib/api.ts | 81 --------- web/lib/auth.ts | 25 --- web/lib/config.ts | 22 --- web/lib/services/links.ts | 78 -------- web/lib/types/api/links.ts | 33 ---- web/lib/types/api/tags.ts | 6 - web/lib/types/next-auth.d.ts | 12 -- web/lib/utils.ts | 6 - web/next.config.mjs | 4 - web/package.json | 41 ----- web/postcss.config.js | 6 - web/public/next.svg | 1 - web/public/vercel.svg | 1 - web/tailwind.config.ts | 80 --------- web/tsconfig.json | 27 --- 46 files changed, 2068 deletions(-) delete mode 100644 web/.env.sample delete mode 100644 web/Dockerfile delete mode 100644 web/README.md delete mode 100644 web/app/api/auth/[...nextauth]/route.tsx delete mode 100644 web/app/api/v1/links/[linkId]/route.ts delete mode 100644 web/app/api/v1/links/route.ts delete mode 100644 web/app/dashboard/bookmarks/components/AddLink.tsx delete mode 100644 web/app/dashboard/bookmarks/components/LinkCard.tsx delete mode 100644 web/app/dashboard/bookmarks/components/LinksGrid.tsx delete mode 100644 web/app/dashboard/bookmarks/page.tsx delete mode 100644 web/app/dashboard/components/Sidebar.tsx delete mode 100644 web/app/dashboard/layout.tsx delete mode 100644 web/app/favicon.ico delete mode 100644 web/app/globals.css delete mode 100644 web/app/layout.tsx delete mode 100644 web/app/page.tsx delete mode 100755 web/bun.lockb delete mode 100644 web/components.json delete mode 100644 web/components/auth/login.tsx delete mode 100644 web/components/auth/logout.tsx delete mode 100644 web/components/ui/badge.tsx delete mode 100644 web/components/ui/button.tsx delete mode 100644 web/components/ui/card.tsx delete mode 100644 web/components/ui/dropdown-menu.tsx delete mode 100644 web/components/ui/form.tsx delete mode 100644 web/components/ui/imageCard.tsx delete mode 100644 web/components/ui/input.tsx delete mode 100644 web/components/ui/label.tsx delete mode 100644 web/components/ui/toast.tsx delete mode 100644 web/components/ui/toaster.tsx delete mode 100644 web/components/ui/use-toast.ts delete mode 100644 web/lib/api.ts delete mode 100644 web/lib/auth.ts delete mode 100644 web/lib/config.ts delete mode 100644 web/lib/services/links.ts delete mode 100644 web/lib/types/api/links.ts delete mode 100644 web/lib/types/api/tags.ts delete mode 100644 web/lib/types/next-auth.d.ts delete mode 100644 web/lib/utils.ts delete mode 100644 web/next.config.mjs delete mode 100644 web/package.json delete mode 100644 web/postcss.config.js delete mode 100644 web/public/next.svg delete mode 100644 web/public/vercel.svg delete mode 100644 web/tailwind.config.ts delete mode 100644 web/tsconfig.json (limited to 'web') diff --git a/web/.env.sample b/web/.env.sample deleted file mode 100644 index a48054f0..00000000 --- a/web/.env.sample +++ /dev/null @@ -1,8 +0,0 @@ -DATABASE_URL="file:./dev.db" -NEXTAUTH_URL= -NEXTAUTH_SECRET= - -# Oauth -AUTHENTIK_ID= -AUTHENTIK_SECRET= -AUTHENTIK_ISSUER= diff --git a/web/Dockerfile b/web/Dockerfile deleted file mode 100644 index 30a46bd3..00000000 --- a/web/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM oven/bun:1.0-alpine AS base - -# Install dependencies only when needed -FROM base AS deps -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -# RUN apk add --no-cache libc6-compat -WORKDIR /app - -# Install dependencies based on the preferred package manager -COPY package.json bun.lockb ./ -RUN bun install --frozen-lockfile - -# Rebuild the source code only when needed -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -ENV NODE_ENV production - -ENV NEXT_TELEMETRY_DISABLED 1 - -RUN bun run build - -# Production image, copy all the files and run next -FROM base AS runner -WORKDIR /app - -ENV NODE_ENV production - -ENV NEXT_TELEMETRY_DISABLED 1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder /app/public ./public - -# Set the correct permission for prerender cache -RUN mkdir .next -RUN chown nextjs:nodejs .next - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static - -USER nextjs - -EXPOSE 3000 - -ENV PORT 3000 -# set hostname to localhost -ENV HOSTNAME "0.0.0.0" - -# server.js is created by next build from the standalone output -# https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD ["node", "server.js"] diff --git a/web/README.md b/web/README.md deleted file mode 100644 index c4033664..00000000 --- a/web/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/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/basic-features/font-optimization) 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/deployment) for more details. diff --git a/web/app/api/auth/[...nextauth]/route.tsx b/web/app/api/auth/[...nextauth]/route.tsx deleted file mode 100644 index e722926b..00000000 --- a/web/app/api/auth/[...nextauth]/route.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { authHandler } from "@/lib/auth"; - -export { authHandler as GET, authHandler as POST }; diff --git a/web/app/api/v1/links/[linkId]/route.ts b/web/app/api/v1/links/[linkId]/route.ts deleted file mode 100644 index 39449d6d..00000000 --- a/web/app/api/v1/links/[linkId]/route.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { authOptions } from "@/lib/auth"; -import { unbookmarkLink } from "@/lib/services/links"; -import { Prisma } from "@remember/db"; - -import { getServerSession } from "next-auth"; -import { NextRequest } from "next/server"; - -export async function DELETE( - _request: NextRequest, - { params }: { params: { linkId: string } }, -) { - // TODO: We probably should be using an API key here instead of the session; - const session = await getServerSession(authOptions); - if (!session) { - return new Response(null, { status: 401 }); - } - - try { - await unbookmarkLink(params.linkId, session.user.id); - } catch (e: unknown) { - if ( - e instanceof Prisma.PrismaClientKnownRequestError && - e.code === "P2025" // RecordNotFound - ) { - return new Response(null, { status: 404 }); - } else { - throw e; - } - } - - return new Response(null, { status: 201 }); -} diff --git a/web/app/api/v1/links/route.ts b/web/app/api/v1/links/route.ts deleted file mode 100644 index 87541634..00000000 --- a/web/app/api/v1/links/route.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { authOptions } from "@/lib/auth"; -import { bookmarkLink, getLinks } from "@/lib/services/links"; - -import { - zNewBookmarkedLinkRequestSchema, - ZGetLinksResponse, - ZBookmarkedLink, -} from "@/lib/types/api/links"; -import { getServerSession } from "next-auth"; -import { NextRequest, NextResponse } from "next/server"; - -export async function POST(request: NextRequest) { - // TODO: We probably should be using an API key here instead of the session; - const session = await getServerSession(authOptions); - if (!session) { - return new Response(null, { status: 401 }); - } - - const linkRequest = zNewBookmarkedLinkRequestSchema.safeParse( - await request.json(), - ); - - if (!linkRequest.success) { - return NextResponse.json( - { - error: linkRequest.error.toString(), - }, - { status: 400 }, - ); - } - - const link = await bookmarkLink(linkRequest.data.url, session.user.id); - - let response: ZBookmarkedLink = { ...link }; - return NextResponse.json(response, { status: 201 }); -} - -export async function GET() { - // TODO: We probably should be using an API key here instead of the session; - const session = await getServerSession(authOptions); - if (!session) { - return new Response(null, { status: 401 }); - } - - const links = await getLinks(session.user.id); - - let response: ZGetLinksResponse = { links }; - return NextResponse.json(response); -} diff --git a/web/app/dashboard/bookmarks/components/AddLink.tsx b/web/app/dashboard/bookmarks/components/AddLink.tsx deleted file mode 100644 index fb77786c..00000000 --- a/web/app/dashboard/bookmarks/components/AddLink.tsx +++ /dev/null @@ -1,67 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { Form, FormControl, FormField, FormItem } from "@/components/ui/form"; -import { Input } from "@/components/ui/input"; -import APIClient from "@/lib/api"; -import { Plus } from "lucide-react"; -import { useRouter } from "next/navigation"; -import { useForm, SubmitErrorHandler } from "react-hook-form"; -import { z } from "zod"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { toast } from "@/components/ui/use-toast"; - -const formSchema = z.object({ - url: z.string().url({ message: "The link must be a valid URL" }), -}); - -export default function AddLink() { - const router = useRouter(); - - const form = useForm>({ - resolver: zodResolver(formSchema), - }); - - async function onSubmit(value: z.infer) { - const [_resp, error] = await APIClient.bookmarkLink(value.url); - if (error) { - toast({ description: error.message, variant: "destructive" }); - return; - } - router.refresh(); - } - - const onError: SubmitErrorHandler> = (errors) => { - toast({ - description: Object.values(errors) - .map((v) => v.message) - .join("\n"), - variant: "destructive", - }); - }; - - return ( -
- -
- { - return ( - - - - - - ); - }} - /> - -
-
- - ); -} diff --git a/web/app/dashboard/bookmarks/components/LinkCard.tsx b/web/app/dashboard/bookmarks/components/LinkCard.tsx deleted file mode 100644 index da59d9da..00000000 --- a/web/app/dashboard/bookmarks/components/LinkCard.tsx +++ /dev/null @@ -1,96 +0,0 @@ -"use client"; - -import { Badge } from "@/components/ui/badge"; -import { Button } from "@/components/ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - ImageCard, - ImageCardBody, - ImageCardFooter, - ImageCardTitle, -} from "@/components/ui/imageCard"; -import { useToast } from "@/components/ui/use-toast"; -import APIClient from "@/lib/api"; -import { ZBookmarkedLink } from "@/lib/types/api/links"; -import { MoreHorizontal, Trash2 } from "lucide-react"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; - -export function LinkOptions({ linkId }: { linkId: string }) { - const { toast } = useToast(); - const router = useRouter(); - - const unbookmarkLink = async () => { - let [_, error] = await APIClient.unbookmarkLink(linkId); - - if (error) { - toast({ - variant: "destructive", - title: "Something went wrong", - description: "There was a problem with your request.", - }); - } else { - toast({ - description: "The link has been deleted!", - }); - } - - router.refresh(); - }; - return ( - - - - - - - - Delete - - - - ); -} - -export default function LinkCard({ link }: { link: ZBookmarkedLink }) { - const parsedUrl = new URL(link.url); - - return ( - - - - {link.details?.title ?? parsedUrl.host} - - - - {link.tags.map((t) => ( - - #{t.name} - - ))} - - -
-
- - {parsedUrl.host} - -
- -
-
-
- ); -} diff --git a/web/app/dashboard/bookmarks/components/LinksGrid.tsx b/web/app/dashboard/bookmarks/components/LinksGrid.tsx deleted file mode 100644 index 66f0d766..00000000 --- a/web/app/dashboard/bookmarks/components/LinksGrid.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { getServerSession } from "next-auth"; -import { redirect } from "next/navigation"; -import { authOptions } from "@/lib/auth"; -import { getLinks } from "@/lib/services/links"; -import LinkCard from "./LinkCard"; - -export default async function LinksGrid() { - const session = await getServerSession(authOptions); - if (!session) { - redirect("/"); - } - const links = await getLinks(session.user.id); - - return ( -
- {links.map((l) => ( - - ))} -
- ); -} diff --git a/web/app/dashboard/bookmarks/page.tsx b/web/app/dashboard/bookmarks/page.tsx deleted file mode 100644 index b4158893..00000000 --- a/web/app/dashboard/bookmarks/page.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import AddLink from "./components/AddLink"; -import LinksGrid from "./components/LinksGrid"; -import type { Metadata } from "next"; - -export const metadata: Metadata = { - title: "Remember - Bookmarks", -}; - -export default async function Bookmarks() { - return ( -
-
- -
-
- -
-
- ); -} diff --git a/web/app/dashboard/components/Sidebar.tsx b/web/app/dashboard/components/Sidebar.tsx deleted file mode 100644 index 0ed87daf..00000000 --- a/web/app/dashboard/components/Sidebar.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Button } from "@/components/ui/button"; -import { authOptions } from "@/lib/auth"; -import { Archive, MoreHorizontal, Star, Tag, Home, Brain} from "lucide-react"; -import { getServerSession } from "next-auth"; -import Link from "next/link"; -import { redirect } from "next/navigation"; - -function SidebarItem({ - name, - logo, - path, -}: { - name: string; - logo: React.ReactNode; - path: string; -}) { - return ( -
  • - - {logo} - {name} - -
  • - ); -} - -export default async function Sidebar() { - const session = await getServerSession(authOptions); - if (!session) { - redirect("/"); - } - - return ( - - ); -} diff --git a/web/app/dashboard/layout.tsx b/web/app/dashboard/layout.tsx deleted file mode 100644 index 9b21271e..00000000 --- a/web/app/dashboard/layout.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import Bookmarks from "@/app/dashboard/bookmarks/page"; -import Sidebar from "@/app/dashboard/components/Sidebar"; - -export default async function Dashboard() { - return ( -
    -
    - -
    -
    - -
    -
    - ); -} diff --git a/web/app/favicon.ico b/web/app/favicon.ico deleted file mode 100644 index 718d6fea..00000000 Binary files a/web/app/favicon.ico and /dev/null differ diff --git a/web/app/globals.css b/web/app/globals.css deleted file mode 100644 index 8abdb15c..00000000 --- a/web/app/globals.css +++ /dev/null @@ -1,76 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -@layer base { - :root { - --background: 0 0% 100%; - --foreground: 222.2 84% 4.9%; - - --card: 0 0% 100%; - --card-foreground: 222.2 84% 4.9%; - - --popover: 0 0% 100%; - --popover-foreground: 222.2 84% 4.9%; - - --primary: 222.2 47.4% 11.2%; - --primary-foreground: 210 40% 98%; - - --secondary: 210 40% 96.1%; - --secondary-foreground: 222.2 47.4% 11.2%; - - --muted: 210 40% 96.1%; - --muted-foreground: 215.4 16.3% 46.9%; - - --accent: 210 40% 96.1%; - --accent-foreground: 222.2 47.4% 11.2%; - - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 210 40% 98%; - - --border: 214.3 31.8% 91.4%; - --input: 214.3 31.8% 91.4%; - --ring: 222.2 84% 4.9%; - - --radius: 0.5rem; - } - - .dark { - --background: 222.2 84% 4.9%; - --foreground: 210 40% 98%; - - --card: 222.2 84% 4.9%; - --card-foreground: 210 40% 98%; - - --popover: 222.2 84% 4.9%; - --popover-foreground: 210 40% 98%; - - --primary: 210 40% 98%; - --primary-foreground: 222.2 47.4% 11.2%; - - --secondary: 217.2 32.6% 17.5%; - --secondary-foreground: 210 40% 98%; - - --muted: 217.2 32.6% 17.5%; - --muted-foreground: 215 20.2% 65.1%; - - --accent: 217.2 32.6% 17.5%; - --accent-foreground: 210 40% 98%; - - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 40% 98%; - - --border: 217.2 32.6% 17.5%; - --input: 217.2 32.6% 17.5%; - --ring: 212.7 26.8% 83.9%; - } -} - -@layer base { - * { - @apply border-border; - } - body { - @apply bg-background text-foreground; - } -} diff --git a/web/app/layout.tsx b/web/app/layout.tsx deleted file mode 100644 index a2d34046..00000000 --- a/web/app/layout.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "./globals.css"; -import React from "react"; -import { Toaster } from "@/components/ui/toaster"; - -const inter = Inter({ subsets: ["latin"] }); - -export const metadata: Metadata = { - title: "Remember", - description: "Your AI powered second brain", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - - ); -} diff --git a/web/app/page.tsx b/web/app/page.tsx deleted file mode 100644 index ffc128a5..00000000 --- a/web/app/page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { LoginButton } from "@/components/auth/login"; -import { LogoutButton } from "@/components/auth/logout"; -import Link from "next/link"; - -export default function Home() { - return ( -
    -
    - -
    -
    - -
    -
    - Bookmarks -
    -
    - ); -} diff --git a/web/bun.lockb b/web/bun.lockb deleted file mode 100755 index 7925e942..00000000 Binary files a/web/bun.lockb and /dev/null differ diff --git a/web/components.json b/web/components.json deleted file mode 100644 index fa674c93..00000000 --- a/web/components.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "default", - "rsc": true, - "tsx": true, - "tailwind": { - "config": "tailwind.config.ts", - "css": "app/globals.css", - "baseColor": "slate", - "cssVariables": true, - "prefix": "" - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils" - } -} diff --git a/web/components/auth/login.tsx b/web/components/auth/login.tsx deleted file mode 100644 index 4cd55546..00000000 --- a/web/components/auth/login.tsx +++ /dev/null @@ -1,17 +0,0 @@ -"use client"; -import { signIn } from "next-auth/react"; - -export const LoginButton = () => { - return ( - - ); -}; diff --git a/web/components/auth/logout.tsx b/web/components/auth/logout.tsx deleted file mode 100644 index 8d627f68..00000000 --- a/web/components/auth/logout.tsx +++ /dev/null @@ -1,17 +0,0 @@ -"use client"; -import { signOut } from "next-auth/react"; - -export const LogoutButton = () => { - return ( - - ); -}; diff --git a/web/components/ui/badge.tsx b/web/components/ui/badge.tsx deleted file mode 100644 index d3d5d604..00000000 --- a/web/components/ui/badge.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import * as React from "react"; -import { cva, type VariantProps } from "class-variance-authority"; - -import { cn } from "@/lib/utils"; - -const badgeVariants = cva( - "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", - { - variants: { - variant: { - default: - "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", - secondary: - "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", - destructive: - "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", - outline: "text-foreground", - }, - }, - defaultVariants: { - variant: "default", - }, - }, -); - -export interface BadgeProps - extends React.HTMLAttributes, - VariantProps {} - -function Badge({ className, variant, ...props }: BadgeProps) { - return ( -
    - ); -} - -export { Badge, badgeVariants }; diff --git a/web/components/ui/button.tsx b/web/components/ui/button.tsx deleted file mode 100644 index 57c9fe47..00000000 --- a/web/components/ui/button.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import * as React from "react"; -import { Slot } from "@radix-ui/react-slot"; -import { cva, type VariantProps } from "class-variance-authority"; - -import { cn } from "@/lib/utils"; - -const buttonVariants = cva( - "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", - { - variants: { - variant: { - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: - "bg-destructive text-destructive-foreground hover:bg-destructive/90", - outline: - "border border-input bg-background hover:bg-accent hover:text-accent-foreground", - secondary: - "bg-secondary text-secondary-foreground hover:bg-secondary/80", - ghost: "hover:bg-accent hover:text-accent-foreground", - link: "text-primary underline-offset-4 hover:underline", - }, - size: { - default: "h-10 px-4 py-2", - sm: "h-9 rounded-md px-3", - lg: "h-11 rounded-md px-8", - icon: "h-10 w-10", - }, - }, - defaultVariants: { - variant: "default", - size: "default", - }, - }, -); - -export interface ButtonProps - extends React.ButtonHTMLAttributes, - VariantProps { - asChild?: boolean; -} - -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button"; - return ( - - ); - }, -); -Button.displayName = "Button"; - -export { Button, buttonVariants }; diff --git a/web/components/ui/card.tsx b/web/components/ui/card.tsx deleted file mode 100644 index dc3b01de..00000000 --- a/web/components/ui/card.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import * as React from "react"; - -import { cn } from "@/lib/utils"; - -const Card = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
    -)); -Card.displayName = "Card"; - -const CardHeader = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
    -)); -CardHeader.displayName = "CardHeader"; - -const CardTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -

    -)); -CardTitle.displayName = "CardTitle"; - -const CardDescription = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -

    -)); -CardDescription.displayName = "CardDescription"; - -const CardContent = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -

    -)); -CardContent.displayName = "CardContent"; - -const CardFooter = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
    -)); -CardFooter.displayName = "CardFooter"; - -export { - Card, - CardHeader, - CardFooter, - CardTitle, - CardDescription, - CardContent, -}; diff --git a/web/components/ui/dropdown-menu.tsx b/web/components/ui/dropdown-menu.tsx deleted file mode 100644 index 3a0c7fed..00000000 --- a/web/components/ui/dropdown-menu.tsx +++ /dev/null @@ -1,200 +0,0 @@ -"use client"; - -import * as React from "react"; -import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; -import { Check, ChevronRight, Circle } from "lucide-react"; - -import { cn } from "@/lib/utils"; - -const DropdownMenu = DropdownMenuPrimitive.Root; - -const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger; - -const DropdownMenuGroup = DropdownMenuPrimitive.Group; - -const DropdownMenuPortal = DropdownMenuPrimitive.Portal; - -const DropdownMenuSub = DropdownMenuPrimitive.Sub; - -const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; - -const DropdownMenuSubTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({ className, inset, children, ...props }, ref) => ( - - {children} - - -)); -DropdownMenuSubTrigger.displayName = - DropdownMenuPrimitive.SubTrigger.displayName; - -const DropdownMenuSubContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -DropdownMenuSubContent.displayName = - DropdownMenuPrimitive.SubContent.displayName; - -const DropdownMenuContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, sideOffset = 4, ...props }, ref) => ( - - - -)); -DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; - -const DropdownMenuItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({ className, inset, ...props }, ref) => ( - -)); -DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; - -const DropdownMenuCheckboxItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, checked, ...props }, ref) => ( - - - - - - - {children} - -)); -DropdownMenuCheckboxItem.displayName = - DropdownMenuPrimitive.CheckboxItem.displayName; - -const DropdownMenuRadioItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - - - - - - - {children} - -)); -DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; - -const DropdownMenuLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({ className, inset, ...props }, ref) => ( - -)); -DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; - -const DropdownMenuSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); -DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; - -const DropdownMenuShortcut = ({ - className, - ...props -}: React.HTMLAttributes) => { - return ( - - ); -}; -DropdownMenuShortcut.displayName = "DropdownMenuShortcut"; - -export { - DropdownMenu, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuCheckboxItem, - DropdownMenuRadioItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuGroup, - DropdownMenuPortal, - DropdownMenuSub, - DropdownMenuSubContent, - DropdownMenuSubTrigger, - DropdownMenuRadioGroup, -}; diff --git a/web/components/ui/form.tsx b/web/components/ui/form.tsx deleted file mode 100644 index 4603f8b3..00000000 --- a/web/components/ui/form.tsx +++ /dev/null @@ -1,176 +0,0 @@ -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" -import { Slot } from "@radix-ui/react-slot" -import { - Controller, - ControllerProps, - FieldPath, - FieldValues, - FormProvider, - useFormContext, -} from "react-hook-form" - -import { cn } from "@/lib/utils" -import { Label } from "@/components/ui/label" - -const Form = FormProvider - -type FormFieldContextValue< - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath -> = { - name: TName -} - -const FormFieldContext = React.createContext( - {} as FormFieldContextValue -) - -const FormField = < - TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath ->({ - ...props -}: ControllerProps) => { - return ( - - - - ) -} - -const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext) - const itemContext = React.useContext(FormItemContext) - const { getFieldState, formState } = useFormContext() - - const fieldState = getFieldState(fieldContext.name, formState) - - if (!fieldContext) { - throw new Error("useFormField should be used within ") - } - - const { id } = itemContext - - return { - id, - name: fieldContext.name, - formItemId: `${id}-form-item`, - formDescriptionId: `${id}-form-item-description`, - formMessageId: `${id}-form-item-message`, - ...fieldState, - } -} - -type FormItemContextValue = { - id: string -} - -const FormItemContext = React.createContext( - {} as FormItemContextValue -) - -const FormItem = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => { - const id = React.useId() - - return ( - -
    - - ) -}) -FormItem.displayName = "FormItem" - -const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => { - const { error, formItemId } = useFormField() - - return ( -