From a26d60ea8563b956f4f33d99b54d9ca1c2ab7590 Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 25 Jun 2025 23:10:22 +0200 Subject: [PATCH] Updated db and formatting --- src/components/auth/signin-button.tsx | 3 - src/components/svgs/authentik.tsx | 36 ++- src/components/ui/avatar.tsx | 70 ++--- src/components/ui/dropdown-menu.tsx | 366 +++++++++++++------------- src/lib/drizzle/schema.ts | 51 +++- 5 files changed, 290 insertions(+), 236 deletions(-) diff --git a/src/components/auth/signin-button.tsx b/src/components/auth/signin-button.tsx index 76276b7..ac319f5 100644 --- a/src/components/auth/signin-button.tsx +++ b/src/components/auth/signin-button.tsx @@ -8,8 +8,6 @@ import { useState } from "react" interface OAuthSignInButtonProps { className?: string - provider?: string - children?: React.ReactNode } export function OAuthSignInButton({ @@ -36,7 +34,6 @@ export function OAuthSignInButton({ disabled={isLoading} className={className} size="lg" - variant="default" > {isLoading ? ( diff --git a/src/components/svgs/authentik.tsx b/src/components/svgs/authentik.tsx index 129fef6..999c44c 100644 --- a/src/components/svgs/authentik.tsx +++ b/src/components/svgs/authentik.tsx @@ -17,18 +17,30 @@ export function AuthentikIcon({ className, ...props }: AuthentikIconProps) { - - - - - - - - - - - - + + + + + + + + + + + + ) } diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx index 71e428b..f46c4f1 100644 --- a/src/components/ui/avatar.tsx +++ b/src/components/ui/avatar.tsx @@ -1,53 +1,53 @@ "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" function Avatar({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } function AvatarImage({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } function AvatarFallback({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } -export { Avatar, AvatarImage, AvatarFallback } +export { Avatar, AvatarFallback, AvatarImage } diff --git a/src/components/ui/dropdown-menu.tsx b/src/components/ui/dropdown-menu.tsx index ec51e9c..6229225 100644 --- a/src/components/ui/dropdown-menu.tsx +++ b/src/components/ui/dropdown-menu.tsx @@ -1,257 +1,253 @@ "use client" -import * as React from "react" import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react" +import * as React from "react" import { cn } from "@/lib/utils" function DropdownMenu({ - ...props + ...props }: React.ComponentProps) { - return + return } function DropdownMenuPortal({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return } function DropdownMenuTrigger({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } function DropdownMenuContent({ - className, - sideOffset = 4, - ...props + className, + sideOffset = 4, + ...props }: React.ComponentProps) { - return ( - - - - ) + return ( + + + + ) } function DropdownMenuGroup({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return } function DropdownMenuItem({ - className, - inset, - variant = "default", - ...props + className, + inset, + variant = "default", + ...props }: React.ComponentProps & { - inset?: boolean - variant?: "default" | "destructive" + inset?: boolean + variant?: "default" | "destructive" }) { - return ( - - ) + return ( + + ) } function DropdownMenuCheckboxItem({ - className, - children, - checked, - ...props + className, + children, + checked, + ...props }: React.ComponentProps) { - return ( - - - - - - - {children} - - ) + return ( + + + + + + + {children} + + ) } function DropdownMenuRadioGroup({ - ...props + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } function DropdownMenuRadioItem({ - className, - children, - ...props + className, + children, + ...props }: React.ComponentProps) { - return ( - - - - - - - {children} - - ) + return ( + + + + + + + {children} + + ) } function DropdownMenuLabel({ - className, - inset, - ...props + className, + inset, + ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean }) { - return ( - - ) + return ( + + ) } function DropdownMenuSeparator({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } function DropdownMenuShortcut({ - className, - ...props + className, + ...props }: React.ComponentProps<"span">) { - return ( - - ) + return ( + + ) } function DropdownMenuSub({ - ...props + ...props }: React.ComponentProps) { - return + return } function DropdownMenuSubTrigger({ - className, - inset, - children, - ...props + className, + inset, + children, + ...props }: React.ComponentProps & { - inset?: boolean + inset?: boolean }) { - return ( - - {children} - - - ) + return ( + + {children} + + + ) } function DropdownMenuSubContent({ - className, - ...props + className, + ...props }: React.ComponentProps) { - return ( - - ) + return ( + + ) } export { - DropdownMenu, - DropdownMenuPortal, - DropdownMenuTrigger, - DropdownMenuContent, - DropdownMenuGroup, - DropdownMenuLabel, - DropdownMenuItem, - DropdownMenuCheckboxItem, - DropdownMenuRadioGroup, - DropdownMenuRadioItem, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuSub, - DropdownMenuSubTrigger, - DropdownMenuSubContent, + DropdownMenu, + DropdownMenuCheckboxItem, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuPortal, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuTrigger } diff --git a/src/lib/drizzle/schema.ts b/src/lib/drizzle/schema.ts index fa913ba..97b474d 100644 --- a/src/lib/drizzle/schema.ts +++ b/src/lib/drizzle/schema.ts @@ -1 +1,50 @@ -export * from "./auth-schema" \ No newline at end of file +export { account, session, user, verification } from "./auth-schema" + +import { relations } from "drizzle-orm" +import { boolean, index, integer, pgTable, timestamp, uuid, varchar } from "drizzle-orm/pg-core" + +const createdAt = timestamp("created_at", { withTimezone: true }).defaultNow() +const updatedAt = timestamp("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => new Date()) + +export const urls = pgTable("urls", { + id: uuid("id").primaryKey().notNull(), + url: varchar("url").notNull(), + slug: varchar("slug").notNull(), + title: varchar("title").notNull(), + maxVisits: integer("max_visits"), + expDate: timestamp("exp_date", { withTimezone: true }), + forwardQueryParams: boolean("forward_query_params").default(true), + crawlable: boolean("crawable").default(false), + createdAt, + updatedAt +}, (t) => { + return [ + index("urls_slug_idx").on(t.slug), + index("urls_url_idx").on(t.url), + index("exp_date_idx").on(t.expDate) + ] +}) + +export const visits = pgTable("visits", { + id: uuid("id").primaryKey().notNull(), + urlId: uuid("url_id").notNull().references(() => urls.id), + ipAdress: varchar("ip_address").notNull(), + userAgent: varchar("user_agent").notNull(), + createdAt, + updatedAt +}, (t) => { + return [ + index("visits_url_id_idx").on(t.urlId) + ] +}) + +export const urlsRelations = relations(urls, ({ many }) => ({ + visits: many(visits) +})) + +export const visitsRelations = relations(visits, ({ one }) => ({ + url: one(urls, { + fields: [visits.urlId], + references: [urls.id] + }) +}))