Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Product listing PoC

Damian Legawiecaea86bf450d8
diff --git a/packages/admin/package.json b/packages/admin/package.json
index e7f5dc16ad..d3ff05b987 100644
--- a/packages/admin/package.json
+++ b/packages/admin/package.json
@@ -11,6 +11,7 @@
},
"dependencies": {
"@fontsource-variable/geist": "^5.2.8",
+ "@fontsource-variable/inter": "^5.2.8",
"@hookform/resolvers": "^5.2.2",
"@spree/sdk": "workspace:^",
"@tanstack/react-query": "^5.90.21",
diff --git a/packages/admin/src/components/app-sidebar.tsx b/packages/admin/src/components/app-sidebar.tsx
index 4caf3c1a3e..264501fb3a 100644
--- a/packages/admin/src/components/app-sidebar.tsx
+++ b/packages/admin/src/components/app-sidebar.tsx
@@ -6,56 +6,67 @@ import {
SidebarContent,
SidebarFooter,
SidebarHeader,
- SidebarRail,
} from '@/components/ui/sidebar'
-import {
- LayoutDashboardIcon,
- PackageIcon,
- ShoppingCartIcon,
- UsersIcon,
- TagIcon,
- SettingsIcon,
-} from 'lucide-react'
import type { ComponentProps } from 'react'
-const navigation = [
+export type NavItem = {
+ title: string
+ url: string
+ icon: string
+ items?: { title: string; url: string }[]
+}
+
+const navigation: NavItem[] = [
{
- title: 'Dashboard',
+ title: 'Home',
url: '/',
- icon: <LayoutDashboardIcon />,
+ icon: 'home',
},
{
title: 'Orders',
url: '/orders',
- icon: <ShoppingCartIcon />,
+ icon: 'inbox',
+ items: [
+ { title: 'Draft Orders', url: '/orders/drafts' },
+ ],
},
{
title: 'Products',
url: '/products',
- icon: <PackageIcon />,
- isActive: true,
+ icon: 'package',
items: [
- { title: 'All Products', url: '/products' },
+ { title: 'Price Lists', url: '/products/price-lists' },
+ { title: 'Stock', url: '/products/stock' },
+ { title: 'Taxonomies', url: '/products/taxonomies' },
+ { title: 'Options', url: '/products/options' },
],
},
- {
- title: 'Categories',
- url: '/categories',
- icon: <TagIcon />,
- },
{
title: 'Customers',
url: '/customers',
- icon: <UsersIcon />,
+ icon: 'users',
},
{
- title: 'Settings',
- url: '/settings',
- icon: <SettingsIcon />,
+ title: 'Promotions',
+ url: '/promotions',
+ icon: 'discount',
items: [
- { title: 'General', url: '/settings' },
+ { title: 'Gift Cards', url: '/promotions/gift-cards' },
],
},
+ {
+ title: 'Reports',
+ url: '/reports',
+ icon: 'chart-bar',
+ },
+]
+
+const bottomNavigation: NavItem[] = [
+ {
+ title: 'Settings',
+ url: '/settings',
+ icon: 'settings',
+ },
]
export function AppSidebar(props: ComponentProps<typeof Sidebar>) {
@@ -65,12 +76,11 @@ export function AppSidebar(props: ComponentProps<typeof Sidebar>) {
<StoreSwitcher />
</SidebarHeader>
<SidebarContent>
- <NavMain items={navigation} />
+ <NavMain items={navigation} bottomItems={bottomNavigation} />
</SidebarContent>
<SidebarFooter>
<NavUser />
</SidebarFooter>
- <SidebarRail />
</Sidebar>
)
}
diff --git a/packages/admin/src/components/nav-main.tsx b/packages/admin/src/components/nav-main.tsx
index f91ca46367..7c0699f14a 100644
--- a/packages/admin/src/components/nav-main.tsx
+++ b/packages/admin/src/components/nav-main.tsx
@@ -1,11 +1,5 @@
-import {
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
-} from '@/components/ui/collapsible'
import {
SidebarGroup,
- SidebarGroupLabel,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
@@ -13,71 +7,108 @@ import {
SidebarMenuSubButton,
SidebarMenuSubItem,
} from '@/components/ui/sidebar'
-import { Link } from '@tanstack/react-router'
-import { ChevronRightIcon } from 'lucide-react'
-import type { ReactNode } from 'react'
+import { TablerIcon } from '@/components/tabler-icon'
+import { Link, useRouterState } from '@tanstack/react-router'
+import type { NavItem } from '@/components/app-sidebar'
+
+function NavIcon({ name, isActive }: { name: string; isActive?: boolean }) {
+ return (
+ <span
+ className={
+ 'inline-flex shrink-0 items-center justify-center rounded-lg p-[0.2rem] mr-2 transition-colors duration-100 ' +
+ (isActive
+ ? 'bg-zinc-950 text-white'
+ : 'text-gray-400 group-hover/menu-button:text-zinc-950')
+ }
+ >
+ <TablerIcon name={name} className="size-[1.125rem]" />
+ </span>
+ )
+}
export function NavMain({
items,
+ bottomItems,
}: {
- items: {
- title: string
- url: string
- icon?: ReactNode
- isActive?: boolean
- items?: {
- title: string
- url: string
- }[]
- }[]
+ items: NavItem[]
+ bottomItems?: NavItem[]
}) {
+ const routerState = useRouterState()
+ const currentPath = routerState.location.pathname
+
return (
- <SidebarGroup>
- <SidebarGroupLabel>Navigation</SidebarGroupLabel>
- <SidebarMenu>
- {items.map((item) =>
- item.items ? (
- <Collapsible
- key={item.title}
- asChild
- defaultOpen={item.isActive}
- className="group/collapsible"
- >
- <SidebarMenuItem>
- <CollapsibleTrigger asChild>
- <SidebarMenuButton tooltip={item.title}>
- {item.icon}
+ <>
+ <SidebarGroup>
+ <SidebarMenu>
+ {items.map((item) => {
+ const isExactActive = currentPath === item.url
+ const isActive = isExactActive ||
+ (item.url !== '/' && currentPath.startsWith(item.url))
+ const hasActiveChild = item.items?.some(
+ (sub) => currentPath === sub.url || currentPath.startsWith(sub.url)
+ )
+ const showSubmenu = isActive || hasActiveChild
+
+ return (
+ <SidebarMenuItem key={item.title}>
+ <SidebarMenuButton
+ tooltip={item.title}
+ asChild
+ isActive={isActive && !hasActiveChild}
+ >
+ <Link to={item.url}>
+ <NavIcon name={item.icon} isActive={isActive && !hasActiveChild} />
<span>{item.title}</span>
- <ChevronRightIcon className="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
- </SidebarMenuButton>
- </CollapsibleTrigger>
- <CollapsibleContent>
+ </Link>
+ </SidebarMenuButton>
+ {item.items && showSubmenu && (
<SidebarMenuSub>
- {item.items.map((subItem) => (
- <SidebarMenuSubItem key={subItem.title}>
- <SidebarMenuSubButton asChild>
- <Link to={subItem.url}>
- <span>{subItem.title}</span>
- </Link>
- </SidebarMenuSubButton>
- </SidebarMenuSubItem>
- ))}
+ {item.items.map((subItem) => {
+ const subActive = currentPath === subItem.url ||
+ currentPath.startsWith(subItem.url)
+ return (
+ <SidebarMenuSubItem key={subItem.title}>
+ <SidebarMenuSubButton asChild isActive={subActive}>
+ <Link to={subItem.url}>
+ <span>{subItem.title}</span>
+ </Link>
+ </SidebarMenuSubButton>
+ </SidebarMenuSubItem>
+ )
+ })}
</SidebarMenuSub>
- </CollapsibleContent>
+ )}
</SidebarMenuItem>
- </Collapsible>
- ) : (
- <SidebarMenuItem key={item.title}>
- <SidebarMenuButton tooltip={item.title} asChild>
- <Link to={item.url}>
- {item.icon}
- <span>{item.title}</span>
- </Link>
- </SidebarMenuButton>
- </SidebarMenuItem>
- ),
- )}
- </SidebarMenu>
- </SidebarGroup>
+ )
+ })}
+ </SidebarMenu>
+ </SidebarGroup>
+
+ {bottomItems && bottomItems.length > 0 && (
+ <SidebarGroup className="mt-auto">
+ <SidebarMenu>
+ {bottomItems.map((item) => {
+ const isActive = currentPath === item.url ||
+ (item.url !== '/' && currentPath.startsWith(item.url))
+
+ return (
+ <SidebarMenuItem key={item.title}>
+ <SidebarMenuButton
+ tooltip={item.title}
+ asChild
+ isActive={isActive}
+ >
+ <Link to={item.url}>
+ <NavIcon name={item.icon} isActive={isActive} />
+ <span>{item.title}</span>
+ </Link>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ )
+ })}
+ </SidebarMenu>
+ </SidebarGroup>
+ )}
+ </>
)
}
diff --git a/packages/admin/src/components/nav-user.tsx b/packages/admin/src/components/nav-user.tsx
index 738dbff5b8..8c29307813 100644
--- a/packages/admin/src/components/nav-user.tsx
+++ b/packages/admin/src/components/nav-user.tsx
@@ -6,18 +6,16 @@ import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
- DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
import {
SidebarMenu,
- SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from '@/components/ui/sidebar'
import { useAuth } from '@/hooks/use-auth'
-import { ChevronsUpDownIcon, LogOutIcon } from 'lucide-react'
+import { TablerIcon } from '@/components/tabler-icon'
export function NavUser() {
const { isMobile } = useSidebar()
@@ -38,40 +36,58 @@ export function NavUser() {
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <SidebarMenuButton
- size="lg"
- className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
- >
- <Avatar className="h-8 w-8 rounded-lg">
- <AvatarFallback className="rounded-lg">{initials}</AvatarFallback>
+ <button className="flex w-full items-center gap-2 rounded-lg p-1 text-left hover:bg-gray-200/50 transition-colors duration-100 outline-none">
+ <Avatar className="size-8">
+ <AvatarFallback className="text-xs bg-zinc-950 text-white">
+ {initials}
+ </AvatarFallback>
</Avatar>
- <div className="grid flex-1 text-left text-sm leading-tight">
- <span className="truncate font-medium">{displayName}</span>
- <span className="truncate text-xs">{user.email}</span>
- </div>
- <ChevronsUpDownIcon className="ml-auto size-4" />
- </SidebarMenuButton>
+ <span className="flex-1 min-w-0 truncate text-sm text-zinc-950">
+ {displayName}
+ </span>
+ </button>
</DropdownMenuTrigger>
<DropdownMenuContent
- className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
- side={isMobile ? 'bottom' : 'right'}
+ className="w-56"
+ side={isMobile ? 'top' : 'right'}
align="end"
- sideOffset={4}
+ sideOffset={8}
>
- <DropdownMenuLabel className="p-0 font-normal">
- <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
- <Avatar className="h-8 w-8 rounded-lg">
- <AvatarFallback className="rounded-lg">{initials}</AvatarFallback>
+ {/* Profile card */}
+ <div className="px-2.5 py-2.5">
+ <div className="flex items-center gap-3 rounded-xl bg-muted p-2.5">
+ <Avatar className="size-8">
+ <AvatarFallback className="text-xs bg-zinc-950 text-white">
+ {initials}
+ </AvatarFallback>
</Avatar>
- <div className="grid flex-1 text-left text-sm leading-tight">
- <span className="truncate font-medium">{displayName}</span>
- <span className="truncate text-xs">{user.email}</span>
+ <div className="grid flex-1 min-w-0 text-sm leading-tight">
+ <span className="truncate font-medium text-zinc-950">{displayName}</span>
+ <span className="truncate text-xs text-muted-foreground">{user.email}</span>
</div>
</div>
- </DropdownMenuLabel>
+ </div>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem>
+ <TablerIcon name="user-scan" />
+ Edit Profile
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem>
+ <TablerIcon name="book" />
+ Documentation
+ </DropdownMenuItem>
+ <DropdownMenuItem>
+ <TablerIcon name="message-circle" />
+ Community
+ </DropdownMenuItem>
+ <DropdownMenuItem>
+ <TablerIcon name="mail" />
+ Contact Support
+ </DropdownMenuItem>
<DropdownMenuSeparator />
- <DropdownMenuItem onClick={logout}>
- <LogOutIcon />
+ <DropdownMenuItem onClick={logout} className="text-destructive focus:text-destructive">
+ <TablerIcon name="log-out" />
Log out
</DropdownMenuItem>
</DropdownMenuContent>
diff --git a/packages/admin/src/components/store-switcher.tsx b/packages/admin/src/components/store-switcher.tsx
index 0422dd8383..47ed1a6b4c 100644
--- a/packages/admin/src/components/store-switcher.tsx
+++ b/packages/admin/src/components/store-switcher.tsx
@@ -1,23 +1,57 @@
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu'
import {
SidebarMenu,
- SidebarMenuButton,
SidebarMenuItem,
+ SidebarMenuButton,
+ useSidebar,
} from '@/components/ui/sidebar'
-import { StoreIcon } from 'lucide-react'
+import { ChevronsUpDownIcon, ExternalLinkIcon } from 'lucide-react'
+import { TablerIcon } from '@/components/tabler-icon'
export function StoreSwitcher() {
+ const { isMobile } = useSidebar()
+
return (
<SidebarMenu>
<SidebarMenuItem>
- <SidebarMenuButton size="lg">
- <div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
- <StoreIcon className="size-4" />
- </div>
- <div className="grid flex-1 text-left text-sm leading-tight">
- <span className="truncate font-medium">Spree Store</span>
- <span className="truncate text-xs text-muted-foreground">Admin</span>
- </div>
- </SidebarMenuButton>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <SidebarMenuButton
+ size="lg"
+ className="h-[58px] gap-2 rounded-xl p-1 hover:bg-gray-200/50 data-[state=open]:bg-gray-200/50"
+ >
+ <div className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-zinc-950 text-white">
+ <TablerIcon name="building-store" className="size-4" />
+ </div>
+ <div className="grid flex-1 text-left text-sm leading-tight">
+ <span className="truncate font-medium text-zinc-950">Spree Store</span>
+ </div>
+ <ChevronsUpDownIcon className="ml-auto size-4 text-gray-400" />
+ </SidebarMenuButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ className="w-(--radix-dropdown-menu-trigger-width) min-w-48"
+ side={isMobile ? 'bottom' : 'right'}
+ align="start"
+ sideOffset={8}
+ >
+ <DropdownMenuItem>
+ <ExternalLinkIcon className="size-4" />
+ View Store
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem>
+ <TablerIcon name="palette" className="size-4" />
+ Edit Theme
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
</SidebarMenuItem>
</SidebarMenu>
)
diff --git a/packages/admin/src/components/table-toolbar.tsx b/packages/admin/src/components/table-toolbar.tsx
new file mode 100644
index 0000000000..7a237580d6
--- /dev/null
+++ b/packages/admin/src/components/table-toolbar.tsx
@@ -0,0 +1,562 @@
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { Badge } from '@/components/ui/badge'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuCheckboxItem,
+ DropdownMenuTrigger,
+ DropdownMenuSeparator,
+ DropdownMenuLabel,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+} from '@/components/ui/dropdown-menu'
+import {
+ Sheet,
+ SheetContent,
+ SheetHeader,
+ SheetTitle,
+ SheetDescription,
+ SheetFooter,
+ SheetClose,
+} from '@/components/ui/sheet'
+import {
+ SearchIcon,
+ XIcon,
+ FilterIcon,
+ ArrowUpDownIcon,
+ Columns3Icon,
+ PlusIcon,
+ Trash2Icon,
+} from 'lucide-react'
+import { useState, useCallback, useRef, useEffect } from 'react'
+
+// ============================================================================
+// Types
+// ============================================================================
+
+export interface ColumnDef {
+ key: string
+ label: string
+ sortable?: boolean
+ filterable?: boolean
+ default?: boolean
+ filterType?: 'string' | 'status' | 'boolean' | 'number' | 'date'
+ filterOptions?: { value: string; label: string }[]
+}
+
+export interface FilterRule {
+ id: string
+ field: string
+ operator: string
+ value: string
+}
+
+export interface SortOption {
+ field: string
+ direction: 'asc' | 'desc'
+}
+
+interface TableToolbarProps {
+ columns: ColumnDef[]
+ visibleColumns: string[]
+ onVisibleColumnsChange: (columns: string[]) => void
+ search: string
+ onSearchChange: (value: string) => void
+ searchPlaceholder?: string
+ sort: SortOption
+ onSortChange: (sort: SortOption) => void
+ filters: FilterRule[]
+ onFiltersChange: (filters: FilterRule[]) => void
+ actions?: React.ReactNode
+}
+
+// ============================================================================
+// Operators
+// ============================================================================
+
+const operatorsByType: Record<string, { value: string; label: string }[]> = {
+ string: [
+ { value: 'cont', label: 'contains' },
+ { value: 'eq', label: 'equals' },
+ { value: 'not_eq', label: 'does not equal' },
+ { value: 'start', label: 'starts with' },
+ { value: 'end', label: 'ends with' },
+ { value: 'present', label: 'is set' },
+ { value: 'blank', label: 'is not set' },
+ ],
+ status: [
+ { value: 'eq', label: 'is' },
+ { value: 'not_eq', label: 'is not' },
+ { value: 'in', label: 'is any of' },
+ { value: 'not_in', label: 'is none of' },
+ ],
+ boolean: [
+ { value: 'eq', label: 'is' },
+ ],
+ number: [
+ { value: 'eq', label: 'equals' },
+ { value: 'gt', label: 'greater than' },
+ { value: 'gteq', label: 'greater than or equal' },
+ { value: 'lt', label: 'less than' },
+ { value: 'lteq', label: 'less than or equal' },
+ ],
+ date: [
+ { value: 'eq', label: 'is' },
+ { value: 'gt', label: 'after' },
+ { value: 'lt', label: 'before' },
+ { value: 'gteq', label: 'on or after' },
+ { value: 'lteq', label: 'on or before' },
+ ],
+}
+
+function getOperators(type: string) {
+ return operatorsByType[type] || operatorsByType.string
+}
+
+const noValueOperators = ['present', 'blank']
+
+// ============================================================================
+// TableToolbar
+// ============================================================================
+
+export function TableToolbar({
+ columns,
+ visibleColumns,
+ onVisibleColumnsChange,
+ search,
+ onSearchChange,
+ searchPlaceholder = 'Search...',
+ sort,
+ onSortChange,
+ filters,
+ onFiltersChange,
+ actions,
+}: TableToolbarProps) {
+ const [filterOpen, setFilterOpen] = useState(false)
+ const searchRef = useRef<HTMLInputElement>(null)
+
+ const sortableColumns = columns.filter((c) => c.sortable)
+ const filterableColumns = columns.filter((c) => c.filterable)
+ const activeFilterCount = filters.length
+
+ return (
+ <>
+ <div className="flex flex-col lg:flex-row gap-3 items-start lg:items-center justify-between p-3 border-b border-gray-200">
+ <div className="flex gap-2 items-center flex-wrap">
+ {/* Search */}
+ <div className="relative lg:w-[300px]">
+ <SearchIcon className="absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-gray-600 pointer-events-none" />
+ <Input
+ ref={searchRef}
+ placeholder={searchPlaceholder}
+ value={search}
+ onChange={(e) => onSearchChange(e.target.value)}
+ className="pl-8 pr-8 h-[2.125rem]"
+ />
+ {search && (
+ <button
+ type="button"
+ className="absolute right-2 top-1/2 -translate-y-1/2 p-0.5 text-gray-400 hover:text-gray-600"
+ onClick={() => {
+ onSearchChange('')
+ searchRef.current?.focus()
+ }}
+ >
+ <XIcon className="size-3.5" />
+ </button>
+ )}
+ </div>
+ </div>
+
+ <div className="flex gap-2 items-center">
+ {/* Filter button */}
+ {filterableColumns.length > 0 && (
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-[2.125rem]"
+ onClick={() => setFilterOpen(true)}
+ >
+ <FilterIcon className="size-4" />
+ Filters
+ {activeFilterCount > 0 && (
+ <Badge className="ml-1 px-1.5 py-0 text-xs">{activeFilterCount}</Badge>
+ )}
+ </Button>
+ )}
+
+ {/* Sort dropdown */}
+ {sortableColumns.length > 0 && (
+ <SortDropdown
+ columns={sortableColumns}
+ sort={sort}
+ onSortChange={onSortChange}
+ />
+ )}
+
+ {/* Column selector */}
+ <ColumnSelector
+ columns={columns.filter((c) => c.default !== undefined)}
+ visibleColumns={visibleColumns}
+ onVisibleColumnsChange={onVisibleColumnsChange}
+ />
+
+ {actions}
+ </div>
+ </div>
+
+ {/* Active filter badges */}
+ {filters.length > 0 && (
+ <div className="flex gap-2 flex-wrap px-3 py-2 border-b border-gray-200">
+ {filters.map((filter) => {
+ const col = columns.find((c) => c.key === filter.field)
+ const ops = getOperators(col?.filterType ?? 'string')
+ const opLabel = ops.find((o) => o.value === filter.operator)?.label ?? filter.operator
+ return (
+ <Badge key={filter.id} className="gap-1.5 pr-1">
+ <span className="font-medium">{col?.label ?? filter.field}</span>
+ <span className="text-muted-foreground">{opLabel}</span>
+ {!noValueOperators.includes(filter.operator) && (
+ <span className="font-medium">{filter.value}</span>
+ )}
+ <button
+ type="button"
+ className="ml-0.5 p-0.5 rounded-sm hover:bg-gray-200"
+ onClick={() => onFiltersChange(filters.filter((f) => f.id !== filter.id))}
+ >
+ <XIcon className="size-3" />
+ </button>
+ </Badge>
+ )
+ })}
+ <button
+ type="button"
+ className="text-xs text-muted-foreground hover:text-foreground"
+ onClick={() => onFiltersChange([])}
+ >
+ Clear all
+ </button>
+ </div>
+ )}
+
+ {/* Filter drawer */}
+ <FilterDrawer
+ open={filterOpen}
+ onOpenChange={setFilterOpen}
+ columns={filterableColumns}
+ filters={filters}
+ onApply={onFiltersChange}
+ />
+ </>
+ )
+}
+
+// ============================================================================
+// Sort Dropdown
+// ============================================================================
+
+function SortDropdown({
+ columns,
+ sort,
+ onSortChange,
+}: {
+ columns: ColumnDef[]
+ sort: SortOption
+ onSortChange: (sort: SortOption) => void
+}) {
+ const currentCol = columns.find((c) => c.key === sort.field)
+ const currentLabel = currentCol?.label ?? 'Sort'
+ const dirLabel = sort.direction === 'asc' ? 'A-Z' : 'Z-A'
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm" className="h-[2.125rem]">
+ <ArrowUpDownIcon className="size-4" />
+ {currentCol ? `${currentLabel} (${dirLabel})` : 'Sort'}
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="min-w-48">
+ <DropdownMenuLabel>Sort by</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuRadioGroup
+ value={`${sort.field}:${sort.direction}`}
+ onValueChange={(val) => {
+ const [field, direction] = val.split(':')
+ onSortChange({ field, direction: direction as 'asc' | 'desc' })
+ }}
+ >
+ {columns.map((col) => (
+ <div key={col.key}>
+ <DropdownMenuRadioItem value={`${col.key}:asc`}>
+ {col.label} (A-Z)
+ </DropdownMenuRadioItem>
+ <DropdownMenuRadioItem value={`${col.key}:desc`}>
+ {col.label} (Z-A)
+ </DropdownMenuRadioItem>
+ </div>
+ ))}
+ </DropdownMenuRadioGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
+
+// ============================================================================
+// Column Selector
+// ============================================================================
+
+function ColumnSelector({
+ columns,
+ visibleColumns,
+ onVisibleColumnsChange,
+}: {
+ columns: ColumnDef[]
+ visibleColumns: string[]
+ onVisibleColumnsChange: (columns: string[]) => void
+}) {
+ const defaults = columns.filter((c) => c.default).map((c) => c.key)
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm" className="h-[2.125rem]">
+ <Columns3Icon className="size-4" />
+ Columns
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="min-w-48">
+ <DropdownMenuLabel>Visible columns</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ {columns.map((col) => (
+ <DropdownMenuCheckboxItem
+ key={col.key}
+ checked={visibleColumns.includes(col.key)}
+ onCheckedChange={(checked) => {
+ onVisibleColumnsChange(
+ checked
+ ? [...visibleColumns, col.key]
+ : visibleColumns.filter((k) => k !== col.key),
+ )
+ }}
+ onSelect={(e) => e.preventDefault()}
+ >
+ {col.label}
+ </DropdownMenuCheckboxItem>
+ ))}
+ <DropdownMenuSeparator />
+ <div className="px-1 py-1">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="w-full justify-center"
+ onClick={() => onVisibleColumnsChange(defaults)}
+ >
+ Reset to default
+ </Button>
+ </div>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
+
+// ============================================================================
+// Filter Drawer
+// ============================================================================
+
+function FilterDrawer({
+ open,
+ onOpenChange,
+ columns,
+ filters: initialFilters,
+ onApply,
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ columns: ColumnDef[]
+ filters: FilterRule[]
+ onApply: (filters: FilterRule[]) => void
+}) {
+ const [draft, setDraft] = useState<FilterRule[]>(initialFilters)
+
+ // Sync draft when opened
+ useEffect(() => {
+ if (open) setDraft(initialFilters)
+ }, [open, initialFilters])
+
+ const addFilter = useCallback(() => {
+ const first = columns[0]
+ if (!first) return
+ setDraft((prev) => [
+ ...prev,
+ {
+ id: crypto.randomUUID(),
+ field: first.key,
+ operator: getOperators(first.filterType ?? 'string')[0].value,
+ value: '',
+ },
+ ])
+ }, [columns])
+
+ const updateFilter = useCallback((id: string, update: Partial<FilterRule>) => {
+ setDraft((prev) =>
+ prev.map((f) => (f.id === id ? { ...f, ...update } : f)),
+ )
+ }, [])
+
+ const removeFilter = useCallback((id: string) => {
+ setDraft((prev) => prev.filter((f) => f.id !== id))
+ }, [])
+
+ function handleApply() {
+ // Remove filters with no value (unless operator doesn't need one)
+ const valid = draft.filter(
+ (f) => noValueOperators.includes(f.operator) || f.value.trim() !== '',
+ )
+ onApply(valid)
+ onOpenChange(false)
+ }
+
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent side="right" showCloseButton={false}>
+ <SheetHeader>
+ <SheetTitle>Filters</SheetTitle>
+ <SheetDescription className="sr-only">Build filters for the table</SheetDescription>
+ <SheetClose asChild>
+ <Button variant="ghost" size="icon-sm">
+ <XIcon />
+ </Button>
+ </SheetClose>
+ </SheetHeader>
+
+ <div className="flex-1 overflow-y-auto p-4 space-y-3">
+ {draft.map((filter) => {
+ const col = columns.find((c) => c.key === filter.field)
+ const type = col?.filterType ?? 'string'
+ const ops = getOperators(type)
+
+ return (
+ <div
+ key={filter.id}
+ className="flex items-center gap-2 p-3 bg-gray-50 rounded-lg"
+ >
+ {/* Field select */}
+ <select
+ className="flex-1 rounded-lg border border-border bg-white py-1.5 px-2 text-sm outline-none focus:outline-2 focus:outline-offset-2 focus:outline-blue-500"
+ value={filter.field}
+ onChange={(e) => {
+ const newCol = columns.find((c) => c.key === e.target.value)
+ const newOps = getOperators(newCol?.filterType ?? 'string')
+ updateFilter(filter.id, {
+ field: e.target.value,
+ operator: newOps[0].value,
+ value: '',
+ })
+ }}
+ >
+ {columns.map((c) => (
+ <option key={c.key} value={c.key}>
+ {c.label}
+ </option>
+ ))}
+ </select>
+
+ {/* Operator select */}
+ <select
+ className="w-[140px] shrink-0 rounded-lg border border-border bg-white py-1.5 px-2 text-sm outline-none focus:outline-2 focus:outline-offset-2 focus:outline-blue-500"
+ value={filter.operator}
+ onChange={(e) => updateFilter(filter.id, { operator: e.target.value })}
+ >
+ {ops.map((op) => (
+ <option key={op.value} value={op.value}>
+ {op.label}
+ </option>
+ ))}
+ </select>
+
+ {/* Value input */}
+ {!noValueOperators.includes(filter.operator) && (
+ col?.filterType === 'status' && col.filterOptions ? (
+ <select
+ className="flex-1 rounded-lg border border-border bg-white py-1.5 px-2 text-sm outline-none focus:outline-2 focus:outline-offset-2 focus:outline-blue-500"
+ value={filter.value}
+ onChange={(e) => updateFilter(filter.id, { value: e.target.value })}
+ >
+ <option value="">Select...</option>
+ {col.filterOptions.map((opt) => (
+ <option key={opt.value} value={opt.value}>
+ {opt.label}
+ </option>
+ ))}
+ </select>
+ ) : col?.filterType === 'boolean' ? (
+ <select
+ className="flex-1 rounded-lg border border-border bg-white py-1.5 px-2 text-sm outline-none focus:outline-2 focus:outline-offset-2 focus:outline-blue-500"
+ value={filter.value}
+ onChange={(e) => updateFilter(filter.id, { value: e.target.value })}
+ >
+ <option value="">Select...</option>
+ <option value="true">Yes</option>
+ <option value="false">No</option>
+ </select>
+ ) : (
+ <input
+ type={col?.filterType === 'number' ? 'number' : col?.filterType === 'date' ? 'date' : 'text'}
+ className="flex-1 rounded-lg border border-border bg-white py-1.5 px-2 text-sm outline-none focus:outline-2 focus:outline-offset-2 focus:outline-blue-500"
+ placeholder="Enter value..."
+ value={filter.value}
+ onChange={(e) => updateFilter(filter.id, { value: e.target.value })}
+ />
+ )
+ )}
+
+ {/* Remove button */}
+ <button
+ type="button"
+ className="p-1.5 rounded-lg text-red-600 hover:bg-red-50 shrink-0"
+ onClick={() => removeFilter(filter.id)}
+ >
+ <Trash2Icon className="size-4" />
+ </button>
+ </div>
+ )
+ })}
+
+ {draft.length === 0 && (
+ <p className="text-sm text-muted-foreground text-center py-6">
+ No filters applied. Click "Add filter" to get started.
+ </p>
+ )}
+
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={addFilter}
+ >
+ <PlusIcon className="size-4" />
+ Add filter
+ </Button>
+ </div>
+
+ <SheetFooter>
+ <SheetClose asChild>
+ <Button variant="outline">Discard</Button>
+ </SheetClose>
+ <div className="flex gap-2">
+ <Button
+ variant="outline"
+ onClick={() => setDraft([])}
+ >
+ Clear all
+ </Button>
+ <Button onClick={handleApply}>
+ Apply filters
+ </Button>
+ </div>
+ </SheetFooter>
+ </SheetContent>
+ </Sheet>
+ )
+}
diff --git a/packages/admin/src/components/tabler-icon.tsx b/packages/admin/src/components/tabler-icon.tsx
new file mode 100644
index 0000000000..cc5f8e8154
--- /dev/null
+++ b/packages/admin/src/components/tabler-icon.tsx
@@ -0,0 +1,50 @@
+import {
+ HomeIcon,
+ InboxIcon,
+ PackageIcon,
+ UsersIcon,
+ TagIcon,
+ BarChart3Icon,
+ SettingsIcon,
+ ReceiptIcon,
+ PlugIcon,
+ StoreIcon,
+ PaletteIcon,
+ UserIcon,
+ LogOutIcon,
+ BookOpenIcon,
+ MessageCircleIcon,
+ MailIcon,
+ type LucideIcon,
+} from 'lucide-react'
+import { cn } from '@/lib/utils'
+
+const iconMap: Record<string, LucideIcon> = {
+ 'home': HomeIcon,
+ 'inbox': InboxIcon,
+ 'package': PackageIcon,
+ 'users': UsersIcon,
+ 'discount': TagIcon,
+ 'chart-bar': BarChart3Icon,
+ 'settings': SettingsIcon,
+ 'receipt-refund': ReceiptIcon,
+ 'plug-connected': PlugIcon,
+ 'building-store': StoreIcon,
+ 'palette': PaletteIcon,
+ 'user-scan': UserIcon,
+ 'log-out': LogOutIcon,
+ 'book': BookOpenIcon,
+ 'message-circle': MessageCircleIcon,
+ 'mail': MailIcon,
+}
+
+interface TablerIconProps {
+ name: string
+ className?: string
+}
+
+export function TablerIcon({ name, className }: TablerIconProps) {
+ const Icon = iconMap[name] ?? StoreIcon
+
+ return <Icon className={cn('size-4', className)} />
+}
diff --git a/packages/admin/src/components/ui/badge.tsx b/packages/admin/src/components/ui/badge.tsx
new file mode 100644
index 0000000000..0fc9c244e7
--- /dev/null
+++ b/packages/admin/src/components/ui/badge.tsx
@@ -0,0 +1,66 @@
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const badgeVariants = cva(
+ "inline-flex items-center whitespace-nowrap text-xs font-normal leading-none rounded-md py-1 px-2",
+ {
+ variants: {
+ variant: {
+ default: "bg-white text-gray-600 border border-gray-200",
+ active: "bg-green-200 text-green-900 border border-transparent",
+ warning: "bg-yellow-200 text-yellow-900 border border-transparent",
+ danger: "bg-red-100 text-red-900 border border-transparent",
+ info: "bg-blue-50 text-blue-900 border border-transparent",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+function Badge({
+ className,
+ variant,
+ ...props
+}: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
+ return (
+ <span className={cn(badgeVariants({ variant }), className)} {...props} />
+ )
+}
+
+const statusVariantMap: Record<string, VariantProps<typeof badgeVariants>["variant"]> = {
+ active: "active",
+ complete: "active",
+ completed: "active",
+ paid: "active",
+ shipped: "active",
+ published: "active",
+ approved: "active",
+ draft: "default",
+ pending: "default",
+ processing: "default",
+ inactive: "default",
+ archived: "warning",
+ returned: "warning",
+ backorder: "warning",
+ balance_due: "warning",
+ credit_owed: "warning",
+ canceled: "danger",
+ failed: "danger",
+ void: "danger",
+ error: "danger",
+ rejected: "danger",
+}
+
+function StatusBadge({ status, className }: { status: string; className?: string }) {
+ const variant = statusVariantMap[status] ?? "default"
+ return (
+ <Badge variant={variant} className={cn("capitalize", className)}>
+ {status.replace(/_/g, " ")}
+ </Badge>
+ )
+}
+
+export { Badge, StatusBadge, badgeVariants }
diff --git a/packages/admin/src/components/ui/button.tsx b/packages/admin/src/components/ui/button.tsx
index ec4be64ba7..5b21df0a92 100644
--- a/packages/admin/src/components/ui/button.tsx
+++ b/packages/admin/src/components/ui/button.tsx
@@ -5,33 +5,30 @@ import { Slot } from "radix-ui"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
- "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "group/button inline-flex shrink-0 items-center justify-center gap-2 rounded-xl border border-transparent text-sm font-medium whitespace-nowrap cursor-pointer select-none no-underline transition-colors duration-100 ease-linear outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-500 disabled:pointer-events-none disabled:opacity-70 disabled:cursor-not-allowed aria-invalid:border-destructive [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
- default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
+ default: "bg-primary text-primary-foreground shadow-xs hover:bg-zinc-800",
outline:
- "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
+ "border-border bg-muted text-foreground shadow-xs hover:bg-gray-100 hover:text-foreground aria-expanded:bg-gray-100",
secondary:
- "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
+ "bg-blue-50 text-blue-900 border-blue-100/75 shadow-xs hover:border-blue-100 hover:bg-blue-100/75",
ghost:
- "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
+ "hover:bg-accent hover:text-accent-foreground aria-expanded:bg-accent",
destructive:
- "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
+ "text-destructive bg-muted border-border shadow-xs hover:bg-red-100",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
- default:
- "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
- lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
- icon: "size-8",
- "icon-xs":
- "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
- "icon-sm":
- "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
- "icon-lg": "size-9",
+ default: "h-9 px-3 py-1.5",
+ xs: "h-6 gap-1 rounded-lg px-2 text-xs [&_svg:not([class*='size-'])]:size-3",
+ sm: "h-7 gap-1 rounded-lg px-2 py-1 text-sm [&_svg:not([class*='size-'])]:size-3.5",
+ lg: "h-10 px-3 py-2 text-base",
+ icon: "size-9",
+ "icon-xs": "size-6 rounded-lg [&_svg:not([class*='size-'])]:size-3",
+ "icon-sm": "size-7 rounded-lg",
+ "icon-lg": "size-10",
},
},
defaultVariants: {
diff --git a/packages/admin/src/components/ui/card.tsx b/packages/admin/src/components/ui/card.tsx
index 9bd5a2544b..ca2da1d324 100644
--- a/packages/admin/src/components/ui/card.tsx
+++ b/packages/admin/src/components/ui/card.tsx
@@ -4,15 +4,13 @@ import { cn } from "@/lib/utils"
function Card({
className,
- size = "default",
...props
-}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
+}: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
- data-size={size}
className={cn(
- "group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
+ "group/card flex flex-col min-w-0 break-words bg-white border border-border rounded-xl",
className
)}
{...props}
@@ -25,7 +23,7 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-header"
className={cn(
- "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",
+ "flex items-center p-5 pr-3 h-14 border-b border-gray-100 rounded-t-[calc(var(--radius-xl)-1px)]",
className
)}
{...props}
@@ -38,7 +36,7 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-title"
className={cn(
- "text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
+ "text-lg font-medium flex items-center gap-2",
className
)}
{...props}
@@ -60,10 +58,7 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
- className={cn(
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
- className
- )}
+ className={cn("ml-auto", className)}
{...props}
/>
)
@@ -73,7 +68,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
- className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
+ className={cn("p-5", className)}
{...props}
/>
)
@@ -84,7 +79,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="card-footer"
className={cn(
- "flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3",
+ "flex items-center p-5 bg-transparent border-t border-gray-100 rounded-b-[calc(var(--radius-xl)-1px)]",
className
)}
{...props}
diff --git a/packages/admin/src/components/ui/data-table.tsx b/packages/admin/src/components/ui/data-table.tsx
new file mode 100644
index 0000000000..a33bf7e9c5
--- /dev/null
+++ b/packages/admin/src/components/ui/data-table.tsx
@@ -0,0 +1,69 @@
+import { cn } from "@/lib/utils"
+import type { ReactNode } from "react"
+
+function Table({ className, ...props }: React.ComponentProps<"table">) {
+ return (
+ <div className="overflow-x-auto">
+ <table
+ className={cn("w-full align-top text-foreground", className)}
+ {...props}
+ />
+ </div>
+ )
+}
+
+function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
+ return <thead className={cn("align-bottom", className)} {...props} />
+}
+
+function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
+ return <tbody className={cn("align-middle", className)} {...props} />
+}
+
+function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
+ return (
+ <tr
+ className={cn(
+ "group/row hover:bg-gray-50/75 last:*:border-b-0",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TableHead({ className, ...props }: React.ComponentProps<"th">) {
+ return (
+ <th
+ className={cn(
+ "text-left text-sm font-medium text-gray-600 bg-muted py-2 px-3 border-b border-gray-200 whitespace-nowrap first:pl-4 last:pr-4 first:rounded-tl-2xl last:rounded-tr-2xl",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TableCell({ className, ...props }: React.ComponentProps<"td">) {
+ return (
+ <td
+ className={cn(
+ "py-4 px-3 border-b border-gray-200 align-middle first:pl-4 last:pr-4 group-last/row:first:rounded-bl-xl group-last/row:last:rounded-br-xl",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function TableEmpty({ children, colSpan }: { children: ReactNode; colSpan: number }) {
+ return (
+ <tr>
+ <td colSpan={colSpan} className="py-12 text-center text-muted-foreground">
+ {children}
+ </td>
+ </tr>
+ )
+}
+
+export { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TableEmpty }
diff --git a/packages/admin/src/components/ui/dropdown-menu.tsx b/packages/admin/src/components/ui/dropdown-menu.tsx
index c263ad57ea..19a539217b 100644
--- a/packages/admin/src/components/ui/dropdown-menu.tsx
+++ b/packages/admin/src/components/ui/dropdown-menu.tsx
@@ -43,7 +43,10 @@ function DropdownMenuContent({
data-slot="dropdown-menu-content"
sideOffset={sideOffset}
align={align}
- className={cn("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
+ className={cn(
+ "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-40 max-w-80 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl bg-white p-1 text-foreground shadow-[0px_0px_0px_1px_rgba(179,179,179,0.5),0px_6px_12px_-3px_rgba(179,179,179,0.35),0px_6px_18px_0px_rgba(179,179,179,0.35)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
+ className
+ )}
{...props}
/>
</DropdownMenuPrimitive.Portal>
@@ -73,7 +76,7 @@ function DropdownMenuItem({
data-inset={inset}
data-variant={variant}
className={cn(
- "group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
+ "group/dropdown-menu-item relative flex cursor-default items-center gap-3 rounded-xl px-2.5 py-2 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
@@ -95,7 +98,7 @@ function DropdownMenuCheckboxItem({
data-slot="dropdown-menu-checkbox-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-default items-center gap-3 rounded-xl py-2 pr-8 pl-2.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
checked={checked}
@@ -106,8 +109,7 @@ function DropdownMenuCheckboxItem({
data-slot="dropdown-menu-checkbox-item-indicator"
>
<DropdownMenuPrimitive.ItemIndicator>
- <CheckIcon
- />
+ <CheckIcon />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
@@ -139,7 +141,7 @@ function DropdownMenuRadioItem({
data-slot="dropdown-menu-radio-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-default items-center gap-3 rounded-xl py-2 pr-8 pl-2.5 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
@@ -149,8 +151,7 @@ function DropdownMenuRadioItem({
data-slot="dropdown-menu-radio-item-indicator"
>
<DropdownMenuPrimitive.ItemIndicator>
- <CheckIcon
- />
+ <CheckIcon />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
@@ -170,7 +171,7 @@ function DropdownMenuLabel({
data-slot="dropdown-menu-label"
data-inset={inset}
className={cn(
- "px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
+ "px-2.5 py-2 text-sm font-normal text-muted-foreground data-inset:pl-7",
className
)}
{...props}
@@ -185,7 +186,7 @@ function DropdownMenuSeparator({
return (
<DropdownMenuPrimitive.Separator
data-slot="dropdown-menu-separator"
- className={cn("-mx-1 my-1 h-px bg-border", className)}
+ className={cn("-mx-1 my-1 h-px bg-gray-100", className)}
{...props}
/>
)
@@ -199,7 +200,7 @@ function DropdownMenuShortcut({
<span
data-slot="dropdown-menu-shortcut"
className={cn(
- "ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",
+ "ml-auto text-xs tracking-widest text-muted-foreground",
className
)}
{...props}
@@ -226,7 +227,7 @@ function DropdownMenuSubTrigger({
data-slot="dropdown-menu-sub-trigger"
data-inset={inset}
className={cn(
- "flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "flex cursor-default items-center gap-3 rounded-xl px-2.5 py-2 text-sm outline-hidden select-none transition-colors duration-75 focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
@@ -244,7 +245,10 @@ function DropdownMenuSubContent({
return (
<DropdownMenuPrimitive.SubContent
data-slot="dropdown-menu-sub-content"
- className={cn("z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
+ className={cn(
+ "z-50 min-w-[96px] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-2xl bg-white p-1 text-foreground shadow-[0px_0px_0px_1px_rgba(179,179,179,0.5),0px_6px_12px_-3px_rgba(179,179,179,0.35),0px_6px_18px_0px_rgba(179,179,179,0.35)] duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
+ className
+ )}
{...props}
/>
)
diff --git a/packages/admin/src/components/ui/input.tsx b/packages/admin/src/components/ui/input.tsx
index d763cd9ab0..27912dee3a 100644
--- a/packages/admin/src/components/ui/input.tsx
+++ b/packages/admin/src/components/ui/input.tsx
@@ -8,7 +8,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
type={type}
data-slot="input"
className={cn(
- "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
+ "block w-full min-w-0 rounded-lg border border-border bg-white py-2 px-3 text-sm font-normal leading-normal text-foreground shadow-xs transition-all duration-100 ease-in-out outline-none placeholder:text-muted-foreground focus:outline-2 focus:outline-offset-2 focus:outline-blue-500 focus:border-border focus:ring-0 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-gray-50 disabled:border-gray-100 disabled:text-muted-foreground disabled:shadow-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground aria-invalid:border-destructive",
className
)}
{...props}
diff --git a/packages/admin/src/components/ui/label.tsx b/packages/admin/src/components/ui/label.tsx
index f752f82ba6..24cc0018cf 100644
--- a/packages/admin/src/components/ui/label.tsx
+++ b/packages/admin/src/components/ui/label.tsx
@@ -11,7 +11,7 @@ function Label({
<LabelPrimitive.Root
data-slot="label"
className={cn(
- "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
+ "flex items-center gap-2 text-sm font-medium leading-none cursor-pointer mb-2 select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
className
)}
{...props}
diff --git a/packages/admin/src/components/ui/pagination.tsx b/packages/admin/src/components/ui/pagination.tsx
new file mode 100644
index 0000000000..f8fa63f884
--- /dev/null
+++ b/packages/admin/src/components/ui/pagination.tsx
@@ -0,0 +1,83 @@
+import { Button } from "@/components/ui/button"
+import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
+
+interface PaginationMeta {
+ page: number
+ limit: number
+ count: number
+ pages: number
+ from: number
+ to: number
+ previous: number | null
+ next: number | null
+}
+
+interface PaginationProps {
+ meta: PaginationMeta
+ onPageChange: (page: number) => void
+}
+
+export function Pagination({ meta, onPageChange }: PaginationProps) {
+ if (meta.pages <= 1) return null
+
+ return (
+ <div className="flex items-center justify-between border-t border-gray-200 bg-white px-4 py-3 rounded-b-2xl">
+ <div className="text-sm text-muted-foreground">
+ {meta.from}–{meta.to} of {meta.count}
+ </div>
+ <div className="flex items-center gap-1">
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ disabled={!meta.previous}
+ onClick={() => meta.previous && onPageChange(meta.previous)}
+ >
+ <ChevronLeftIcon className="size-4" />
+ </Button>
+ {generatePageNumbers(meta.page, meta.pages).map((p, i) =>
+ p === "..." ? (
+ <span key={`ellipsis-${i}`} className="px-1 text-sm text-muted-foreground">
+ ...
+ </span>
+ ) : (
+ <Button
+ key={p}
+ variant={p === meta.page ? "default" : "ghost"}
+ size="icon-sm"
+ onClick={() => onPageChange(p as number)}
+ >
+ {p}
+ </Button>
+ ),
+ )}
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ disabled={!meta.next}
+ onClick={() => meta.next && onPageChange(meta.next)}
+ >
+ <ChevronRightIcon className="size-4" />
+ </Button>
+ </div>
+ </div>
+ )
+}
+
+function generatePageNumbers(current: number, total: number): (number | "...")[] {
+ if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
+
+ const pages: (number | "...")[] = [1]
+
+ if (current > 3) pages.push("...")
+
+ const start = Math.max(2, current - 1)
+ const end = Math.min(total - 1, current + 1)
+ for (let i = start; i <= end; i++) pages.push(i)
+
+ if (current < total - 2) pages.push("...")
+
+ pages.push(total)
+ return pages
+}
+
+export type { PaginationMeta }
diff --git a/packages/admin/src/components/ui/sheet.tsx b/packages/admin/src/components/ui/sheet.tsx
index bcb2527569..686142c34b 100644
--- a/packages/admin/src/components/ui/sheet.tsx
+++ b/packages/admin/src/components/ui/sheet.tsx
@@ -37,7 +37,7 @@ function SheetOverlay({
<SheetPrimitive.Overlay
data-slot="sheet-overlay"
className={cn(
- "fixed inset-0 z-50 bg-black/10 duration-100 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
+ "fixed inset-0 z-50 bg-white/80 duration-200 data-ending-style:opacity-0 data-starting-style:opacity-0 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
className
)}
{...props}
@@ -62,7 +62,13 @@ function SheetContent({
data-slot="sheet-content"
data-side={side}
className={cn(
- "fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",
+ "fixed z-50 flex flex-col bg-white text-sm shadow-[0px_0px_0px_1px_rgba(179,179,179,0.5),0px_6px_12px_-3px_rgba(179,179,179,0.35),0px_6px_18px_0px_rgba(179,179,179,0.35)] transition duration-250 ease-out",
+ "data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-[calc(100dvh-1rem)] data-[side=right]:max-h-[calc(100dvh-1rem)] data-[side=right]:w-[calc(100vw-1rem)] data-[side=right]:max-w-[600px] data-[side=right]:min-w-[320px] data-[side=right]:m-2 data-[side=right]:rounded-2xl",
+ "data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:sm:max-w-sm",
+ "data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t",
+ "data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b",
+ "data-open:animate-in data-open:fade-in-0 data-[side=right]:data-open:slide-in-from-right-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=top]:data-open:slide-in-from-top-10",
+ "data-closed:animate-out data-closed:fade-out-0 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=top]:data-closed:slide-out-to-top-10",
className
)}
{...props}
@@ -75,8 +81,7 @@ function SheetContent({
className="absolute top-3 right-3"
size="icon-sm"
>
- <XIcon
- />
+ <XIcon />
<span className="sr-only">Close</span>
</Button>
</SheetPrimitive.Close>
@@ -90,7 +95,7 @@ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-header"
- className={cn("flex flex-col gap-0.5 p-4", className)}
+ className={cn("flex items-center justify-between p-4 border-b border-gray-100", className)}
{...props}
/>
)
@@ -100,7 +105,7 @@ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="sheet-footer"
- className={cn("mt-auto flex flex-col gap-2 p-4", className)}
+ className={cn("flex items-center justify-between p-4 bg-muted border-t border-gray-100 rounded-b-2xl", className)}
{...props}
/>
)
@@ -113,7 +118,7 @@ function SheetTitle({
return (
<SheetPrimitive.Title
data-slot="sheet-title"
- className={cn("text-base font-medium text-foreground", className)}
+ className={cn("text-base font-semibold text-foreground", className)}
{...props}
/>
)
diff --git a/packages/admin/src/components/ui/sidebar.tsx b/packages/admin/src/components/ui/sidebar.tsx
index e245caa3e8..54aaf5ab81 100644
--- a/packages/admin/src/components/ui/sidebar.tsx
+++ b/packages/admin/src/components/ui/sidebar.tsx
@@ -24,8 +24,8 @@ import { PanelLeftIcon } from "lucide-react"
const SIDEBAR_COOKIE_NAME = "sidebar_state"
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
-const SIDEBAR_WIDTH = "16rem"
-const SIDEBAR_WIDTH_MOBILE = "18rem"
+const SIDEBAR_WIDTH = "220px"
+const SIDEBAR_WIDTH_MOBILE = "220px"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
@@ -239,7 +239,7 @@ function Sidebar({
<div
data-sidebar="sidebar"
data-slot="sidebar-inner"
- className="flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
+ className="flex size-full flex-col bg-sidebar shadow-[inset_-1px_0_0_var(--color-sidebar-border)] group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border"
>
{children}
</div>
@@ -331,7 +331,7 @@ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="sidebar-header"
data-sidebar="header"
- className={cn("flex flex-col gap-2 p-2", className)}
+ className={cn("flex flex-col gap-0 px-2", className)}
{...props}
/>
)
@@ -342,7 +342,7 @@ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="sidebar-footer"
data-sidebar="footer"
- className={cn("flex flex-col gap-2 p-2", className)}
+ className={cn("flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border", className)}
{...props}
/>
)
@@ -368,7 +368,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
+ "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
className
)}
{...props}
@@ -381,7 +381,7 @@ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="sidebar-group"
data-sidebar="group"
- className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
+ className={cn("relative flex w-full min-w-0 flex-col px-3 py-0", className)}
{...props}
/>
)
@@ -446,7 +446,7 @@ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
<ul
data-slot="sidebar-menu"
data-sidebar="menu"
- className={cn("flex w-full min-w-0 flex-col gap-0", className)}
+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}
{...props}
/>
)
@@ -464,11 +464,11 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
}
const sidebarMenuButtonVariants = cva(
- "peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
+ "peer/menu-button group/menu-button flex w-full items-center overflow-hidden rounded-xl p-1 text-left text-sm text-gray-800 ring-sidebar-ring outline-hidden transition-colors duration-100 ease-in-out group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-gray-200/50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-gray-200/50 data-open:hover:text-zinc-950 data-active:bg-white data-active:text-zinc-950 data-active:font-semibold data-active:shadow-[rgba(0,0,0,0)_0px_0px_0px_0px,rgba(0,0,0,0)_0px_0px_0px_0px,rgba(0,0,0,0.04)_0px_0px_0px_1px,rgba(0,0,0,0.04)_0px_1px_2px_-1px,rgba(0,0,0,0.02)_0px_2px_4px_0px] [&>span:last-child]:truncate",
{
variants: {
variant: {
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
+ default: "",
outline:
"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
},
@@ -622,7 +622,7 @@ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
data-slot="sidebar-menu-sub"
data-sidebar="menu-sub"
className={cn(
- "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
+ "relative ml-4 flex min-w-0 flex-col pt-1 pl-4 group-data-[collapsible=icon]:hidden before:absolute before:left-0 before:top-0 before:bottom-1 before:w-px before:bg-gray-200",
className
)}
{...props}
@@ -664,7 +664,7 @@ function SidebarMenuSubButton({
data-size={size}
data-active={isActive}
className={cn(
- "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
+ "relative flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-xl p-1 text-gray-800 ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-gray-50 hover:text-zinc-950 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:font-semibold data-active:text-zinc-950 data-active:bg-transparent data-active:shadow-none data-active:before:absolute data-active:before:-left-4 data-active:before:top-[10%] data-active:before:h-[80%] data-active:before:w-[3px] data-active:before:rounded-sm data-active:before:bg-zinc-950 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
className
)}
{...props}
diff --git a/packages/admin/src/components/ui/tooltip.tsx b/packages/admin/src/components/ui/tooltip.tsx
index bb1ea52342..561b5e90f8 100644
--- a/packages/admin/src/components/ui/tooltip.tsx
+++ b/packages/admin/src/components/ui/tooltip.tsx
@@ -32,7 +32,7 @@ function TooltipTrigger({
function TooltipContent({
className,
- sideOffset = 0,
+ sideOffset = 4,
children,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
@@ -42,13 +42,12 @@ function TooltipContent({
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
- "z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
+ "z-50 inline-flex w-fit max-w-[200px] origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-lg bg-white px-2 py-1 text-sm font-normal text-foreground shadow-[0px_0px_0px_1px_var(--color-gray-200),0px_3px_6px_-1px_rgba(209,213,219,0.35),0px_3px_6px_0px_rgba(209,213,219,0.35)] data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
className
)}
{...props}
>
{children}
- <TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
)
diff --git a/packages/admin/src/hooks/use-products.ts b/packages/admin/src/hooks/use-products.ts
new file mode 100644
index 0000000000..7a108d4e74
--- /dev/null
+++ b/packages/admin/src/hooks/use-products.ts
@@ -0,0 +1,36 @@
+import { useQuery } from '@tanstack/react-query'
+import { spreeClient } from '@/client'
+import { useAuth } from '@/hooks/use-auth'
+import type { FilterRule } from '@/components/table-toolbar'
+
+interface UseProductsParams {
+ page?: number
+ limit?: number
+ sort?: string
+ search?: string
+ filters?: FilterRule[]
+}
+
+export function useProducts({ page = 1, limit = 25, sort = '-updated_at', search, filters = [] }: UseProductsParams = {}) {
+ const { token } = useAuth()
+
+ return useQuery({
+ queryKey: ['products', { page, limit, sort, search, filters }],
+ queryFn: async () => {
+ const params: Record<string, unknown> = { page, limit, sort }
+
+ if (search) {
+ params.name_cont = search
+ }
+
+ // Convert FilterRule[] to Ransack params
+ for (const filter of filters) {
+ const key = `${filter.field}_${filter.operator}`
+ params[key] = filter.value
+ }
+
+ return spreeClient.admin.products.list(params, { token: token! })
+ },
+ enabled: !!token,
+ })
+}
diff --git a/packages/admin/src/index.css b/packages/admin/src/index.css
index 58dded2ad5..7bf9054bad 100644
--- a/packages/admin/src/index.css
+++ b/packages/admin/src/index.css
@@ -1,42 +1,50 @@
@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
-@import "@fontsource-variable/geist";
+@import "@fontsource-variable/inter";
@custom-variant dark (&:is(.dark *));
+/* ============================================================================
+ Spree Admin Theme
+ Adapted from spree/admin Tailwind design system to match look & feel.
+ ============================================================================ */
+
:root {
- --background: oklch(1 0 0);
- --foreground: oklch(0.145 0 0);
+ /* Colors — neutral/zinc palette matching Rails admin */
+ --background: oklch(1 0 0); /* white */
+ --foreground: oklch(0.145 0 0); /* zinc-950 */
--card: oklch(1 0 0);
--card-foreground: oklch(0.145 0 0);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.145 0 0);
- --primary: oklch(0.205 0 0);
+ --primary: oklch(0.205 0 0); /* zinc-950 — black primary like Rails admin */
--primary-foreground: oklch(0.985 0 0);
- --secondary: oklch(0.97 0 0);
+ --secondary: oklch(0.97 0 0); /* gray-25 equivalent */
--secondary-foreground: oklch(0.205 0 0);
- --muted: oklch(0.97 0 0);
- --muted-foreground: oklch(0.556 0 0);
+ --muted: oklch(0.985 0 0); /* FAFAFA — gray-25 */
+ --muted-foreground: oklch(0.44 0 0);
--accent: oklch(0.97 0 0);
--accent-foreground: oklch(0.205 0 0);
- --destructive: oklch(0.58 0.22 27);
- --border: oklch(0.922 0 0);
- --input: oklch(0.922 0 0);
- --ring: oklch(0.708 0 0);
+ --destructive: oklch(0.58 0.22 27); /* red-600 */
+ --border: oklch(0.902 0 0); /* gray-200 */
+ --input: oklch(0.902 0 0);
+ --ring: oklch(0.552 0.016 285); /* blue-500 focus ring */
--chart-1: oklch(0.809 0.105 251.813);
--chart-2: oklch(0.623 0.214 259.815);
--chart-3: oklch(0.546 0.245 262.881);
--chart-4: oklch(0.488 0.243 264.376);
--chart-5: oklch(0.424 0.199 265.638);
- --radius: 0.625rem;
+ --radius: 0.75rem; /* rounded-xl base */
+
+ /* Sidebar — light gray bg like Rails admin #FAFAFA */
--sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.145 0 0);
--sidebar-primary: oklch(0.205 0 0);
--sidebar-primary-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.97 0 0);
--sidebar-accent-foreground: oklch(0.205 0 0);
- --sidebar-border: oklch(0.922 0 0);
+ --sidebar-border: oklch(0.902 0 0);
--sidebar-ring: oklch(0.708 0 0);
}
@@ -47,7 +55,7 @@
--card-foreground: oklch(0.985 0 0);
--popover: oklch(0.205 0 0);
--popover-foreground: oklch(0.985 0 0);
- --primary: oklch(0.87 0.00 0);
+ --primary: oklch(0.87 0 0);
--primary-foreground: oklch(0.205 0 0);
--secondary: oklch(0.269 0 0);
--secondary-foreground: oklch(0.985 0 0);
@@ -75,7 +83,28 @@
}
@theme inline {
- --font-sans: 'Geist Variable', sans-serif;
+ /* Inter — same font as Rails admin */
+ --font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
+
+ /* Typography scale — matches Spree admin (smaller than Tailwind defaults) */
+ --text-xs: 0.75rem;
+ --text-sm: 0.8125rem;
+ --text-base: 0.875rem;
+ --text-lg: 1rem;
+ --text-xl: 1.25rem;
+ --text-2xl: 1.5rem;
+ --text-3xl: 1.75rem;
+ --text-4xl: 2rem;
+
+ /* Shadows — subtle like Rails admin */
+ --shadow-xs: rgba(43, 34, 51, 0.05) 0px 1px 1px;
+ --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
+
+ /* Sidebar + header tokens */
+ --spacing-sidebar-width: 220px;
+ --spacing-header-height: 58px;
+
+ /* Color mappings */
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
@@ -107,23 +136,55 @@
--color-card: var(--card);
--color-foreground: var(--foreground);
--color-background: var(--background);
- --radius-sm: calc(var(--radius) * 0.6);
- --radius-md: calc(var(--radius) * 0.8);
- --radius-lg: var(--radius);
- --radius-xl: calc(var(--radius) * 1.4);
- --radius-2xl: calc(var(--radius) * 1.8);
- --radius-3xl: calc(var(--radius) * 2.2);
- --radius-4xl: calc(var(--radius) * 2.6);
+
+ /* Spree status colors — for badges & alerts */
+ --color-success: var(--color-green-900);
+ --color-warning: var(--color-yellow-900);
+ --color-info: var(--color-blue-900);
+ --color-danger: var(--color-red-600);
}
@layer base {
* {
@apply border-border outline-ring/50;
}
+
+ html {
+ @apply font-sans antialiased;
+ text-rendering: optimizeLegibility;
+ }
+
body {
- @apply bg-background text-foreground;
+ @apply bg-background text-foreground text-base;
+ line-height: 1.5;
}
- html {
- @apply font-sans;
+
+ /* Headings — semibold (600) like Rails admin */
+ h1,
+ h2,
+ h3,
+ h4,
+ h5,
+ h6 {
+ @apply font-semibold leading-tight;
+ }
+
+ h1 {
+ @apply text-4xl;
+ }
+ h2 {
+ @apply text-3xl;
+ }
+ h3 {
+ @apply text-2xl;
+ }
+ h4 {
+ @apply text-xl;
+ }
+ h5 {
+ @apply text-lg;
+ }
+ h6 {
+ @apply text-base;
}
}
diff --git a/packages/admin/src/routeTree.gen.ts b/packages/admin/src/routeTree.gen.ts
index f798462875..55662f70d1 100644
--- a/packages/admin/src/routeTree.gen.ts
+++ b/packages/admin/src/routeTree.gen.ts
@@ -14,6 +14,7 @@ import { Route as AuthenticatedRouteImport } from './routes/_authenticated'
import { Route as AuthenticatedIndexRouteImport } from './routes/_authenticated/index'
import { Route as AuthenticatedProductsIndexRouteImport } from './routes/_authenticated/products/index'
import { Route as AuthenticatedOrdersIndexRouteImport } from './routes/_authenticated/orders/index'
+import { Route as AuthenticatedProductsProductIdRouteImport } from './routes/_authenticated/products/$productId'
const LoginRoute = LoginRouteImport.update({
id: '/login',
@@ -41,16 +42,24 @@ const AuthenticatedOrdersIndexRoute =
path: '/orders/',
getParentRoute: () => AuthenticatedRoute,
} as any)
+const AuthenticatedProductsProductIdRoute =
+ AuthenticatedProductsProductIdRouteImport.update({
+ id: '/products/$productId',
+ path: '/products/$productId',
+ getParentRoute: () => AuthenticatedRoute,
+ } as any)
export interface FileRoutesByFullPath {
'/': typeof AuthenticatedIndexRoute
'/login': typeof LoginRoute
+ '/products/$productId': typeof AuthenticatedProductsProductIdRoute
'/orders/': typeof AuthenticatedOrdersIndexRoute
'/products/': typeof AuthenticatedProductsIndexRoute
}
export interface FileRoutesByTo {
'/login': typeof LoginRoute
'/': typeof AuthenticatedIndexRoute
+ '/products/$productId': typeof AuthenticatedProductsProductIdRoute
'/orders': typeof AuthenticatedOrdersIndexRoute
'/products': typeof AuthenticatedProductsIndexRoute
}
@@ -59,19 +68,21 @@ export interface FileRoutesById {
'/_authenticated': typeof AuthenticatedRouteWithChildren
'/login': typeof LoginRoute
'/_authenticated/': typeof AuthenticatedIndexRoute
+ '/_authenticated/products/$productId': typeof AuthenticatedProductsProductIdRoute
'/_authenticated/orders/': typeof AuthenticatedOrdersIndexRoute
'/_authenticated/products/': typeof AuthenticatedProductsIndexRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/login' | '/orders/' | '/products/'
+ fullPaths: '/' | '/login' | '/products/$productId' | '/orders/' | '/products/'
fileRoutesByTo: FileRoutesByTo
- to: '/login' | '/' | '/orders' | '/products'
+ to: '/login' | '/' | '/products/$productId' | '/orders' | '/products'
id:
| '__root__'
| '/_authenticated'
| '/login'
| '/_authenticated/'
+ | '/_authenticated/products/$productId'
| '/_authenticated/orders/'
| '/_authenticated/products/'
fileRoutesById: FileRoutesById
@@ -118,17 +129,26 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthenticatedOrdersIndexRouteImport
parentRoute: typeof AuthenticatedRoute
}
+ '/_authenticated/products/$productId': {
+ id: '/_authenticated/products/$productId'
+ path: '/products/$productId'
+ fullPath: '/products/$productId'
+ preLoaderRoute: typeof AuthenticatedProductsProductIdRouteImport
+ parentRoute: typeof AuthenticatedRoute
+ }
}
}
interface AuthenticatedRouteChildren {
AuthenticatedIndexRoute: typeof AuthenticatedIndexRoute
+ AuthenticatedProductsProductIdRoute: typeof AuthenticatedProductsProductIdRoute
AuthenticatedOrdersIndexRoute: typeof AuthenticatedOrdersIndexRoute
AuthenticatedProductsIndexRoute: typeof AuthenticatedProductsIndexRoute
}
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
AuthenticatedIndexRoute: AuthenticatedIndexRoute,
+ AuthenticatedProductsProductIdRoute: AuthenticatedProductsProductIdRoute,
AuthenticatedOrdersIndexRoute: AuthenticatedOrdersIndexRoute,
AuthenticatedProductsIndexRoute: AuthenticatedProductsIndexRoute,
}
diff --git a/packages/admin/src/routes/_authenticated.tsx b/packages/admin/src/routes/_authenticated.tsx
index 6af8e4ce73..922bd34ce1 100644
--- a/packages/admin/src/routes/_authenticated.tsx
+++ b/packages/admin/src/routes/_authenticated.tsx
@@ -27,7 +27,7 @@ function AuthenticatedLayout() {
<SidebarProvider>
<AppSidebar />
<SidebarInset>
- <header className="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
+ <header className="flex h-[58px] shrink-0 items-center bg-white shadow-[inset_0_-1px_0_var(--color-border)]">
<div className="flex items-center gap-2 px-4">
<SidebarTrigger className="-ml-1" />
<Separator orientation="vertical" className="mr-2 h-4" />
@@ -40,7 +40,7 @@ function AuthenticatedLayout() {
</Breadcrumb>
</div>
</header>
- <div className="flex flex-1 flex-col gap-4 p-4 pt-0">
+ <div className="flex flex-1 flex-col gap-4 p-4">
<Outlet />
</div>
</SidebarInset>
diff --git a/packages/admin/src/routes/_authenticated/products/$productId.tsx b/packages/admin/src/routes/_authenticated/products/$productId.tsx
new file mode 100644
index 0000000000..abcf53d9f6
--- /dev/null
+++ b/packages/admin/src/routes/_authenticated/products/$productId.tsx
@@ -0,0 +1,16 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/_authenticated/products/$productId')({
+ component: ProductDetailPage,
+})
+
+function ProductDetailPage() {
+ const { productId } = Route.useParams()
+
+ return (
+ <div className="space-y-4">
+ <h1 className="text-2xl font-medium">Product {productId}</h1>
+ <p className="text-muted-foreground">Product detail page will be implemented here.</p>
+ </div>
+ )
+}
diff --git a/packages/admin/src/routes/_authenticated/products/index.tsx b/packages/admin/src/routes/_authenticated/products/index.tsx
index c69d2ef67f..7738377515 100644
--- a/packages/admin/src/routes/_authenticated/products/index.tsx
+++ b/packages/admin/src/routes/_authenticated/products/index.tsx
@@ -1,18 +1,345 @@
-import { createFileRoute } from '@tanstack/react-router'
+import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
+import { useProducts } from '@/hooks/use-products'
+import { Card, CardContent } from '@/components/ui/card'
+import { Button } from '@/components/ui/button'
+import { StatusBadge } from '@/components/ui/badge'
+import { Pagination } from '@/components/ui/pagination'
+import {
+ Table,
+ TableHeader,
+ TableBody,
+ TableRow,
+ TableHead,
+ TableCell,
+ TableEmpty,
+} from '@/components/ui/data-table'
+import {
+ TableToolbar,
+ type ColumnDef,
+ type FilterRule,
+ type SortOption,
+} from '@/components/table-toolbar'
+import { z } from 'zod/v4'
+import { PlusIcon, PackageIcon } from 'lucide-react'
+import { useState, useDeferredValue } from 'react'
+
+// ============================================================================
+// Column definitions — mirrors the Rails admin spree_admin_tables.rb config
+// ============================================================================
+
+const productColumns: ColumnDef[] = [
+ {
+ key: 'name',
+ label: 'Name',
+ sortable: true,
+ filterable: true,
+ default: true,
+ },
+ {
+ key: 'status',
+ label: 'Status',
+ sortable: true,
+ filterable: true,
+ default: true,
+ filterType: 'status',
+ filterOptions: [
+ { value: 'draft', label: 'Draft' },
+ { value: 'active', label: 'Active' },
+ { value: 'archived', label: 'Archived' },
+ ],
+ },
+ {
+ key: 'inventory',
+ label: 'Inventory',
+ sortable: false,
+ filterable: false,
+ default: true,
+ },
+ {
+ key: 'price',
+ label: 'Price',
+ sortable: true,
+ filterable: true,
+ default: true,
+ filterType: 'number',
+ },
+ {
+ key: 'sku',
+ label: 'SKU',
+ sortable: false,
+ filterable: true,
+ default: false,
+ },
+ {
+ key: 'created_at',
+ label: 'Created at',
+ sortable: true,
+ filterable: true,
+ default: false,
+ filterType: 'date',
+ },
+ {
+ key: 'updated_at',
+ label: 'Updated at',
+ sortable: true,
+ filterable: true,
+ default: false,
+ filterType: 'date',
+ },
+]
+
+const defaultColumns = productColumns.filter((c) => c.default).map((c) => c.key)
+
+// ============================================================================
+// Route
+// ============================================================================
+
+const filterSchema = z.object({
+ id: z.string(),
+ field: z.string(),
+ operator: z.string(),
+ value: z.string(),
+})
+
+const searchSchema = z.object({
+ page: z.coerce.number().optional().default(1),
+ sort: z.string().optional().default('updated_at'),
+ dir: z.enum(['asc', 'desc']).optional().default('desc'),
+ search: z.string().optional(),
+ filters: z.preprocess(
+ (val) => {
+ if (typeof val === 'string') {
+ try { return JSON.parse(val) } catch { return [] }
+ }
+ return val ?? []
+ },
+ z.array(filterSchema).optional().default([]),
+ ),
+ columns: z.preprocess(
+ (val) => {
+ if (typeof val === 'string') return val.split(',')
+ return val ?? undefined
+ },
+ z.array(z.string()).optional(),
+ ),
+})
export const Route = createFileRoute('/_authenticated/products/')({
+ validateSearch: searchSchema,
component: ProductsPage,
})
+// ============================================================================
+// Page
+// ============================================================================
+
function ProductsPage() {
+ const { page, sort, dir, search, filters, columns: urlColumns } = Route.useSearch()
+ const navigate = useNavigate({ from: Route.fullPath })
+
+ const [searchInput, setSearchInput] = useState(search ?? '')
+ const deferredSearch = useDeferredValue(searchInput)
+ const visibleColumns = urlColumns ?? defaultColumns
+
+ const sortString = dir === 'desc' ? `-${sort}` : sort
+
+ const { data, isLoading } = useProducts({
+ page,
+ sort: sortString,
+ search: deferredSearch || undefined,
+ filters: filters as FilterRule[],
+ })
+
+ const products = data?.data ?? []
+ const meta = data?.meta
+
+ // Navigation helpers
+ function updateSearch(updates: Record<string, unknown>) {
+ navigate({ search: (prev) => ({ ...prev, ...updates }) })
+ }
+
+ function handleSearchChange(value: string) {
+ setSearchInput(value)
+ updateSearch({ search: value || undefined, page: 1 })
+ }
+
+ function handleSortChange(s: SortOption) {
+ updateSearch({ sort: s.field, dir: s.direction, page: 1 })
+ }
+
+ function handleFiltersChange(f: FilterRule[]) {
+ updateSearch({
+ filters: f.length > 0 ? JSON.stringify(f) : undefined,
+ page: 1,
+ })
+ }
+
+ function handleColumnsChange(cols: string[]) {
+ const isDefault = cols.length === defaultColumns.length && cols.every((c) => defaultColumns.includes(c))
+ updateSearch({ columns: isDefault ? undefined : cols.join(',') })
+ }
+
+ const showSku = visibleColumns.includes('sku')
+ const showCreatedAt = visibleColumns.includes('created_at')
+ const showUpdatedAt = visibleColumns.includes('updated_at')
+
+ const colCount = 2 + // name is always shown, price is always shown
+ (visibleColumns.includes('status') ? 1 : 0) +
+ (visibleColumns.includes('inventory') ? 1 : 0) +
+ (showSku ? 1 : 0) +
+ (showCreatedAt ? 1 : 0) +
+ (showUpdatedAt ? 1 : 0)
+
return (
- <div className="space-y-4">
- <div className="flex items-center justify-between">
- <h1 className="text-2xl font-bold">Products</h1>
- </div>
- <p className="text-muted-foreground">
- Product listing will be implemented here.
- </p>
- </div>
+ <Card className="rounded-2xl">
+ <TableToolbar
+ columns={productColumns}
+ visibleColumns={visibleColumns}
+ onVisibleColumnsChange={handleColumnsChange}
+ search={searchInput}
+ onSearchChange={handleSearchChange}
+ searchPlaceholder="Search products..."
+ sort={{ field: sort, direction: dir }}
+ onSortChange={handleSortChange}
+ filters={filters as FilterRule[]}
+ onFiltersChange={handleFiltersChange}
+ actions={
+ <Button size="sm" className="h-[2.125rem]">
+ <PlusIcon className="size-4" />
+ Add Product
+ </Button>
+ }
+ />
+ <CardContent className="p-0">
+ <Table>
+ <TableHeader>
+ <tr>
+ <TableHead>Name</TableHead>
+ {visibleColumns.includes('status') && <TableHead>Status</TableHead>}
+ {visibleColumns.includes('inventory') && <TableHead>Inventory</TableHead>}
+ {showSku && <TableHead>SKU</TableHead>}
+ <TableHead className="text-right">Price</TableHead>
+ {showCreatedAt && <TableHead>Created</TableHead>}
+ {showUpdatedAt && <TableHead>Updated</TableHead>}
+ </tr>
+ </TableHeader>
+ <TableBody>
+ {isLoading ? (
+ <TableEmpty colSpan={colCount}>Loading products...</TableEmpty>
+ ) : products.length === 0 ? (
+ <TableEmpty colSpan={colCount}>
+ <div className="flex flex-col items-center gap-2">
+ <PackageIcon className="size-8 text-muted-foreground/50" />
+ <p>No products found</p>
+ {(deferredSearch || (filters as FilterRule[]).length > 0) && (
+ <p className="text-xs">
+ Try adjusting your search or filters
+ </p>
+ )}
+ </div>
+ </TableEmpty>
+ ) : (
+ products.map((product: any) => (
+ <TableRow key={product.id}>
+ <TableCell>
+ <Link
+ to="/products/$productId"
+ params={{ productId: product.id }}
+ className="flex items-center gap-3 no-underline"
+ >
+ <div className="flex size-10 shrink-0 items-center justify-center rounded-lg border border-gray-200 bg-gray-50 overflow-hidden">
+ {product.thumbnail_url ? (
+ <img
+ src={product.thumbnail_url}
+ alt={product.name}
+ className="size-full object-cover"
+ />
+ ) : (
+ <PackageIcon className="size-4 text-gray-400" />
+ )}
+ </div>
+ <div className="min-w-0">
+ <div className="truncate font-medium text-zinc-950">
+ {product.name}
+ </div>
+ </div>
+ </Link>
+ </TableCell>
+ {visibleColumns.includes('status') && (
+ <TableCell>
+ <StatusBadge status={product.status} />
+ </TableCell>
+ )}
+ {visibleColumns.includes('inventory') && (
+ <TableCell>
+ <InventoryCell product={product} />
+ </TableCell>
+ )}
+ {showSku && (
+ <TableCell className="text-sm text-muted-foreground">
+ {product.sku ?? '—'}
+ </TableCell>
+ )}
+ <TableCell className="text-right tabular-nums whitespace-nowrap">
+ {product.price ? formatPrice(product.price) : '—'}
+ </TableCell>
+ {showCreatedAt && (
+ <TableCell className="text-sm text-muted-foreground whitespace-nowrap">
+ {formatRelativeTime(product.created_at)}
+ </TableCell>
+ )}
+ {showUpdatedAt && (
+ <TableCell className="text-sm text-muted-foreground whitespace-nowrap">
+ {formatRelativeTime(product.updated_at)}
+ </TableCell>
+ )}
+ </TableRow>
+ ))
+ )}
+ </TableBody>
+ </Table>
+ {meta && (
+ <Pagination
+ meta={meta}
+ onPageChange={(p) => updateSearch({ page: p })}
+ />
+ )}
+ </CardContent>
+ </Card>
)
}
+
+// ============================================================================
+// Helpers
+// ============================================================================
+
+function InventoryCell({ product }: { product: any }) {
+ if (!product.in_stock && !product.backorderable) {
+ return <span className="text-sm text-destructive">Out of stock</span>
+ }
+ if (product.backorderable && !product.in_stock) {
+ return <span className="text-sm text-muted-foreground">On backorder</span>
+ }
+ return <span className="text-sm text-muted-foreground">In stock</span>
+}
+
+function formatPrice(price: { amount?: string; currency?: string; display?: string } | null) {
+ if (!price) return '—'
+ return price.display ?? `${price.currency} ${price.amount}`
+}
+
+function formatRelativeTime(iso: string) {
+ const date = new Date(iso)
+ const now = new Date()
+ const diffMs = now.getTime() - date.getTime()
+ const diffMins = Math.floor(diffMs / 60000)
+ const diffHours = Math.floor(diffMins / 60)
+ const diffDays = Math.floor(diffHours / 24)
+
+ if (diffMins < 1) return 'just now'
+ if (diffMins < 60) return `${diffMins}m ago`
+ if (diffHours < 24) return `${diffHours}h ago`
+ if (diffDays < 30) return `${diffDays}d ago`
+
+ return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: date.getFullYear() !== now.getFullYear() ? 'numeric' : undefined })
+}
diff --git a/packages/admin/src/routes/login.tsx b/packages/admin/src/routes/login.tsx
index 177cdee80f..ffdbf41d32 100644
--- a/packages/admin/src/routes/login.tsx
+++ b/packages/admin/src/routes/login.tsx
@@ -64,14 +64,14 @@ function LoginFormCard({
onSubmit,
isLoading,
className,
- ...props
}: {
form: ReturnType<typeof useForm<LoginForm>>
onSubmit: (data: LoginForm) => Promise<void>
isLoading: boolean
-} & React.ComponentProps<'div'>) {
+ className?: string
+}) {
return (
- <div className={cn('flex flex-col gap-6', className)} {...props}>
+ <div className={cn('flex flex-col gap-6', className)}>
<Card>
<CardHeader className="text-center">
<CardTitle className="text-xl">Welcome back</CardTitle>