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.

Implement order listings in new admin

Damian Legawiec93058f007868
diff --git a/packages/admin/biome.json b/packages/admin/biome.json
new file mode 100644
index 0000000000..146e47d151
--- /dev/null
+++ b/packages/admin/biome.json
@@ -0,0 +1,57 @@
+{
+ "$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
+ "linter": {
+ "enabled": true,
+ "rules": {
+ "recommended": true,
+ "correctness": {
+ "noUnusedImports": "warn",
+ "noUnusedVariables": "warn"
+ },
+ "suspicious": {
+ "noExplicitAny": "off"
+ },
+ "style": {
+ "noNonNullAssertion": "off"
+ }
+ }
+ },
+ "formatter": {
+ "enabled": true,
+ "indentStyle": "space",
+ "indentWidth": 2,
+ "lineWidth": 100
+ },
+ "javascript": {
+ "formatter": {
+ "quoteStyle": "single",
+ "semicolons": "asNeeded"
+ }
+ },
+ "css": {
+ "linter": {
+ "enabled": false
+ },
+ "formatter": {
+ "enabled": false
+ }
+ },
+ "assist": {
+ "actions": {
+ "source": {
+ "organizeImports": "on"
+ }
+ }
+ },
+ "files": {
+ "includes": ["src/**", "!src/routeTree.gen.ts", "!src/**/*.css"]
+ },
+ "overrides": [
+ {
+ "includes": ["src/components/ui/**"],
+ "linter": {
+ "enabled": false
+ }
+ }
+ ]
+}
diff --git a/packages/admin/ARCHITECTURE.md b/packages/admin/docs/ARCHITECTURE.md
similarity index 100%
rename from packages/admin/ARCHITECTURE.md
rename to packages/admin/docs/ARCHITECTURE.md
diff --git a/packages/admin/eslint.config.js b/packages/admin/eslint.config.js
deleted file mode 100644
index 5e6b472f58..0000000000
--- a/packages/admin/eslint.config.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import js from '@eslint/js'
-import globals from 'globals'
-import reactHooks from 'eslint-plugin-react-hooks'
-import reactRefresh from 'eslint-plugin-react-refresh'
-import tseslint from 'typescript-eslint'
-import { defineConfig, globalIgnores } from 'eslint/config'
-
-export default defineConfig([
- globalIgnores(['dist']),
- {
- files: ['**/*.{ts,tsx}'],
- extends: [
- js.configs.recommended,
- tseslint.configs.recommended,
- reactHooks.configs.flat.recommended,
- reactRefresh.configs.vite,
- ],
- languageOptions: {
- ecmaVersion: 2020,
- globals: globals.browser,
- },
- },
-])
diff --git a/packages/admin/package.json b/packages/admin/package.json
index d3ff05b987..c76f744014 100644
--- a/packages/admin/package.json
+++ b/packages/admin/package.json
@@ -6,7 +6,9 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
- "lint": "eslint .",
+ "lint": "biome check .",
+ "lint:fix": "biome check --fix .",
+ "format": "biome format --write .",
"preview": "vite preview"
},
"dependencies": {
@@ -30,20 +32,14 @@
},
"devDependencies": {
"@biomejs/biome": "^2.4.6",
- "@eslint/js": "^9.39.1",
"@tailwindcss/vite": "^4.2.1",
"@tanstack/router-plugin": "^1.166.2",
"@types/node": "^24.10.1",
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
- "eslint": "^9.39.1",
- "eslint-plugin-react-hooks": "^7.0.1",
- "eslint-plugin-react-refresh": "^0.4.24",
- "globals": "^16.5.0",
"tailwindcss": "^4.2.1",
"typescript": "~5.9.3",
- "typescript-eslint": "^8.48.0",
"vite": "^8.0.0-beta.13"
},
"pnpm": {
diff --git a/packages/admin/src/components/app-sidebar.tsx b/packages/admin/src/components/app-sidebar.tsx
index 264501fb3a..eaceed90f3 100644
--- a/packages/admin/src/components/app-sidebar.tsx
+++ b/packages/admin/src/components/app-sidebar.tsx
@@ -1,13 +1,8 @@
+import type { ComponentProps } from 'react'
import { NavMain } from '@/components/nav-main'
import { NavUser } from '@/components/nav-user'
import { StoreSwitcher } from '@/components/store-switcher'
-import {
- Sidebar,
- SidebarContent,
- SidebarFooter,
- SidebarHeader,
-} from '@/components/ui/sidebar'
-import type { ComponentProps } from 'react'
+import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader } from '@/components/ui/sidebar'
export type NavItem = {
title: string
@@ -26,9 +21,7 @@ const navigation: NavItem[] = [
title: 'Orders',
url: '/orders',
icon: 'inbox',
- items: [
- { title: 'Draft Orders', url: '/orders/drafts' },
- ],
+ items: [{ title: 'Draft Orders', url: '/orders/drafts' }],
},
{
title: 'Products',
@@ -50,9 +43,7 @@ const navigation: NavItem[] = [
title: 'Promotions',
url: '/promotions',
icon: 'discount',
- items: [
- { title: 'Gift Cards', url: '/promotions/gift-cards' },
- ],
+ items: [{ title: 'Gift Cards', url: '/promotions/gift-cards' }],
},
{
title: 'Reports',
diff --git a/packages/admin/src/components/nav-main.tsx b/packages/admin/src/components/nav-main.tsx
index 7c0699f14a..0366a92b78 100644
--- a/packages/admin/src/components/nav-main.tsx
+++ b/packages/admin/src/components/nav-main.tsx
@@ -1,3 +1,6 @@
+import { Link, useRouterState } from '@tanstack/react-router'
+import type { NavItem } from '@/components/app-sidebar'
+import { TablerIcon } from '@/components/tabler-icon'
import {
SidebarGroup,
SidebarMenu,
@@ -7,9 +10,6 @@ import {
SidebarMenuSubButton,
SidebarMenuSubItem,
} from '@/components/ui/sidebar'
-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 (
@@ -26,13 +26,7 @@ function NavIcon({ name, isActive }: { name: string; isActive?: boolean }) {
)
}
-export function NavMain({
- items,
- bottomItems,
-}: {
- items: NavItem[]
- bottomItems?: NavItem[]
-}) {
+export function NavMain({ items, bottomItems }: { items: NavItem[]; bottomItems?: NavItem[] }) {
const routerState = useRouterState()
const currentPath = routerState.location.pathname
@@ -42,10 +36,9 @@ export function NavMain({
<SidebarMenu>
{items.map((item) => {
const isExactActive = currentPath === item.url
- const isActive = isExactActive ||
- (item.url !== '/' && currentPath.startsWith(item.url))
+ const isActive = isExactActive || (item.url !== '/' && currentPath.startsWith(item.url))
const hasActiveChild = item.items?.some(
- (sub) => currentPath === sub.url || currentPath.startsWith(sub.url)
+ (sub) => currentPath === sub.url || currentPath.startsWith(sub.url),
)
const showSubmenu = isActive || hasActiveChild
@@ -64,8 +57,8 @@ export function NavMain({
{item.items && showSubmenu && (
<SidebarMenuSub>
{item.items.map((subItem) => {
- const subActive = currentPath === subItem.url ||
- currentPath.startsWith(subItem.url)
+ const subActive =
+ currentPath === subItem.url || currentPath.startsWith(subItem.url)
return (
<SidebarMenuSubItem key={subItem.title}>
<SidebarMenuSubButton asChild isActive={subActive}>
@@ -88,16 +81,12 @@ export function NavMain({
<SidebarGroup className="mt-auto">
<SidebarMenu>
{bottomItems.map((item) => {
- const isActive = currentPath === item.url ||
- (item.url !== '/' && currentPath.startsWith(item.url))
+ const isActive =
+ currentPath === item.url || (item.url !== '/' && currentPath.startsWith(item.url))
return (
<SidebarMenuItem key={item.title}>
- <SidebarMenuButton
- tooltip={item.title}
- asChild
- isActive={isActive}
- >
+ <SidebarMenuButton tooltip={item.title} asChild isActive={isActive}>
<Link to={item.url}>
<NavIcon name={item.icon} isActive={isActive} />
<span>{item.title}</span>
diff --git a/packages/admin/src/components/nav-user.tsx b/packages/admin/src/components/nav-user.tsx
index 8c29307813..7f88fcc4d0 100644
--- a/packages/admin/src/components/nav-user.tsx
+++ b/packages/admin/src/components/nav-user.tsx
@@ -1,7 +1,5 @@
-import {
- Avatar,
- AvatarFallback,
-} from '@/components/ui/avatar'
+import { TablerIcon } from '@/components/tabler-icon'
+import { Avatar, AvatarFallback } from '@/components/ui/avatar'
import {
DropdownMenu,
DropdownMenuContent,
@@ -9,13 +7,8 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
-import {
- SidebarMenu,
- SidebarMenuItem,
- useSidebar,
-} from '@/components/ui/sidebar'
+import { SidebarMenu, SidebarMenuItem, useSidebar } from '@/components/ui/sidebar'
import { useAuth } from '@/hooks/use-auth'
-import { TablerIcon } from '@/components/tabler-icon'
export function NavUser() {
const { isMobile } = useSidebar()
@@ -23,11 +16,12 @@ export function NavUser() {
if (!user) return null
- const initials = [user.first_name, user.last_name]
- .filter(Boolean)
- .map((n) => n![0])
- .join('')
- .toUpperCase() || user.email[0]!.toUpperCase()
+ const initials =
+ [user.first_name, user.last_name]
+ .filter(Boolean)
+ .map((n) => n![0])
+ .join('')
+ .toUpperCase() || user.email[0]!.toUpperCase()
const displayName = [user.first_name, user.last_name].filter(Boolean).join(' ') || user.email
@@ -36,15 +30,16 @@ export function NavUser() {
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <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">
+ <button
+ type="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>
- <span className="flex-1 min-w-0 truncate text-sm text-zinc-950">
- {displayName}
- </span>
+ <span className="flex-1 min-w-0 truncate text-sm text-zinc-950">{displayName}</span>
</button>
</DropdownMenuTrigger>
<DropdownMenuContent
diff --git a/packages/admin/src/components/resource-table.tsx b/packages/admin/src/components/resource-table.tsx
index d458920475..9b662018e0 100644
--- a/packages/admin/src/components/resource-table.tsx
+++ b/packages/admin/src/components/resource-table.tsx
@@ -1,28 +1,27 @@
-import { useQuery } from "@tanstack/react-query";
-import { useNavigate } from "@tanstack/react-router";
-import { Card, CardContent } from "@/components/ui/card";
-import { Pagination, type PaginationMeta } from "@/components/ui/pagination";
+import { useQuery } from '@tanstack/react-query'
+import { useNavigate } from '@tanstack/react-router'
+import { type ReactNode, useDeferredValue, useState } from 'react'
+import { z } from 'zod/v4'
+import { TableToolbar } from '@/components/table-toolbar'
+import { Card, CardContent } from '@/components/ui/card'
import {
Table,
- TableHeader,
TableBody,
- TableRow,
- TableHead,
TableCell,
TableEmpty,
-} from "@/components/ui/data-table";
-import { TableToolbar } from "@/components/table-toolbar";
-import { useAuth } from "@/hooks/use-auth";
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/ui/data-table'
+import { Pagination, type PaginationMeta } from '@/components/ui/pagination'
+import { useAuth } from '@/hooks/use-auth'
import {
- getTable,
- getDisplayableColumns,
- getDefaultColumnKeys,
- type TableDef,
type FilterRule,
+ getDefaultColumnKeys,
+ getDisplayableColumns,
+ getTable,
type SortOption,
-} from "@/lib/table-registry";
-import { z } from "zod/v4";
-import { useState, useDeferredValue, type ReactNode } from "react";
+} from '@/lib/table-registry'
// ============================================================================
// Search schema — shared by all resource table routes
@@ -33,30 +32,30 @@ const filterSchema = z.object({
field: z.string(),
operator: z.string(),
value: z.string(),
-});
+})
export const resourceSearchSchema = z.object({
page: z.coerce.number().optional().default(1),
sort: z.string().optional(),
- dir: z.enum(["asc", "desc"]).optional(),
+ dir: z.enum(['asc', 'desc']).optional(),
search: z.string().optional(),
filters: z.preprocess((val) => {
- if (typeof val === "string") {
+ if (typeof val === 'string') {
try {
- return JSON.parse(val);
+ return JSON.parse(val)
} catch {
- return [];
+ return []
}
}
- return val ?? [];
+ return val ?? []
}, z.array(filterSchema).optional().default([])),
columns: z.preprocess((val) => {
- if (typeof val === "string") return val.split(",");
- return val ?? undefined;
+ if (typeof val === 'string') return val.split(',')
+ return val ?? undefined
}, z.array(z.string()).optional()),
-});
+})
-export type ResourceSearch = z.infer<typeof resourceSearchSchema>;
+export type ResourceSearch = z.infer<typeof resourceSearchSchema>
// ============================================================================
// Props
@@ -64,19 +63,19 @@ export type ResourceSearch = z.infer<typeof resourceSearchSchema>;
interface ResourceTableProps<T> {
/** Registry key (e.g., 'products') */
- tableKey: string;
+ tableKey: string
/** TanStack Query key prefix (e.g., 'products') */
- queryKey: string;
+ queryKey: string
/** Function that calls the SDK to fetch data */
- queryFn: (
- params: Record<string, unknown>,
- ) => Promise<{ data: T[]; meta: PaginationMeta }>;
+ queryFn: (params: Record<string, unknown>) => Promise<{ data: T[]; meta: PaginationMeta }>
/** Current search params from the route */
- searchParams: ResourceSearch;
+ searchParams: ResourceSearch
/** Title displayed in the toolbar header. Overrides the table definition's title. */
- title?: string;
+ title?: string
+ /** Default params always sent with every request (e.g., { complete: 1 } for orders) */
+ defaultParams?: Record<string, unknown>
/** Actions to render in the toolbar (e.g., "Add Product" button) */
- actions?: ReactNode;
+ actions?: ReactNode
}
// ============================================================================
@@ -89,108 +88,96 @@ export function ResourceTable<T extends Record<string, any>>({
queryFn,
searchParams,
title,
+ defaultParams,
actions,
}: ResourceTableProps<T>) {
- const table = getTable<T>(tableKey);
- const { token } = useAuth();
- const navigate = useNavigate();
+ const table = getTable<T>(tableKey)
+ const { token } = useAuth()
+ const navigate = useNavigate()
- const {
- page,
- sort: urlSort,
- dir: urlDir,
- search,
- filters,
- columns: urlColumns,
- } = searchParams;
+ const { page, sort: urlSort, dir: urlDir, search, filters, columns: urlColumns } = searchParams
const defaultSort = table.defaultSort ?? {
- field: "updated_at",
- direction: "desc" as const,
- };
- const sort = urlSort ?? defaultSort.field;
- const dir = urlDir ?? defaultSort.direction;
+ field: 'updated_at',
+ direction: 'desc' as const,
+ }
+ const sort = urlSort ?? defaultSort.field
+ const dir = urlDir ?? defaultSort.direction
- const [searchInput, setSearchInput] = useState(search ?? "");
- const deferredSearch = useDeferredValue(searchInput);
+ const [searchInput, setSearchInput] = useState(search ?? '')
+ const deferredSearch = useDeferredValue(searchInput)
- const displayableColumns = getDisplayableColumns(table);
- const defaultColumnKeys = getDefaultColumnKeys(table);
- const visibleColumnKeys = urlColumns ?? defaultColumnKeys;
+ const displayableColumns = getDisplayableColumns(table)
+ const defaultColumnKeys = getDefaultColumnKeys(table)
+ const visibleColumnKeys = urlColumns ?? defaultColumnKeys
- const visibleColumns = displayableColumns.filter((c) =>
- visibleColumnKeys.includes(c.key),
- );
+ const visibleColumns = displayableColumns.filter((c) => visibleColumnKeys.includes(c.key))
// Build API params
- const sortString = dir === "desc" ? `-${sort}` : sort;
+ const sortString = dir === 'desc' ? `-${sort}` : sort
const { data, isLoading } = useQuery({
- queryKey: [
- queryKey,
- { page, sort: sortString, search: deferredSearch, filters },
- ],
+ queryKey: [queryKey, { page, sort: sortString, search: deferredSearch, filters }],
queryFn: () => {
- const params: Record<string, unknown> = { page, sort: sortString };
+ const params: Record<string, unknown> = { page, sort: sortString, ...defaultParams }
if (deferredSearch) {
- const searchParam = table.searchParam ?? "name_cont";
- params[searchParam] = deferredSearch;
+ const searchParam = table.searchParam ?? 'name_cont'
+ params[searchParam] = deferredSearch
}
// Convert FilterRule[] to Ransack params
for (const filter of filters as FilterRule[]) {
- const col = table.columns.find((c) => c.key === filter.field);
- const ransackKey = col?.ransackAttribute ?? filter.field;
- params[`${ransackKey}_${filter.operator}`] = filter.value;
+ const col = table.columns.find((c) => c.key === filter.field)
+ const ransackKey = col?.ransackAttribute ?? filter.field
+ params[`${ransackKey}_${filter.operator}`] = filter.value
}
- return queryFn(params);
+ return queryFn(params)
},
enabled: !!token,
- });
+ })
- const rows = data?.data ?? [];
- const meta = data?.meta;
+ const rows = data?.data ?? []
+ const meta = data?.meta
// Navigation helpers
function updateSearch(updates: Record<string, unknown>) {
navigate({
search: (prev: Record<string, unknown>) => ({ ...prev, ...updates }),
- });
+ })
}
function handleSearchChange(value: string) {
- setSearchInput(value);
- updateSearch({ search: value || undefined, page: 1 });
+ setSearchInput(value)
+ updateSearch({ search: value || undefined, page: 1 })
}
function handleSortChange(s: SortOption) {
- updateSearch({ sort: s.field, dir: s.direction, page: 1 });
+ 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 === defaultColumnKeys.length &&
- cols.every((c) => defaultColumnKeys.includes(c));
- updateSearch({ columns: isDefault ? undefined : cols.join(",") });
+ cols.length === defaultColumnKeys.length && cols.every((c) => defaultColumnKeys.includes(c))
+ updateSearch({ columns: isDefault ? undefined : cols.join(',') })
}
// Header columns for price-like right-aligned columns
const headerColumns = visibleColumns.map((col) => {
- const isRightAligned = col.className?.includes("text-right");
+ const isRightAligned = col.className?.includes('text-right')
return {
...col,
- headerClassName: isRightAligned ? "text-right" : undefined,
- };
- });
+ headerClassName: isRightAligned ? 'text-right' : undefined,
+ }
+ })
return (
<Card className="rounded-2xl">
@@ -200,7 +187,7 @@ export function ResourceTable<T extends Record<string, any>>({
onVisibleColumnsChange={handleColumnsChange}
search={searchInput}
onSearchChange={handleSearchChange}
- searchPlaceholder={table.searchPlaceholder ?? "Search..."}
+ searchPlaceholder={table.searchPlaceholder ?? 'Search...'}
sort={{ field: sort, direction: dir }}
onSortChange={handleSortChange}
filters={filters as FilterRule[]}
@@ -222,18 +209,14 @@ export function ResourceTable<T extends Record<string, any>>({
</TableHeader>
<TableBody>
{isLoading ? (
- <TableEmpty colSpan={visibleColumns.length}>
- Loading...
- </TableEmpty>
+ <TableEmpty colSpan={visibleColumns.length}>Loading...</TableEmpty>
) : rows.length === 0 ? (
<TableEmpty colSpan={visibleColumns.length}>
<div className="flex flex-col items-center gap-2">
{table.emptyIcon}
- <p>{table.emptyMessage ?? "No results found"}</p>
+ <p>{table.emptyMessage ?? 'No results found'}</p>
{(deferredSearch || (filters as FilterRule[]).length > 0) && (
- <p className="text-xs">
- Try adjusting your search or filters
- </p>
+ <p className="text-xs">Try adjusting your search or filters</p>
)}
</div>
</TableEmpty>
@@ -242,9 +225,7 @@ export function ResourceTable<T extends Record<string, any>>({
<TableRow key={(row as any).id ?? i}>
{visibleColumns.map((col) => (
<TableCell key={col.key} className={col.className}>
- {col.render
- ? col.render(row)
- : String((row as any)[col.key] ?? "—")}
+ {col.render ? col.render(row) : String((row as any)[col.key] ?? '—')}
</TableCell>
))}
</TableRow>
@@ -252,13 +233,8 @@ export function ResourceTable<T extends Record<string, any>>({
)}
</TableBody>
</Table>
- {meta && (
- <Pagination
- meta={meta}
- onPageChange={(p) => updateSearch({ page: p })}
- />
- )}
+ {meta && <Pagination meta={meta} onPageChange={(p) => updateSearch({ page: p })} />}
</CardContent>
</Card>
- );
+ )
}
diff --git a/packages/admin/src/components/store-switcher.tsx b/packages/admin/src/components/store-switcher.tsx
index 47ed1a6b4c..5312208eb7 100644
--- a/packages/admin/src/components/store-switcher.tsx
+++ b/packages/admin/src/components/store-switcher.tsx
@@ -1,3 +1,5 @@
+import { ChevronsUpDownIcon, ExternalLinkIcon } from 'lucide-react'
+import { TablerIcon } from '@/components/tabler-icon'
import {
DropdownMenu,
DropdownMenuContent,
@@ -7,12 +9,10 @@ import {
} from '@/components/ui/dropdown-menu'
import {
SidebarMenu,
- SidebarMenuItem,
SidebarMenuButton,
+ SidebarMenuItem,
useSidebar,
} from '@/components/ui/sidebar'
-import { ChevronsUpDownIcon, ExternalLinkIcon } from 'lucide-react'
-import { TablerIcon } from '@/components/tabler-icon'
export function StoreSwitcher() {
const { isMobile } = useSidebar()
diff --git a/packages/admin/src/components/table-toolbar.tsx b/packages/admin/src/components/table-toolbar.tsx
index fd7f38d9bc..8161bf229c 100644
--- a/packages/admin/src/components/table-toolbar.tsx
+++ b/packages/admin/src/components/table-toolbar.tsx
@@ -1,55 +1,62 @@
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Badge } from "@/components/ui/badge";
+import {
+ ArrowUpDownIcon,
+ Columns3Icon,
+ FilterIcon,
+ PlusIcon,
+ SearchIcon,
+ Trash2Icon,
+ XIcon,
+} from 'lucide-react'
+import { useCallback, useEffect, useRef, useState } from 'react'
+import { Badge } from '@/components/ui/badge'
+import { Button } from '@/components/ui/button'
+import { CardTitle } from '@/components/ui/card'
import {
DropdownMenu,
- DropdownMenuContent,
DropdownMenuCheckboxItem,
- DropdownMenuTrigger,
- DropdownMenuSeparator,
+ DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
-} from "@/components/ui/dropdown-menu";
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu'
+import { Input } from '@/components/ui/input'
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select'
import {
Sheet,
+ SheetClose,
SheetContent,
- SheetHeader,
- SheetTitle,
SheetDescription,
SheetFooter,
- SheetClose,
-} from "@/components/ui/sheet";
-import { CardTitle } from "@/components/ui/card";
-import {
- SearchIcon,
- XIcon,
- FilterIcon,
- ArrowUpDownIcon,
- Columns3Icon,
- PlusIcon,
- Trash2Icon,
-} from "lucide-react";
-import { useState, useCallback, useRef, useEffect } from "react";
-import type { ColumnDef, FilterRule, SortOption } from "@/lib/table-registry";
+ SheetHeader,
+ SheetTitle,
+} from '@/components/ui/sheet'
+import type { ColumnDef, FilterRule, SortOption } from '@/lib/table-registry'
interface TableToolbarProps {
/** Displayable columns (for column selector and table headers) */
- 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;
+ 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
/** All columns including filter-only ones (for the filter drawer). Falls back to `columns` if not provided. */
- allColumns?: ColumnDef[];
+ allColumns?: ColumnDef[]
/** Title displayed in the toolbar header */
- title?: string;
- actions?: React.ReactNode;
+ title?: string
+ actions?: React.ReactNode
}
// ============================================================================
@@ -58,42 +65,42 @@ interface TableToolbarProps {
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" },
+ { 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" },
+ { 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" }],
+ 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" },
+ { 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" },
+ { 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;
+ return operatorsByType[type] || operatorsByType.string
}
-const noValueOperators = ["present", "blank"];
+const noValueOperators = ['present', 'blank']
// ============================================================================
// TableToolbar
@@ -105,7 +112,7 @@ export function TableToolbar({
onVisibleColumnsChange,
search,
onSearchChange,
- searchPlaceholder = "Search...",
+ searchPlaceholder = 'Search...',
sort,
onSortChange,
filters,
@@ -114,13 +121,13 @@ export function TableToolbar({
title,
actions,
}: TableToolbarProps) {
- const [filterOpen, setFilterOpen] = useState(false);
- const searchRef = useRef<HTMLInputElement>(null);
+ const [filterOpen, setFilterOpen] = useState(false)
+ const searchRef = useRef<HTMLInputElement>(null)
- const allCols = allColumns ?? columns;
- const sortableColumns = allCols.filter((c) => c.sortable);
- const filterableColumns = allCols.filter((c) => c.filterable);
- const activeFilterCount = filters.length;
+ const allCols = allColumns ?? columns
+ const sortableColumns = allCols.filter((c) => c.sortable)
+ const filterableColumns = allCols.filter((c) => c.filterable)
+ const activeFilterCount = filters.length
return (
<>
@@ -128,22 +135,22 @@ export function TableToolbar({
{title && <CardTitle>{title}</CardTitle>}
<div className="flex gap-2 items-center flex-wrap ml-auto">
{/* 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
+ <div className="flex items-center gap-2 border border-gray-200 bg-white rounded-lg shadow-xs px-2.5 h-[2.125rem] lg:w-[300px] focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-blue-500 transition-all duration-100 ease-in-out">
+ <SearchIcon className="size-4 text-gray-600 shrink-0" />
+ <input
ref={searchRef}
placeholder={searchPlaceholder}
value={search}
onChange={(e) => onSearchChange(e.target.value)}
- className="pl-8 pr-8 h-[2.125rem]"
+ className="h-full w-full border-0 bg-transparent p-0 text-sm text-foreground placeholder:text-muted-foreground outline-none focus:ring-0"
/>
{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"
+ className="p-0.5 text-gray-400 hover:text-gray-600 shrink-0"
onClick={() => {
- onSearchChange("");
- searchRef.current?.focus();
+ onSearchChange('')
+ searchRef.current?.focus()
}}
>
<XIcon className="size-3.5" />
@@ -164,20 +171,14 @@ export function TableToolbar({
<FilterIcon className="size-4" />
Filters
{activeFilterCount > 0 && (
- <Badge className="ml-1 px-1.5 py-0 text-xs">
- {activeFilterCount}
- </Badge>
+ <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}
- />
+ <SortDropdown columns={sortableColumns} sort={sort} onSortChange={onSortChange} />
)}
{/* Column selector */}
@@ -195,16 +196,12 @@ export function TableToolbar({
{filters.length > 0 && (
<div className="flex gap-2 flex-wrap px-3 py-2 border-b border-gray-200">
{filters.map((filter) => {
- const col = allCols.find((c) => c.key === filter.field);
- const ops = getOperators(col?.filterType ?? "string");
- const opLabel =
- ops.find((o) => o.value === filter.operator)?.label ??
- filter.operator;
+ const col = allCols.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="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>
@@ -212,14 +209,12 @@ export function TableToolbar({
<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))
- }
+ onClick={() => onFiltersChange(filters.filter((f) => f.id !== filter.id))}
>
<XIcon className="size-3" />
</button>
</Badge>
- );
+ )
})}
<button
type="button"
@@ -240,7 +235,7 @@ export function TableToolbar({
onApply={onFiltersChange}
/>
</>
- );
+ )
}
// ============================================================================
@@ -252,46 +247,48 @@ function SortDropdown({
sort,
onSortChange,
}: {
- columns: ColumnDef[];
- sort: SortOption;
- onSortChange: (sort: SortOption) => void;
+ 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";
+ const currentCol = columns.find((c) => c.key === sort.field)
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="sm" className="h-[2.125rem]">
<ArrowUpDownIcon className="size-4" />
- {currentCol ? `${currentLabel} (${dirLabel})` : "Sort"}
+ {currentCol?.label ?? '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" });
- }}
+ value={sort.field}
+ onValueChange={(field) => onSortChange({ field, direction: sort.direction })}
>
{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>
+ <DropdownMenuRadioItem key={col.key} value={col.key}>
+ {col.label}
+ </DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
+ <DropdownMenuSeparator />
+ <DropdownMenuLabel>Order</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuRadioGroup
+ value={sort.direction}
+ onValueChange={(dir) =>
+ onSortChange({ field: sort.field, direction: dir as 'asc' | 'desc' })
+ }
+ >
+ <DropdownMenuRadioItem value="asc">Ascending</DropdownMenuRadioItem>
+ <DropdownMenuRadioItem value="desc">Descending</DropdownMenuRadioItem>
+ </DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
- );
+ )
}
// ============================================================================
@@ -303,11 +300,11 @@ function ColumnSelector({
visibleColumns,
onVisibleColumnsChange,
}: {
- columns: ColumnDef[];
- visibleColumns: string[];
- onVisibleColumnsChange: (columns: string[]) => void;
+ columns: ColumnDef[]
+ visibleColumns: string[]
+ onVisibleColumnsChange: (columns: string[]) => void
}) {
- const defaults = columns.filter((c) => c.default).map((c) => c.key);
+ const defaults = columns.filter((c) => c.default).map((c) => c.key)
return (
<DropdownMenu>
@@ -329,7 +326,7 @@ function ColumnSelector({
checked
? [...visibleColumns, col.key]
: visibleColumns.filter((k) => k !== col.key),
- );
+ )
}}
onSelect={(e) => e.preventDefault()}
>
@@ -349,7 +346,7 @@ function ColumnSelector({
</div>
</DropdownMenuContent>
</DropdownMenu>
- );
+ )
}
// ============================================================================
@@ -363,53 +360,48 @@ function FilterDrawer({
filters: initialFilters,
onApply,
}: {
- open: boolean;
- onOpenChange: (open: boolean) => void;
- columns: ColumnDef[];
- filters: FilterRule[];
- onApply: (filters: FilterRule[]) => void;
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ columns: ColumnDef[]
+ filters: FilterRule[]
+ onApply: (filters: FilterRule[]) => void
}) {
- const [draft, setDraft] = useState<FilterRule[]>(initialFilters);
+ const [draft, setDraft] = useState<FilterRule[]>(initialFilters)
// Sync draft when opened
useEffect(() => {
- if (open) setDraft(initialFilters);
- }, [open, initialFilters]);
+ if (open) setDraft(initialFilters)
+ }, [open, initialFilters])
const addFilter = useCallback(() => {
- const first = columns[0];
- if (!first) return;
+ const first = columns[0]
+ if (!first) return
setDraft((prev) => [
...prev,
{
id: crypto.randomUUID(),
field: first.key,
- operator: getOperators(first.filterType ?? "string")[0].value,
- value: "",
+ 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)),
- );
- },
- [],
- );
+ ])
+ }, [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));
- }, []);
+ 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);
+ (f) => noValueOperators.includes(f.operator) || f.value.trim() !== '',
+ )
+ onApply(valid)
+ onOpenChange(false)
}
return (
@@ -417,9 +409,7 @@ function FilterDrawer({
<SheetContent side="right" showCloseButton={false}>
<SheetHeader>
<SheetTitle>Filters</SheetTitle>
- <SheetDescription className="sr-only">
- Build filters for the table
- </SheetDescription>
+ <SheetDescription className="sr-only">Build filters for the table</SheetDescription>
<SheetClose asChild>
<Button variant="ghost" size="icon-sm">
<XIcon />
@@ -429,97 +419,98 @@ function FilterDrawer({
<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);
+ 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"
- >
+ <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"
+ <Select
value={filter.field}
- onChange={(e) => {
- const newCol = columns.find(
- (c) => c.key === e.target.value,
- );
- const newOps = getOperators(newCol?.filterType ?? "string");
+ onValueChange={(val) => {
+ const newCol = columns.find((c) => c.key === val)
+ const newOps = getOperators(newCol?.filterType ?? 'string')
updateFilter(filter.id, {
- field: e.target.value,
+ field: val,
operator: newOps[0].value,
- value: "",
- });
+ value: '',
+ })
}}
>
- {columns.map((c) => (
- <option key={c.key} value={c.key}>
- {c.label}
- </option>
- ))}
- </select>
+ <SelectTrigger className="flex-1">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {columns.map((c) => (
+ <SelectItem key={c.key} value={c.key}>
+ {c.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </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"
+ <Select
value={filter.operator}
- onChange={(e) =>
- updateFilter(filter.id, { operator: e.target.value })
- }
+ onValueChange={(val) => updateFilter(filter.id, { operator: val })}
>
- {ops.map((op) => (
- <option key={op.value} value={op.value}>
- {op.label}
- </option>
- ))}
- </select>
+ <SelectTrigger className="w-[140px] shrink-0">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {ops.map((op) => (
+ <SelectItem key={op.value} value={op.value}>
+ {op.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </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 })
- }
+ (col?.filterType === 'status' && col.filterOptions ? (
+ <Select
+ value={filter.value || undefined}
+ onValueChange={(val) => updateFilter(filter.id, { value: val })}
>
- <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 })
- }
+ <SelectTrigger className="flex-1">
+ <SelectValue placeholder="Select..." />
+ </SelectTrigger>
+ <SelectContent>
+ {col.filterOptions.map((opt) => (
+ <SelectItem key={opt.value} value={opt.value}>
+ {opt.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ ) : col?.filterType === 'boolean' ? (
+ <Select
+ value={filter.value || undefined}
+ onValueChange={(val) => updateFilter(filter.id, { value: val })}
>
- <option value="">Select...</option>
- <option value="true">Yes</option>
- <option value="false">No</option>
- </select>
+ <SelectTrigger className="flex-1">
+ <SelectValue placeholder="Select..." />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="true">Yes</SelectItem>
+ <SelectItem value="false">No</SelectItem>
+ </SelectContent>
+ </Select>
) : (
- <input
+ <Input
type={
- col?.filterType === "number"
- ? "number"
- : col?.filterType === "date"
- ? "date"
- : "text"
+ 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"
+ className="flex-1 py-1.5 px-2"
placeholder="Enter value..."
value={filter.value}
- onChange={(e) =>
- updateFilter(filter.id, { value: e.target.value })
- }
+ onChange={(e) => updateFilter(filter.id, { value: e.target.value })}
/>
))}
@@ -532,7 +523,7 @@ function FilterDrawer({
<Trash2Icon className="size-4" />
</button>
</div>
- );
+ )
})}
{draft.length === 0 && (
@@ -560,5 +551,5 @@ function FilterDrawer({
</SheetFooter>
</SheetContent>
</Sheet>
- );
+ )
}
diff --git a/packages/admin/src/components/tabler-icon.tsx b/packages/admin/src/components/tabler-icon.tsx
index cc5f8e8154..7fbfac82c6 100644
--- a/packages/admin/src/components/tabler-icon.tsx
+++ b/packages/admin/src/components/tabler-icon.tsx
@@ -1,41 +1,41 @@
import {
+ BarChart3Icon,
+ BookOpenIcon,
HomeIcon,
InboxIcon,
+ LogOutIcon,
+ type LucideIcon,
+ MailIcon,
+ MessageCircleIcon,
PackageIcon,
- UsersIcon,
- TagIcon,
- BarChart3Icon,
- SettingsIcon,
- ReceiptIcon,
+ PaletteIcon,
PlugIcon,
+ ReceiptIcon,
+ SettingsIcon,
StoreIcon,
- PaletteIcon,
+ TagIcon,
UserIcon,
- LogOutIcon,
- BookOpenIcon,
- MessageCircleIcon,
- MailIcon,
- type LucideIcon,
+ UsersIcon,
} from 'lucide-react'
import { cn } from '@/lib/utils'
const iconMap: Record<string, LucideIcon> = {
- 'home': HomeIcon,
- 'inbox': InboxIcon,
- 'package': PackageIcon,
- 'users': UsersIcon,
- 'discount': TagIcon,
+ home: HomeIcon,
+ inbox: InboxIcon,
+ package: PackageIcon,
+ users: UsersIcon,
+ discount: TagIcon,
'chart-bar': BarChart3Icon,
- 'settings': SettingsIcon,
+ settings: SettingsIcon,
'receipt-refund': ReceiptIcon,
'plug-connected': PlugIcon,
'building-store': StoreIcon,
- 'palette': PaletteIcon,
+ palette: PaletteIcon,
'user-scan': UserIcon,
'log-out': LogOutIcon,
- 'book': BookOpenIcon,
+ book: BookOpenIcon,
'message-circle': MessageCircleIcon,
- 'mail': MailIcon,
+ mail: MailIcon,
}
interface TablerIconProps {
diff --git a/packages/admin/src/components/ui/avatar.tsx b/packages/admin/src/components/ui/avatar.tsx
index 99f3ed25f0..20f1045b0b 100644
--- a/packages/admin/src/components/ui/avatar.tsx
+++ b/packages/admin/src/components/ui/avatar.tsx
@@ -1,39 +1,33 @@
-import * as React from "react"
-import { Avatar as AvatarPrimitive } from "radix-ui"
+import { Avatar as AvatarPrimitive } from 'radix-ui'
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
function Avatar({
className,
- size = "default",
+ size = 'default',
...props
}: React.ComponentProps<typeof AvatarPrimitive.Root> & {
- size?: "default" | "sm" | "lg"
+ size?: 'default' | 'sm' | 'lg'
}) {
return (
<AvatarPrimitive.Root
data-slot="avatar"
data-size={size}
className={cn(
- "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
- className
+ 'group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten',
+ className,
)}
{...props}
/>
)
}
-function AvatarImage({
- className,
- ...props
-}: React.ComponentProps<typeof AvatarPrimitive.Image>) {
+function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
return (
<AvatarPrimitive.Image
data-slot="avatar-image"
- className={cn(
- "aspect-square size-full rounded-full object-cover",
- className
- )}
+ className={cn('aspect-square size-full rounded-full object-cover', className)}
{...props}
/>
)
@@ -47,64 +41,54 @@ function AvatarFallback({
<AvatarPrimitive.Fallback
data-slot="avatar-fallback"
className={cn(
- "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
- className
+ 'flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs',
+ className,
)}
{...props}
/>
)
}
-function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
+function AvatarBadge({ className, ...props }: React.ComponentProps<'span'>) {
return (
<span
data-slot="avatar-badge"
className={cn(
- "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
- "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
- "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
- "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
- className
+ 'absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none',
+ 'group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden',
+ 'group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2',
+ 'group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2',
+ className,
)}
{...props}
/>
)
}
-function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
+function AvatarGroup({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="avatar-group"
className={cn(
- "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
- className
+ 'group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background',
+ className,
)}
{...props}
/>
)
}
-function AvatarGroupCount({
- className,
- ...props
-}: React.ComponentProps<"div">) {
+function AvatarGroupCount({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="avatar-group-count"
className={cn(
- "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
- className
+ 'relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3',
+ className,
)}
{...props}
/>
)
}
-export {
- Avatar,
- AvatarImage,
- AvatarFallback,
- AvatarGroup,
- AvatarGroupCount,
- AvatarBadge,
-}
+export { Avatar, AvatarImage, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarBadge }
diff --git a/packages/admin/src/components/ui/badge.tsx b/packages/admin/src/components/ui/badge.tsx
index 0fc9c244e7..1eea63470a 100644
--- a/packages/admin/src/components/ui/badge.tsx
+++ b/packages/admin/src/components/ui/badge.tsx
@@ -1,64 +1,70 @@
-import { cva, type VariantProps } from "class-variance-authority"
+import { cva, type VariantProps } from 'class-variance-authority'
-import { cn } from "@/lib/utils"
+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",
+ '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",
+ 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",
+ variant: 'default',
},
- }
+ },
)
function Badge({
className,
variant,
...props
-}: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
- return (
- <span className={cn(badgeVariants({ variant }), className)} {...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",
+const statusVariantMap: Record<string, VariantProps<typeof badgeVariants>['variant']> = {
+ active: 'active',
+ complete: 'active',
+ completed: 'active',
+ paid: 'active',
+ shipped: 'active',
+ published: 'active',
+ approved: 'active',
+ ready: 'active',
+ draft: 'default',
+ pending: 'default',
+ processing: 'default',
+ inactive: 'default',
+ cart: 'default',
+ address: 'default',
+ delivery: 'default',
+ payment: 'default',
+ confirm: 'default',
+ resumed: 'info',
+ partial: 'warning',
+ 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"
+ const variant = statusVariantMap[status] ?? 'default'
return (
- <Badge variant={variant} className={cn("capitalize", className)}>
- {status.replace(/_/g, " ")}
+ <Badge variant={variant} className={cn('capitalize', className)}>
+ {status.replace(/_/g, ' ')}
</Badge>
)
}
diff --git a/packages/admin/src/components/ui/breadcrumb.tsx b/packages/admin/src/components/ui/breadcrumb.tsx
index db9afc0c0f..67db248d2d 100644
--- a/packages/admin/src/components/ui/breadcrumb.tsx
+++ b/packages/admin/src/components/ui/breadcrumb.tsx
@@ -1,38 +1,30 @@
-import * as React from "react"
-import { Slot } from "radix-ui"
+import { ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react'
+import { Slot } from 'radix-ui'
+import type * as React from 'react'
+import { cn } from '@/lib/utils'
-import { cn } from "@/lib/utils"
-import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
-
-function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
- return (
- <nav
- aria-label="breadcrumb"
- data-slot="breadcrumb"
- className={cn(className)}
- {...props}
- />
- )
+function Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>) {
+ return <nav aria-label="breadcrumb" data-slot="breadcrumb" className={cn(className)} {...props} />
}
-function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
+function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
return (
<ol
data-slot="breadcrumb-list"
className={cn(
- "flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",
- className
+ 'flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground',
+ className,
)}
{...props}
/>
)
}
-function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
+function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {
return (
<li
data-slot="breadcrumb-item"
- className={cn("inline-flex items-center gap-1", className)}
+ className={cn('inline-flex items-center gap-1', className)}
{...props}
/>
)
@@ -42,70 +34,57 @@ function BreadcrumbLink({
asChild,
className,
...props
-}: React.ComponentProps<"a"> & {
+}: React.ComponentProps<'a'> & {
asChild?: boolean
}) {
- const Comp = asChild ? Slot.Root : "a"
+ const Comp = asChild ? Slot.Root : 'a'
return (
<Comp
data-slot="breadcrumb-link"
- className={cn("transition-colors hover:text-foreground", className)}
+ className={cn('transition-colors hover:text-foreground', className)}
{...props}
/>
)
}
-function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
+function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {
return (
<span
data-slot="breadcrumb-page"
role="link"
aria-disabled="true"
aria-current="page"
- className={cn("font-normal text-foreground", className)}
+ className={cn('font-normal text-foreground', className)}
{...props}
/>
)
}
-function BreadcrumbSeparator({
- children,
- className,
- ...props
-}: React.ComponentProps<"li">) {
+function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {
return (
<li
data-slot="breadcrumb-separator"
role="presentation"
aria-hidden="true"
- className={cn("[&>svg]:size-3.5", className)}
+ className={cn('[&>svg]:size-3.5', className)}
{...props}
>
- {children ?? (
- <ChevronRightIcon />
- )}
+ {children ?? <ChevronRightIcon />}
</li>
)
}
-function BreadcrumbEllipsis({
- className,
- ...props
-}: React.ComponentProps<"span">) {
+function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {
return (
<span
data-slot="breadcrumb-ellipsis"
role="presentation"
aria-hidden="true"
- className={cn(
- "flex size-5 items-center justify-center [&>svg]:size-4",
- className
- )}
+ className={cn('flex size-5 items-center justify-center [&>svg]:size-4', className)}
{...props}
>
- <MoreHorizontalIcon
- />
+ <MoreHorizontalIcon />
<span className="sr-only">More</span>
</span>
)
diff --git a/packages/admin/src/components/ui/button.tsx b/packages/admin/src/components/ui/button.tsx
index 5b21df0a92..33d4dcb0ff 100644
--- a/packages/admin/src/components/ui/button.tsx
+++ b/packages/admin/src/components/ui/button.tsx
@@ -1,54 +1,52 @@
-import * as React from "react"
-import { cva, type VariantProps } from "class-variance-authority"
-import { Slot } from "radix-ui"
+import { cva, type VariantProps } from 'class-variance-authority'
+import { Slot } from 'radix-ui'
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
const buttonVariants = cva(
"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 shadow-xs hover:bg-zinc-800",
+ default: 'bg-primary text-primary-foreground shadow-xs hover:bg-zinc-800',
outline:
- "border-border bg-muted text-foreground shadow-xs hover:bg-gray-100 hover:text-foreground aria-expanded:bg-gray-100",
+ 'border-border bg-muted text-foreground shadow-xs hover:bg-gray-100 hover:text-foreground aria-expanded:bg-gray-100',
secondary:
- "bg-blue-50 text-blue-900 border-blue-100/75 shadow-xs hover:border-blue-100 hover:bg-blue-100/75",
- ghost:
- "hover:bg-accent hover:text-accent-foreground aria-expanded:bg-accent",
- destructive:
- "text-destructive bg-muted border-border shadow-xs hover:bg-red-100",
- link: "text-primary underline-offset-4 hover:underline",
+ 'bg-blue-50 text-blue-900 border-blue-100/75 shadow-xs hover:border-blue-100 hover:bg-blue-100/75',
+ ghost: 'hover:bg-accent hover:text-accent-foreground aria-expanded:bg-accent',
+ destructive: 'text-destructive bg-muted border-border shadow-xs hover:bg-red-100',
+ link: 'text-primary underline-offset-4 hover:underline',
},
size: {
- default: "h-9 px-3 py-1.5",
+ 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",
+ 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: {
- variant: "default",
- size: "default",
+ variant: 'default',
+ size: 'default',
},
- }
+ },
)
function Button({
className,
- variant = "default",
- size = "default",
+ variant = 'default',
+ size = 'default',
asChild = false,
...props
-}: React.ComponentProps<"button"> &
+}: React.ComponentProps<'button'> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}) {
- const Comp = asChild ? Slot.Root : "button"
+ const Comp = asChild ? Slot.Root : 'button'
return (
<Comp
diff --git a/packages/admin/src/components/ui/card.tsx b/packages/admin/src/components/ui/card.tsx
index ca2da1d324..6cba064a87 100644
--- a/packages/admin/src/components/ui/card.tsx
+++ b/packages/admin/src/components/ui/card.tsx
@@ -1,98 +1,72 @@
-import * as React from "react"
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
-function Card({
- className,
- ...props
-}: React.ComponentProps<"div">) {
+function Card({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="card"
className={cn(
- "group/card flex flex-col min-w-0 break-words bg-white border border-border rounded-xl",
- className
+ 'group/card flex flex-col min-w-0 break-words bg-white border border-border rounded-xl',
+ className,
)}
{...props}
/>
)
}
-function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
+function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="card-header"
className={cn(
- "flex items-center p-5 pr-3 h-14 border-b border-gray-100 rounded-t-[calc(var(--radius-xl)-1px)]",
- className
+ 'flex items-center p-5 pr-3 h-14 border-b border-gray-100 rounded-t-[calc(var(--radius-xl)-1px)]',
+ className,
)}
{...props}
/>
)
}
-function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
+function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="card-title"
- className={cn(
- "text-lg font-medium flex items-center gap-2",
- className
- )}
+ className={cn('text-lg font-medium flex items-center gap-2', className)}
{...props}
/>
)
}
-function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
+function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="card-description"
- className={cn("text-sm text-muted-foreground", className)}
+ className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
)
}
-function CardAction({ className, ...props }: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-action"
- className={cn("ml-auto", className)}
- {...props}
- />
- )
+function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
+ return <div data-slot="card-action" className={cn('ml-auto', className)} {...props} />
}
-function CardContent({ className, ...props }: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-content"
- className={cn("p-5", className)}
- {...props}
- />
- )
+function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
+ return <div data-slot="card-content" className={cn('p-5', className)} {...props} />
}
-function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
+function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="card-footer"
className={cn(
- "flex items-center p-5 bg-transparent border-t border-gray-100 rounded-b-[calc(var(--radius-xl)-1px)]",
- className
+ 'flex items-center p-5 bg-transparent border-t border-gray-100 rounded-b-[calc(var(--radius-xl)-1px)]',
+ className,
)}
{...props}
/>
)
}
-export {
- Card,
- CardHeader,
- CardFooter,
- CardTitle,
- CardAction,
- CardDescription,
- CardContent,
-}
+export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }
diff --git a/packages/admin/src/components/ui/collapsible.tsx b/packages/admin/src/components/ui/collapsible.tsx
index 63fc8eff3f..9845927dd6 100644
--- a/packages/admin/src/components/ui/collapsible.tsx
+++ b/packages/admin/src/components/ui/collapsible.tsx
@@ -1,31 +1,19 @@
-import { Collapsible as CollapsiblePrimitive } from "radix-ui"
+import { Collapsible as CollapsiblePrimitive } from 'radix-ui'
-function Collapsible({
- ...props
-}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
+function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
}
function CollapsibleTrigger({
...props
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
- return (
- <CollapsiblePrimitive.CollapsibleTrigger
- data-slot="collapsible-trigger"
- {...props}
- />
- )
+ return <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} />
}
function CollapsibleContent({
...props
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
- return (
- <CollapsiblePrimitive.CollapsibleContent
- data-slot="collapsible-content"
- {...props}
- />
- )
+ return <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} />
}
export { Collapsible, CollapsibleTrigger, CollapsibleContent }
diff --git a/packages/admin/src/components/ui/data-table.tsx b/packages/admin/src/components/ui/data-table.tsx
index a33bf7e9c5..fca91a2558 100644
--- a/packages/admin/src/components/ui/data-table.tsx
+++ b/packages/admin/src/components/ui/data-table.tsx
@@ -1,55 +1,46 @@
-import { cn } from "@/lib/utils"
-import type { ReactNode } from "react"
+import type { ReactNode } from 'react'
+import { cn } from '@/lib/utils'
-function Table({ className, ...props }: React.ComponentProps<"table">) {
+function Table({ className, ...props }: React.ComponentProps<'table'>) {
return (
<div className="overflow-x-auto">
- <table
- className={cn("w-full align-top text-foreground", className)}
- {...props}
- />
+ <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 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 TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
+ return <tbody className={cn('align-middle', className)} {...props} />
}
-function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
+function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
return (
- <tr
- className={cn(
- "group/row hover:bg-gray-50/75 last:*:border-b-0",
- className
- )}
- {...props}
- />
+ <tr className={cn('group/row hover:bg-gray-50/75 last:*:border-b-0', className)} {...props} />
)
}
-function TableHead({ className, ...props }: React.ComponentProps<"th">) {
+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
+ '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">) {
+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
+ '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}
/>
diff --git a/packages/admin/src/components/ui/dropdown-menu.tsx b/packages/admin/src/components/ui/dropdown-menu.tsx
index 19a539217b..3f5c98ced5 100644
--- a/packages/admin/src/components/ui/dropdown-menu.tsx
+++ b/packages/admin/src/components/ui/dropdown-menu.tsx
@@ -1,39 +1,29 @@
-"use client"
+'use client'
-import * as React from "react"
-import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
+import { CheckIcon, ChevronRightIcon } from 'lucide-react'
+import { DropdownMenu as DropdownMenuPrimitive } from 'radix-ui'
+import type * as React from 'react'
+import { cn } from '@/lib/utils'
-import { cn } from "@/lib/utils"
-import { CheckIcon, ChevronRightIcon } from "lucide-react"
-
-function DropdownMenu({
- ...props
-}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
+function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
}
function DropdownMenuPortal({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
- return (
- <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
- )
+ return <DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
}
function DropdownMenuTrigger({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
- return (
- <DropdownMenuPrimitive.Trigger
- data-slot="dropdown-menu-trigger"
- {...props}
- />
- )
+ return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
}
function DropdownMenuContent({
className,
- align = "start",
+ align = 'start',
sideOffset = 4,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
@@ -44,8 +34,8 @@ function DropdownMenuContent({
sideOffset={sideOffset}
align={align}
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
+ '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}
/>
@@ -53,22 +43,18 @@ function DropdownMenuContent({
)
}
-function DropdownMenuGroup({
- ...props
-}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
- return (
- <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
- )
+function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
+ return <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
}
function DropdownMenuItem({
className,
inset,
- variant = "default",
+ variant = 'default',
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
inset?: boolean
- variant?: "default" | "destructive"
+ variant?: 'default' | 'destructive'
}) {
return (
<DropdownMenuPrimitive.Item
@@ -77,7 +63,7 @@ function DropdownMenuItem({
data-variant={variant}
className={cn(
"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
+ className,
)}
{...props}
/>
@@ -99,7 +85,7 @@ function DropdownMenuCheckboxItem({
data-inset={inset}
className={cn(
"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
+ className,
)}
checked={checked}
{...props}
@@ -120,12 +106,7 @@ function DropdownMenuCheckboxItem({
function DropdownMenuRadioGroup({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
- return (
- <DropdownMenuPrimitive.RadioGroup
- data-slot="dropdown-menu-radio-group"
- {...props}
- />
- )
+ return <DropdownMenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />
}
function DropdownMenuRadioItem({
@@ -142,7 +123,7 @@ function DropdownMenuRadioItem({
data-inset={inset}
className={cn(
"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
+ className,
)}
{...props}
>
@@ -171,8 +152,8 @@ function DropdownMenuLabel({
data-slot="dropdown-menu-label"
data-inset={inset}
className={cn(
- "px-2.5 py-2 text-sm font-normal text-muted-foreground data-inset:pl-7",
- className
+ 'px-2.5 py-2 text-sm font-normal text-muted-foreground data-inset:pl-7',
+ className,
)}
{...props}
/>
@@ -186,31 +167,23 @@ function DropdownMenuSeparator({
return (
<DropdownMenuPrimitive.Separator
data-slot="dropdown-menu-separator"
- className={cn("-mx-1 my-1 h-px bg-gray-100", className)}
+ className={cn('-mx-1 my-1 h-px bg-gray-100', className)}
{...props}
/>
)
}
-function DropdownMenuShortcut({
- className,
- ...props
-}: React.ComponentProps<"span">) {
+function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>) {
return (
<span
data-slot="dropdown-menu-shortcut"
- className={cn(
- "ml-auto text-xs tracking-widest text-muted-foreground",
- className
- )}
+ className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)}
{...props}
/>
)
}
-function DropdownMenuSub({
- ...props
-}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
+function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />
}
@@ -228,7 +201,7 @@ function DropdownMenuSubTrigger({
data-inset={inset}
className={cn(
"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
+ className,
)}
{...props}
>
@@ -246,8 +219,8 @@ function DropdownMenuSubContent({
<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-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
+ '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 27912dee3a..5c5a4466c8 100644
--- a/packages/admin/src/components/ui/input.tsx
+++ b/packages/admin/src/components/ui/input.tsx
@@ -1,15 +1,15 @@
-import * as React from "react"
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
-function Input({ className, type, ...props }: React.ComponentProps<"input">) {
+function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
return (
<input
type={type}
data-slot="input"
className={cn(
- "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
+ '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 24cc0018cf..f406f725e8 100644
--- a/packages/admin/src/components/ui/label.tsx
+++ b/packages/admin/src/components/ui/label.tsx
@@ -1,18 +1,15 @@
-import * as React from "react"
-import { Label as LabelPrimitive } from "radix-ui"
+import { Label as LabelPrimitive } from 'radix-ui'
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
-function Label({
- className,
- ...props
-}: React.ComponentProps<typeof LabelPrimitive.Root>) {
+function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
data-slot="label"
className={cn(
- "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
+ '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
index f8fa63f884..adbd681872 100644
--- a/packages/admin/src/components/ui/pagination.tsx
+++ b/packages/admin/src/components/ui/pagination.tsx
@@ -1,5 +1,5 @@
-import { Button } from "@/components/ui/button"
-import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
+import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'
+import { Button } from '@/components/ui/button'
interface PaginationMeta {
page: number
@@ -35,14 +35,14 @@ export function Pagination({ meta, onPageChange }: PaginationProps) {
<ChevronLeftIcon className="size-4" />
</Button>
{generatePageNumbers(meta.page, meta.pages).map((p, i) =>
- p === "..." ? (
+ p === '...' ? (
<span key={`ellipsis-${i}`} className="px-1 text-sm text-muted-foreground">
...
</span>
) : (
<Button
key={p}
- variant={p === meta.page ? "default" : "ghost"}
+ variant={p === meta.page ? 'default' : 'ghost'}
size="icon-sm"
onClick={() => onPageChange(p as number)}
>
@@ -63,18 +63,18 @@ export function Pagination({ meta, onPageChange }: PaginationProps) {
)
}
-function generatePageNumbers(current: number, total: number): (number | "...")[] {
+function generatePageNumbers(current: number, total: number): (number | '...')[] {
if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
- const pages: (number | "...")[] = [1]
+ const pages: (number | '...')[] = [1]
- if (current > 3) pages.push("...")
+ 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("...")
+ if (current < total - 2) pages.push('...')
pages.push(total)
return pages
diff --git a/packages/admin/src/components/ui/select.tsx b/packages/admin/src/components/ui/select.tsx
new file mode 100644
index 0000000000..c94bbec1d9
--- /dev/null
+++ b/packages/admin/src/components/ui/select.tsx
@@ -0,0 +1,182 @@
+import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
+import { Select as SelectPrimitive } from 'radix-ui'
+import type * as React from 'react'
+import { cn } from '@/lib/utils'
+
+function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {
+ return <SelectPrimitive.Root data-slot="select" {...props} />
+}
+
+function SelectGroup({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Group>) {
+ return (
+ <SelectPrimitive.Group
+ data-slot="select-group"
+ className={cn('scroll-my-1 p-1', className)}
+ {...props}
+ />
+ )
+}
+
+function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>) {
+ return <SelectPrimitive.Value data-slot="select-value" {...props} />
+}
+
+function SelectTrigger({
+ className,
+ size = 'default',
+ children,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
+ size?: 'sm' | 'default'
+}) {
+ return (
+ <SelectPrimitive.Trigger
+ data-slot="select-trigger"
+ data-size={size}
+ className={cn(
+ "flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 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",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+ <SelectPrimitive.Icon asChild>
+ <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
+ </SelectPrimitive.Icon>
+ </SelectPrimitive.Trigger>
+ )
+}
+
+function SelectContent({
+ className,
+ children,
+ position = 'item-aligned',
+ align = 'center',
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Content>) {
+ return (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Content
+ data-slot="select-content"
+ data-align-trigger={position === 'item-aligned'}
+ className={cn(
+ 'relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none 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',
+ position === 'popper' &&
+ 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
+ className,
+ )}
+ position={position}
+ align={align}
+ {...props}
+ >
+ <SelectScrollUpButton />
+ <SelectPrimitive.Viewport
+ data-position={position}
+ className={cn(
+ 'data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)',
+ position === 'popper' && '',
+ )}
+ >
+ {children}
+ </SelectPrimitive.Viewport>
+ <SelectScrollDownButton />
+ </SelectPrimitive.Content>
+ </SelectPrimitive.Portal>
+ )
+}
+
+function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>) {
+ return (
+ <SelectPrimitive.Label
+ data-slot="select-label"
+ className={cn('px-1.5 py-1 text-xs text-muted-foreground', className)}
+ {...props}
+ />
+ )
+}
+
+function SelectItem({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Item>) {
+ return (
+ <SelectPrimitive.Item
+ data-slot="select-item"
+ className={cn(
+ "relative flex w-full 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 not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
+ className,
+ )}
+ {...props}
+ >
+ <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center">
+ <SelectPrimitive.ItemIndicator>
+ <CheckIcon className="pointer-events-none" />
+ </SelectPrimitive.ItemIndicator>
+ </span>
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ </SelectPrimitive.Item>
+ )
+}
+
+function SelectSeparator({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
+ return (
+ <SelectPrimitive.Separator
+ data-slot="select-separator"
+ className={cn('pointer-events-none -mx-1 my-1 h-px bg-border', className)}
+ {...props}
+ />
+ )
+}
+
+function SelectScrollUpButton({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
+ return (
+ <SelectPrimitive.ScrollUpButton
+ data-slot="select-scroll-up-button"
+ className={cn(
+ "z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
+ className,
+ )}
+ {...props}
+ >
+ <ChevronUpIcon />
+ </SelectPrimitive.ScrollUpButton>
+ )
+}
+
+function SelectScrollDownButton({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
+ return (
+ <SelectPrimitive.ScrollDownButton
+ data-slot="select-scroll-down-button"
+ className={cn(
+ "z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
+ className,
+ )}
+ {...props}
+ >
+ <ChevronDownIcon />
+ </SelectPrimitive.ScrollDownButton>
+ )
+}
+
+export {
+ Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectLabel,
+ SelectScrollDownButton,
+ SelectScrollUpButton,
+ SelectSeparator,
+ SelectTrigger,
+ SelectValue,
+}
diff --git a/packages/admin/src/components/ui/separator.tsx b/packages/admin/src/components/ui/separator.tsx
index ca11501513..0ff166af5d 100644
--- a/packages/admin/src/components/ui/separator.tsx
+++ b/packages/admin/src/components/ui/separator.tsx
@@ -1,11 +1,11 @@
-import * as React from "react"
-import { Separator as SeparatorPrimitive } from "radix-ui"
+import { Separator as SeparatorPrimitive } from 'radix-ui'
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
function Separator({
className,
- orientation = "horizontal",
+ orientation = 'horizontal',
decorative = true,
...props
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
@@ -15,8 +15,8 @@ function Separator({
decorative={decorative}
orientation={orientation}
className={cn(
- "shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
- className
+ 'shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch',
+ className,
)}
{...props}
/>
diff --git a/packages/admin/src/components/ui/sheet.tsx b/packages/admin/src/components/ui/sheet.tsx
index 686142c34b..b88fefbe1d 100644
--- a/packages/admin/src/components/ui/sheet.tsx
+++ b/packages/admin/src/components/ui/sheet.tsx
@@ -1,31 +1,24 @@
-"use client"
+'use client'
-import * as React from "react"
-import { Dialog as SheetPrimitive } from "radix-ui"
-
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
-import { XIcon } from "lucide-react"
+import { XIcon } from 'lucide-react'
+import { Dialog as SheetPrimitive } from 'radix-ui'
+import type * as React from 'react'
+import { Button } from '@/components/ui/button'
+import { cn } from '@/lib/utils'
function Sheet({ ...props }: React.ComponentProps<typeof SheetPrimitive.Root>) {
return <SheetPrimitive.Root data-slot="sheet" {...props} />
}
-function SheetTrigger({
- ...props
-}: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
+function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
}
-function SheetClose({
- ...props
-}: React.ComponentProps<typeof SheetPrimitive.Close>) {
+function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
}
-function SheetPortal({
- ...props
-}: React.ComponentProps<typeof SheetPrimitive.Portal>) {
+function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
return <SheetPrimitive.Portal data-slot="sheet-portal" {...props} />
}
@@ -37,8 +30,8 @@ function SheetOverlay({
<SheetPrimitive.Overlay
data-slot="sheet-overlay"
className={cn(
- "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
+ '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}
/>
@@ -48,11 +41,11 @@ function SheetOverlay({
function SheetContent({
className,
children,
- side = "right",
+ side = 'right',
showCloseButton = true,
...props
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
- side?: "top" | "right" | "bottom" | "left"
+ side?: 'top' | 'right' | 'bottom' | 'left'
showCloseButton?: boolean
}) {
return (
@@ -62,25 +55,21 @@ function SheetContent({
data-slot="sheet-content"
data-side={side}
className={cn(
- "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
+ '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}
>
{children}
{showCloseButton && (
<SheetPrimitive.Close data-slot="sheet-close" asChild>
- <Button
- variant="ghost"
- className="absolute top-3 right-3"
- size="icon-sm"
- >
+ <Button variant="ghost" className="absolute top-3 right-3" size="icon-sm">
<XIcon />
<span className="sr-only">Close</span>
</Button>
@@ -91,34 +80,34 @@ function SheetContent({
)
}
-function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
+function SheetHeader({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sheet-header"
- className={cn("flex items-center justify-between p-4 border-b border-gray-100", className)}
+ className={cn('flex items-center justify-between p-4 border-b border-gray-100', className)}
{...props}
/>
)
}
-function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
+function SheetFooter({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sheet-footer"
- className={cn("flex items-center justify-between p-4 bg-muted border-t border-gray-100 rounded-b-2xl", className)}
+ className={cn(
+ 'flex items-center justify-between p-4 bg-muted border-t border-gray-100 rounded-b-2xl',
+ className,
+ )}
{...props}
/>
)
}
-function SheetTitle({
- className,
- ...props
-}: React.ComponentProps<typeof SheetPrimitive.Title>) {
+function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>) {
return (
<SheetPrimitive.Title
data-slot="sheet-title"
- className={cn("text-base font-semibold text-foreground", className)}
+ className={cn('text-base font-semibold text-foreground', className)}
{...props}
/>
)
@@ -131,7 +120,7 @@ function SheetDescription({
return (
<SheetPrimitive.Description
data-slot="sheet-description"
- className={cn("text-sm text-muted-foreground", className)}
+ className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
)
diff --git a/packages/admin/src/components/ui/sidebar.tsx b/packages/admin/src/components/ui/sidebar.tsx
index 54aaf5ab81..224e5cfb4d 100644
--- a/packages/admin/src/components/ui/sidebar.tsx
+++ b/packages/admin/src/components/ui/sidebar.tsx
@@ -1,36 +1,31 @@
-import * as React from "react"
-import { cva, type VariantProps } from "class-variance-authority"
-import { Slot } from "radix-ui"
-
-import { useIsMobile } from "@/hooks/use-mobile"
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
-import { Input } from "@/components/ui/input"
-import { Separator } from "@/components/ui/separator"
+import { cva, type VariantProps } from 'class-variance-authority'
+import { PanelLeftIcon } from 'lucide-react'
+import { Slot } from 'radix-ui'
+import * as React from 'react'
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
+import { Separator } from '@/components/ui/separator'
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
-} from "@/components/ui/sheet"
-import { Skeleton } from "@/components/ui/skeleton"
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip"
-import { PanelLeftIcon } from "lucide-react"
+} from '@/components/ui/sheet'
+import { Skeleton } from '@/components/ui/skeleton'
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
+import { useIsMobile } from '@/hooks/use-mobile'
+import { cn } from '@/lib/utils'
-const SIDEBAR_COOKIE_NAME = "sidebar_state"
+const SIDEBAR_COOKIE_NAME = 'sidebar_state'
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
-const SIDEBAR_WIDTH = "220px"
-const SIDEBAR_WIDTH_MOBILE = "220px"
-const SIDEBAR_WIDTH_ICON = "3rem"
-const SIDEBAR_KEYBOARD_SHORTCUT = "b"
+const SIDEBAR_WIDTH = '220px'
+const SIDEBAR_WIDTH_MOBILE = '220px'
+const SIDEBAR_WIDTH_ICON = '3rem'
+const SIDEBAR_KEYBOARD_SHORTCUT = 'b'
type SidebarContextProps = {
- state: "expanded" | "collapsed"
+ state: 'expanded' | 'collapsed'
open: boolean
setOpen: (open: boolean) => void
openMobile: boolean
@@ -44,7 +39,7 @@ const SidebarContext = React.createContext<SidebarContextProps | null>(null)
function useSidebar() {
const context = React.useContext(SidebarContext)
if (!context) {
- throw new Error("useSidebar must be used within a SidebarProvider.")
+ throw new Error('useSidebar must be used within a SidebarProvider.')
}
return context
@@ -58,7 +53,7 @@ function SidebarProvider({
style,
children,
...props
-}: React.ComponentProps<"div"> & {
+}: React.ComponentProps<'div'> & {
defaultOpen?: boolean
open?: boolean
onOpenChange?: (open: boolean) => void
@@ -72,7 +67,7 @@ function SidebarProvider({
const open = openProp ?? _open
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
- const openState = typeof value === "function" ? value(open) : value
+ const openState = typeof value === 'function' ? value(open) : value
if (setOpenProp) {
setOpenProp(openState)
} else {
@@ -82,7 +77,7 @@ function SidebarProvider({
// This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
- [setOpenProp, open]
+ [setOpenProp, open],
)
// Helper to toggle the sidebar.
@@ -93,22 +88,19 @@ function SidebarProvider({
// Adds a keyboard shortcut to toggle the sidebar.
React.useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
- if (
- event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
- (event.metaKey || event.ctrlKey)
- ) {
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
event.preventDefault()
toggleSidebar()
}
}
- window.addEventListener("keydown", handleKeyDown)
- return () => window.removeEventListener("keydown", handleKeyDown)
+ window.addEventListener('keydown', handleKeyDown)
+ return () => window.removeEventListener('keydown', handleKeyDown)
}, [toggleSidebar])
// We add a state so that we can do data-state="expanded" or "collapsed".
// This makes it easier to style the sidebar with Tailwind classes.
- const state = open ? "expanded" : "collapsed"
+ const state = open ? 'expanded' : 'collapsed'
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
@@ -120,7 +112,7 @@ function SidebarProvider({
setOpenMobile,
toggleSidebar,
}),
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar],
)
return (
@@ -129,14 +121,14 @@ function SidebarProvider({
data-slot="sidebar-wrapper"
style={
{
- "--sidebar-width": SIDEBAR_WIDTH,
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
+ '--sidebar-width': SIDEBAR_WIDTH,
+ '--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
...style,
} as React.CSSProperties
}
className={cn(
- "group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
- className
+ 'group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar',
+ className,
)}
{...props}
>
@@ -147,27 +139,27 @@ function SidebarProvider({
}
function Sidebar({
- side = "left",
- variant = "sidebar",
- collapsible = "offcanvas",
+ side = 'left',
+ variant = 'sidebar',
+ collapsible = 'offcanvas',
className,
children,
dir,
...props
-}: React.ComponentProps<"div"> & {
- side?: "left" | "right"
- variant?: "sidebar" | "floating" | "inset"
- collapsible?: "offcanvas" | "icon" | "none"
+}: React.ComponentProps<'div'> & {
+ side?: 'left' | 'right'
+ variant?: 'sidebar' | 'floating' | 'inset'
+ collapsible?: 'offcanvas' | 'icon' | 'none'
}) {
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
- if (collapsible === "none") {
+ if (collapsible === 'none') {
return (
<div
data-slot="sidebar"
className={cn(
- "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
- className
+ 'flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground',
+ className,
)}
{...props}
>
@@ -187,7 +179,7 @@ function Sidebar({
className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
style={
{
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
+ '--sidebar-width': SIDEBAR_WIDTH_MOBILE,
} as React.CSSProperties
}
side={side}
@@ -206,7 +198,7 @@ function Sidebar({
<div
className="group peer hidden text-sidebar-foreground md:block"
data-state={state}
- data-collapsible={state === "collapsed" ? collapsible : ""}
+ data-collapsible={state === 'collapsed' ? collapsible : ''}
data-variant={variant}
data-side={side}
data-slot="sidebar"
@@ -215,24 +207,24 @@ function Sidebar({
<div
data-slot="sidebar-gap"
className={cn(
- "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
- "group-data-[collapsible=offcanvas]:w-0",
- "group-data-[side=right]:rotate-180",
- variant === "floating" || variant === "inset"
- ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
+ 'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear',
+ 'group-data-[collapsible=offcanvas]:w-0',
+ 'group-data-[side=right]:rotate-180',
+ variant === 'floating' || variant === 'inset'
+ ? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
)}
/>
<div
data-slot="sidebar-container"
data-side={side}
className={cn(
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
+ 'fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex',
// Adjust the padding for floating and inset variants.
- variant === "floating" || variant === "inset"
- ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
- className
+ variant === 'floating' || variant === 'inset'
+ ? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
+ : 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
+ className,
)}
{...props}
>
@@ -248,11 +240,7 @@ function Sidebar({
)
}
-function SidebarTrigger({
- className,
- onClick,
- ...props
-}: React.ComponentProps<typeof Button>) {
+function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>) {
const { toggleSidebar } = useSidebar()
return (
@@ -274,7 +262,7 @@ function SidebarTrigger({
)
}
-function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
+function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
const { toggleSidebar } = useSidebar()
return (
@@ -286,102 +274,96 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
onClick={toggleSidebar}
title="Toggle Sidebar"
className={cn(
- "absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2",
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
- "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar",
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
- className
+ 'absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2',
+ 'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
+ '[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
+ 'group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar',
+ '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
+ '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
+ className,
)}
{...props}
/>
)
}
-function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
+function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
return (
<main
data-slot="sidebar-inset"
className={cn(
- "relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
- className
+ 'relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',
+ className,
)}
{...props}
/>
)
}
-function SidebarInput({
- className,
- ...props
-}: React.ComponentProps<typeof Input>) {
+function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>) {
return (
<Input
data-slot="sidebar-input"
data-sidebar="input"
- className={cn("h-8 w-full bg-background shadow-none", className)}
+ className={cn('h-8 w-full bg-background shadow-none', className)}
{...props}
/>
)
}
-function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarHeader({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-header"
data-sidebar="header"
- className={cn("flex flex-col gap-0 px-2", className)}
+ className={cn('flex flex-col gap-0 px-2', className)}
{...props}
/>
)
}
-function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarFooter({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-footer"
data-sidebar="footer"
- className={cn("flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border", className)}
+ className={cn('flex flex-col gap-0 p-2 mt-auto border-t border-sidebar-border', className)}
{...props}
/>
)
}
-function SidebarSeparator({
- className,
- ...props
-}: React.ComponentProps<typeof Separator>) {
+function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
return (
<Separator
data-slot="sidebar-separator"
data-sidebar="separator"
- className={cn("mx-2 w-auto bg-sidebar-border", className)}
+ className={cn('mx-2 w-auto bg-sidebar-border', className)}
{...props}
/>
)
}
-function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarContent({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- "no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
- className
+ 'no-scrollbar flex min-h-0 flex-1 flex-col gap-0 pt-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden',
+ className,
)}
{...props}
/>
)
}
-function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
+function SidebarGroup({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-group"
data-sidebar="group"
- className={cn("relative flex w-full min-w-0 flex-col px-3 py-0", className)}
+ className={cn('relative flex w-full min-w-0 flex-col px-3 py-0', className)}
{...props}
/>
)
@@ -391,16 +373,16 @@ function SidebarGroupLabel({
className,
asChild = false,
...props
-}: React.ComponentProps<"div"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot.Root : "div"
+}: React.ComponentProps<'div'> & { asChild?: boolean }) {
+ const Comp = asChild ? Slot.Root : 'div'
return (
<Comp
data-slot="sidebar-group-label"
data-sidebar="group-label"
className={cn(
- "flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
- className
+ 'flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
+ className,
)}
{...props}
/>
@@ -411,94 +393,91 @@ function SidebarGroupAction({
className,
asChild = false,
...props
-}: React.ComponentProps<"button"> & { asChild?: boolean }) {
- const Comp = asChild ? Slot.Root : "button"
+}: React.ComponentProps<'button'> & { asChild?: boolean }) {
+ const Comp = asChild ? Slot.Root : 'button'
return (
<Comp
data-slot="sidebar-group-action"
data-sidebar="group-action"
className={cn(
- "absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
- className
+ 'absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',
+ className,
)}
{...props}
/>
)
}
-function SidebarGroupContent({
- className,
- ...props
-}: React.ComponentProps<"div">) {
+function SidebarGroupContent({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-group-content"
data-sidebar="group-content"
- className={cn("w-full text-sm", className)}
+ className={cn('w-full text-sm', className)}
{...props}
/>
)
}
-function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
+function SidebarMenu({ className, ...props }: React.ComponentProps<'ul'>) {
return (
<ul
data-slot="sidebar-menu"
data-sidebar="menu"
- className={cn("flex w-full min-w-0 flex-col gap-1", className)}
+ className={cn('flex w-full min-w-0 flex-col gap-1', className)}
{...props}
/>
)
}
-function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
+function SidebarMenuItem({ className, ...props }: React.ComponentProps<'li'>) {
return (
<li
data-slot="sidebar-menu-item"
data-sidebar="menu-item"
- className={cn("group/menu-item relative", className)}
+ className={cn('group/menu-item relative', className)}
{...props}
/>
)
}
const sidebarMenuButtonVariants = cva(
- "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",
+ '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: "",
+ 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))]",
+ '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))]',
},
size: {
- default: "h-8 text-sm",
- sm: "h-7 text-xs",
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
+ default: 'h-8 text-sm',
+ sm: 'h-7 text-xs',
+ lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!',
},
},
defaultVariants: {
- variant: "default",
- size: "default",
+ variant: 'default',
+ size: 'default',
},
- }
+ },
)
function SidebarMenuButton({
asChild = false,
isActive = false,
- variant = "default",
- size = "default",
+ variant = 'default',
+ size = 'default',
tooltip,
className,
...props
-}: React.ComponentProps<"button"> & {
+}: React.ComponentProps<'button'> & {
asChild?: boolean
isActive?: boolean
tooltip?: string | React.ComponentProps<typeof TooltipContent>
} & VariantProps<typeof sidebarMenuButtonVariants>) {
- const Comp = asChild ? Slot.Root : "button"
+ const Comp = asChild ? Slot.Root : 'button'
const { isMobile, state } = useSidebar()
const button = (
@@ -516,7 +495,7 @@ function SidebarMenuButton({
return button
}
- if (typeof tooltip === "string") {
+ if (typeof tooltip === 'string') {
tooltip = {
children: tooltip,
}
@@ -528,7 +507,7 @@ function SidebarMenuButton({
<TooltipContent
side="right"
align="center"
- hidden={state !== "collapsed" || isMobile}
+ hidden={state !== 'collapsed' || isMobile}
{...tooltip}
/>
</Tooltip>
@@ -540,38 +519,35 @@ function SidebarMenuAction({
asChild = false,
showOnHover = false,
...props
-}: React.ComponentProps<"button"> & {
+}: React.ComponentProps<'button'> & {
asChild?: boolean
showOnHover?: boolean
}) {
- const Comp = asChild ? Slot.Root : "button"
+ const Comp = asChild ? Slot.Root : 'button'
return (
<Comp
data-slot="sidebar-menu-action"
data-sidebar="menu-action"
className={cn(
- "absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0",
+ 'absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0',
showOnHover &&
- "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0",
- className
+ 'group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0',
+ className,
)}
{...props}
/>
)
}
-function SidebarMenuBadge({
- className,
- ...props
-}: React.ComponentProps<"div">) {
+function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="sidebar-menu-badge"
data-sidebar="menu-badge"
className={cn(
- "pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
- className
+ 'pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground',
+ className,
)}
{...props}
/>
@@ -582,7 +558,7 @@ function SidebarMenuSkeleton({
className,
showIcon = false,
...props
-}: React.ComponentProps<"div"> & {
+}: React.ComponentProps<'div'> & {
showIcon?: boolean
}) {
// Random width between 50 to 90%.
@@ -594,21 +570,16 @@ function SidebarMenuSkeleton({
<div
data-slot="sidebar-menu-skeleton"
data-sidebar="menu-skeleton"
- className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
+ className={cn('flex h-8 items-center gap-2 rounded-md px-2', className)}
{...props}
>
- {showIcon && (
- <Skeleton
- className="size-4 rounded-md"
- data-sidebar="menu-skeleton-icon"
- />
- )}
+ {showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
<Skeleton
className="h-4 max-w-(--skeleton-width) flex-1"
data-sidebar="menu-skeleton-text"
style={
{
- "--skeleton-width": width,
+ '--skeleton-width': width,
} as React.CSSProperties
}
/>
@@ -616,29 +587,26 @@ function SidebarMenuSkeleton({
)
}
-function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
+function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
return (
<ul
data-slot="sidebar-menu-sub"
data-sidebar="menu-sub"
className={cn(
- "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
+ '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}
/>
)
}
-function SidebarMenuSubItem({
- className,
- ...props
-}: React.ComponentProps<"li">) {
+function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<'li'>) {
return (
<li
data-slot="sidebar-menu-sub-item"
data-sidebar="menu-sub-item"
- className={cn("group/menu-sub-item relative", className)}
+ className={cn('group/menu-sub-item relative', className)}
{...props}
/>
)
@@ -646,16 +614,16 @@ function SidebarMenuSubItem({
function SidebarMenuSubButton({
asChild = false,
- size = "md",
+ size = 'md',
isActive = false,
className,
...props
-}: React.ComponentProps<"a"> & {
+}: React.ComponentProps<'a'> & {
asChild?: boolean
- size?: "sm" | "md"
+ size?: 'sm' | 'md'
isActive?: boolean
}) {
- const Comp = asChild ? Slot.Root : "a"
+ const Comp = asChild ? Slot.Root : 'a'
return (
<Comp
@@ -664,8 +632,8 @@ function SidebarMenuSubButton({
data-size={size}
data-active={isActive}
className={cn(
- "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
+ '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/skeleton.tsx b/packages/admin/src/components/ui/skeleton.tsx
index 0118624f6e..1fef545792 100644
--- a/packages/admin/src/components/ui/skeleton.tsx
+++ b/packages/admin/src/components/ui/skeleton.tsx
@@ -1,10 +1,10 @@
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
-function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
+function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
return (
<div
data-slot="skeleton"
- className={cn("animate-pulse rounded-md bg-muted", className)}
+ className={cn('animate-pulse rounded-md bg-muted', className)}
{...props}
/>
)
diff --git a/packages/admin/src/components/ui/tooltip.tsx b/packages/admin/src/components/ui/tooltip.tsx
index 561b5e90f8..d4bc2e4fef 100644
--- a/packages/admin/src/components/ui/tooltip.tsx
+++ b/packages/admin/src/components/ui/tooltip.tsx
@@ -1,9 +1,9 @@
-"use client"
+'use client'
-import * as React from "react"
-import { Tooltip as TooltipPrimitive } from "radix-ui"
+import { Tooltip as TooltipPrimitive } from 'radix-ui'
+import type * as React from 'react'
-import { cn } from "@/lib/utils"
+import { cn } from '@/lib/utils'
function TooltipProvider({
delayDuration = 0,
@@ -18,15 +18,11 @@ function TooltipProvider({
)
}
-function Tooltip({
- ...props
-}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
+function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
}
-function TooltipTrigger({
- ...props
-}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
+function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
}
@@ -42,8 +38,8 @@ function TooltipContent({
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
- "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
+ '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}
>
diff --git a/packages/admin/src/hooks/use-mobile.ts b/packages/admin/src/hooks/use-mobile.ts
index 2b0fe1dfef..4331d5c562 100644
--- a/packages/admin/src/hooks/use-mobile.ts
+++ b/packages/admin/src/hooks/use-mobile.ts
@@ -1,4 +1,4 @@
-import * as React from "react"
+import * as React from 'react'
const MOBILE_BREAKPOINT = 768
@@ -10,9 +10,9 @@ export function useIsMobile() {
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
- mql.addEventListener("change", onChange)
+ mql.addEventListener('change', onChange)
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
- return () => mql.removeEventListener("change", onChange)
+ return () => mql.removeEventListener('change', onChange)
}, [])
return !!isMobile
diff --git a/packages/admin/src/hooks/use-products.ts b/packages/admin/src/hooks/use-products.ts
index a489e42b91..9940842c7a 100644
--- a/packages/admin/src/hooks/use-products.ts
+++ b/packages/admin/src/hooks/use-products.ts
@@ -11,7 +11,13 @@ interface UseProductsParams {
filters?: FilterRule[]
}
-export function useProducts({ page = 1, limit = 25, sort = '-updated_at', search, filters = [] }: UseProductsParams = {}) {
+export function useProducts({
+ page = 1,
+ limit = 25,
+ sort = '-updated_at',
+ search,
+ filters = [],
+}: UseProductsParams = {}) {
const { token } = useAuth()
return useQuery({
diff --git a/packages/admin/src/lib/formatters.ts b/packages/admin/src/lib/formatters.ts
index a75efc0da1..d94f3a731c 100644
--- a/packages/admin/src/lib/formatters.ts
+++ b/packages/admin/src/lib/formatters.ts
@@ -1,4 +1,6 @@
-export function formatPrice(price: { amount?: string; currency?: string; display?: string } | null) {
+export function formatPrice(
+ price: { amount?: string; currency?: string; display?: string } | null,
+) {
if (!price) return '—'
return price.display ?? `${price.currency} ${price.amount}`
}
diff --git a/packages/admin/src/lib/table-registry.ts b/packages/admin/src/lib/table-registry.ts
index f8657b0149..6948bf53d8 100644
--- a/packages/admin/src/lib/table-registry.ts
+++ b/packages/admin/src/lib/table-registry.ts
@@ -59,7 +59,8 @@ export function defineTable<T = any>(key: string, def: Omit<TableDef<T>, 'key'>)
export function getTable<T = any>(key: string): TableDef<T> {
const table = registry.get(key)
- if (!table) throw new Error(`Table "${key}" is not registered. Call defineTable("${key}", ...) first.`)
+ if (!table)
+ throw new Error(`Table "${key}" is not registered. Call defineTable("${key}", ...) first.`)
return table as TableDef<T>
}
@@ -86,7 +87,9 @@ function createMutator(tableKey: string): TableMutator {
if (!table) throw new Error(`Table "${tableKey}" is not registered.`)
// Prevent duplicates
if (table.columns.some((c) => c.key === column.key)) {
- throw new Error(`Column "${column.key}" already exists in table "${tableKey}". Use updateColumn() instead.`)
+ throw new Error(
+ `Column "${column.key}" already exists in table "${tableKey}". Use updateColumn() instead.`,
+ )
}
table.columns.push(column)
},
diff --git a/packages/admin/src/lib/utils.ts b/packages/admin/src/lib/utils.ts
index bd0c391ddd..d32b0fe652 100644
--- a/packages/admin/src/lib/utils.ts
+++ b/packages/admin/src/lib/utils.ts
@@ -1,5 +1,5 @@
-import { clsx, type ClassValue } from "clsx"
-import { twMerge } from "tailwind-merge"
+import { type ClassValue, clsx } from 'clsx'
+import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
diff --git a/packages/admin/src/main.tsx b/packages/admin/src/main.tsx
index e735b5ec41..ef8861ef5f 100644
--- a/packages/admin/src/main.tsx
+++ b/packages/admin/src/main.tsx
@@ -1,11 +1,11 @@
-import { StrictMode } from 'react'
-import { createRoot } from 'react-dom/client'
import { QueryClientProvider } from '@tanstack/react-query'
import { RouterProvider } from '@tanstack/react-router'
+import { StrictMode } from 'react'
+import { createRoot } from 'react-dom/client'
import { TooltipProvider } from '@/components/ui/tooltip'
-import { AuthProvider } from '@/providers/auth-provider'
import { useAuth } from '@/hooks/use-auth'
import { queryClient } from '@/lib/query-client'
+import { AuthProvider } from '@/providers/auth-provider'
import { router } from '@/router'
import './index.css'
diff --git a/packages/admin/src/providers/auth-provider.tsx b/packages/admin/src/providers/auth-provider.tsx
index d8d102158b..b4826abe11 100644
--- a/packages/admin/src/providers/auth-provider.tsx
+++ b/packages/admin/src/providers/auth-provider.tsx
@@ -1,4 +1,4 @@
-import { createContext, useCallback, useEffect, useState, type ReactNode } from 'react'
+import { createContext, type ReactNode, useCallback, useEffect, useState } from 'react'
import { spreeClient } from '@/client'
interface AuthUser {
@@ -23,9 +23,7 @@ const TOKEN_KEY = 'spree_admin_token'
const USER_KEY = 'spree_admin_user'
export function AuthProvider({ children }: { children: ReactNode }) {
- const [token, setToken] = useState<string | null>(() =>
- localStorage.getItem(TOKEN_KEY),
- )
+ const [token, setToken] = useState<string | null>(() => localStorage.getItem(TOKEN_KEY))
const [user, setUser] = useState<AuthUser | null>(() => {
const stored = localStorage.getItem(USER_KEY)
return stored ? JSON.parse(stored) : null
@@ -52,15 +50,19 @@ export function AuthProvider({ children }: { children: ReactNode }) {
localStorage.removeItem(USER_KEY)
}, [])
+ // biome-ignore lint/correctness/useExhaustiveDependencies: only run on mount
useEffect(() => {
if (!token) return
- spreeClient.admin.auth.refresh({ token }).then((response) => {
- setToken(response.token)
- localStorage.setItem(TOKEN_KEY, response.token)
- }).catch(() => {
- logout()
- })
+ spreeClient.admin.auth
+ .refresh({ token })
+ .then((response) => {
+ setToken(response.token)
+ localStorage.setItem(TOKEN_KEY, response.token)
+ })
+ .catch(() => {
+ logout()
+ })
}, []) // eslint-disable-line react-hooks/exhaustive-deps
return (
diff --git a/packages/admin/src/routeTree.gen.ts b/packages/admin/src/routeTree.gen.ts
index 55662f70d1..1fd4f6babb 100644
--- a/packages/admin/src/routeTree.gen.ts
+++ b/packages/admin/src/routeTree.gen.ts
@@ -15,6 +15,8 @@ import { Route as AuthenticatedIndexRouteImport } from './routes/_authenticated/
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'
+import { Route as AuthenticatedOrdersDraftsRouteImport } from './routes/_authenticated/orders/drafts'
+import { Route as AuthenticatedOrdersOrderIdRouteImport } from './routes/_authenticated/orders/$orderId'
const LoginRoute = LoginRouteImport.update({
id: '/login',
@@ -48,10 +50,24 @@ const AuthenticatedProductsProductIdRoute =
path: '/products/$productId',
getParentRoute: () => AuthenticatedRoute,
} as any)
+const AuthenticatedOrdersDraftsRoute =
+ AuthenticatedOrdersDraftsRouteImport.update({
+ id: '/orders/drafts',
+ path: '/orders/drafts',
+ getParentRoute: () => AuthenticatedRoute,
+ } as any)
+const AuthenticatedOrdersOrderIdRoute =
+ AuthenticatedOrdersOrderIdRouteImport.update({
+ id: '/orders/$orderId',
+ path: '/orders/$orderId',
+ getParentRoute: () => AuthenticatedRoute,
+ } as any)
export interface FileRoutesByFullPath {
'/': typeof AuthenticatedIndexRoute
'/login': typeof LoginRoute
+ '/orders/$orderId': typeof AuthenticatedOrdersOrderIdRoute
+ '/orders/drafts': typeof AuthenticatedOrdersDraftsRoute
'/products/$productId': typeof AuthenticatedProductsProductIdRoute
'/orders/': typeof AuthenticatedOrdersIndexRoute
'/products/': typeof AuthenticatedProductsIndexRoute
@@ -59,6 +75,8 @@ export interface FileRoutesByFullPath {
export interface FileRoutesByTo {
'/login': typeof LoginRoute
'/': typeof AuthenticatedIndexRoute
+ '/orders/$orderId': typeof AuthenticatedOrdersOrderIdRoute
+ '/orders/drafts': typeof AuthenticatedOrdersDraftsRoute
'/products/$productId': typeof AuthenticatedProductsProductIdRoute
'/orders': typeof AuthenticatedOrdersIndexRoute
'/products': typeof AuthenticatedProductsIndexRoute
@@ -68,20 +86,38 @@ export interface FileRoutesById {
'/_authenticated': typeof AuthenticatedRouteWithChildren
'/login': typeof LoginRoute
'/_authenticated/': typeof AuthenticatedIndexRoute
+ '/_authenticated/orders/$orderId': typeof AuthenticatedOrdersOrderIdRoute
+ '/_authenticated/orders/drafts': typeof AuthenticatedOrdersDraftsRoute
'/_authenticated/products/$productId': typeof AuthenticatedProductsProductIdRoute
'/_authenticated/orders/': typeof AuthenticatedOrdersIndexRoute
'/_authenticated/products/': typeof AuthenticatedProductsIndexRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
- fullPaths: '/' | '/login' | '/products/$productId' | '/orders/' | '/products/'
+ fullPaths:
+ | '/'
+ | '/login'
+ | '/orders/$orderId'
+ | '/orders/drafts'
+ | '/products/$productId'
+ | '/orders/'
+ | '/products/'
fileRoutesByTo: FileRoutesByTo
- to: '/login' | '/' | '/products/$productId' | '/orders' | '/products'
+ to:
+ | '/login'
+ | '/'
+ | '/orders/$orderId'
+ | '/orders/drafts'
+ | '/products/$productId'
+ | '/orders'
+ | '/products'
id:
| '__root__'
| '/_authenticated'
| '/login'
| '/_authenticated/'
+ | '/_authenticated/orders/$orderId'
+ | '/_authenticated/orders/drafts'
| '/_authenticated/products/$productId'
| '/_authenticated/orders/'
| '/_authenticated/products/'
@@ -136,11 +172,27 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthenticatedProductsProductIdRouteImport
parentRoute: typeof AuthenticatedRoute
}
+ '/_authenticated/orders/drafts': {
+ id: '/_authenticated/orders/drafts'
+ path: '/orders/drafts'
+ fullPath: '/orders/drafts'
+ preLoaderRoute: typeof AuthenticatedOrdersDraftsRouteImport
+ parentRoute: typeof AuthenticatedRoute
+ }
+ '/_authenticated/orders/$orderId': {
+ id: '/_authenticated/orders/$orderId'
+ path: '/orders/$orderId'
+ fullPath: '/orders/$orderId'
+ preLoaderRoute: typeof AuthenticatedOrdersOrderIdRouteImport
+ parentRoute: typeof AuthenticatedRoute
+ }
}
}
interface AuthenticatedRouteChildren {
AuthenticatedIndexRoute: typeof AuthenticatedIndexRoute
+ AuthenticatedOrdersOrderIdRoute: typeof AuthenticatedOrdersOrderIdRoute
+ AuthenticatedOrdersDraftsRoute: typeof AuthenticatedOrdersDraftsRoute
AuthenticatedProductsProductIdRoute: typeof AuthenticatedProductsProductIdRoute
AuthenticatedOrdersIndexRoute: typeof AuthenticatedOrdersIndexRoute
AuthenticatedProductsIndexRoute: typeof AuthenticatedProductsIndexRoute
@@ -148,6 +200,8 @@ interface AuthenticatedRouteChildren {
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
AuthenticatedIndexRoute: AuthenticatedIndexRoute,
+ AuthenticatedOrdersOrderIdRoute: AuthenticatedOrdersOrderIdRoute,
+ AuthenticatedOrdersDraftsRoute: AuthenticatedOrdersDraftsRoute,
AuthenticatedProductsProductIdRoute: AuthenticatedProductsProductIdRoute,
AuthenticatedOrdersIndexRoute: AuthenticatedOrdersIndexRoute,
AuthenticatedProductsIndexRoute: AuthenticatedProductsIndexRoute,
diff --git a/packages/admin/src/routes/_authenticated.tsx b/packages/admin/src/routes/_authenticated.tsx
index 922bd34ce1..92ba512043 100644
--- a/packages/admin/src/routes/_authenticated.tsx
+++ b/packages/admin/src/routes/_authenticated.tsx
@@ -1,17 +1,13 @@
import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'
import { AppSidebar } from '@/components/app-sidebar'
-import {
- SidebarInset,
- SidebarProvider,
- SidebarTrigger,
-} from '@/components/ui/sidebar'
-import { Separator } from '@/components/ui/separator'
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbList,
BreadcrumbPage,
} from '@/components/ui/breadcrumb'
+import { Separator } from '@/components/ui/separator'
+import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar'
export const Route = createFileRoute('/_authenticated')({
beforeLoad: ({ context }) => {
diff --git a/packages/admin/src/routes/_authenticated/index.tsx b/packages/admin/src/routes/_authenticated/index.tsx
index f799bff514..0d97ceef84 100644
--- a/packages/admin/src/routes/_authenticated/index.tsx
+++ b/packages/admin/src/routes/_authenticated/index.tsx
@@ -8,9 +8,7 @@ function DashboardPage() {
return (
<div className="space-y-4">
<h1 className="text-2xl font-bold">Dashboard</h1>
- <p className="text-muted-foreground">
- Welcome to the Spree Admin dashboard.
- </p>
+ <p className="text-muted-foreground">Welcome to the Spree Admin dashboard.</p>
</div>
)
}
diff --git a/packages/admin/src/routes/_authenticated/orders/$orderId.tsx b/packages/admin/src/routes/_authenticated/orders/$orderId.tsx
new file mode 100644
index 0000000000..8b07bf1c7f
--- /dev/null
+++ b/packages/admin/src/routes/_authenticated/orders/$orderId.tsx
@@ -0,0 +1,16 @@
+import { createFileRoute } from '@tanstack/react-router'
+
+export const Route = createFileRoute('/_authenticated/orders/$orderId')({
+ component: OrderDetailPage,
+})
+
+function OrderDetailPage() {
+ const { orderId } = Route.useParams()
+
+ return (
+ <div className="space-y-4">
+ <h1 className="text-2xl font-medium">Order {orderId}</h1>
+ <p className="text-muted-foreground">Order detail page will be implemented here.</p>
+ </div>
+ )
+}
diff --git a/packages/admin/src/routes/_authenticated/orders/drafts.tsx b/packages/admin/src/routes/_authenticated/orders/drafts.tsx
new file mode 100644
index 0000000000..40d54aae43
--- /dev/null
+++ b/packages/admin/src/routes/_authenticated/orders/drafts.tsx
@@ -0,0 +1,34 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { PlusIcon } from 'lucide-react'
+import { spreeClient } from '@/client'
+import { ResourceTable, resourceSearchSchema } from '@/components/resource-table'
+import { Button } from '@/components/ui/button'
+import { useAuth } from '@/hooks/use-auth'
+import '@/tables/orders'
+
+export const Route = createFileRoute('/_authenticated/orders/drafts')({
+ validateSearch: resourceSearchSchema,
+ component: DraftOrdersPage,
+})
+
+function DraftOrdersPage() {
+ const searchParams = Route.useSearch()
+ const { token } = useAuth()
+
+ return (
+ <ResourceTable
+ tableKey="orders"
+ queryKey="draft-orders"
+ queryFn={(params) => spreeClient.admin.orders.list(params, { token: token! })}
+ searchParams={searchParams}
+ defaultParams={{ incomplete: 1 }}
+ title="Draft Orders"
+ actions={
+ <Button size="sm" className="h-[2.125rem]">
+ <PlusIcon className="size-4" />
+ New Order
+ </Button>
+ }
+ />
+ )
+}
diff --git a/packages/admin/src/routes/_authenticated/orders/index.tsx b/packages/admin/src/routes/_authenticated/orders/index.tsx
index bff147ce12..aee450aa63 100644
--- a/packages/admin/src/routes/_authenticated/orders/index.tsx
+++ b/packages/admin/src/routes/_authenticated/orders/index.tsx
@@ -1,18 +1,33 @@
import { createFileRoute } from '@tanstack/react-router'
+import { PlusIcon } from 'lucide-react'
+import { spreeClient } from '@/client'
+import { ResourceTable, resourceSearchSchema } from '@/components/resource-table'
+import { Button } from '@/components/ui/button'
+import { useAuth } from '@/hooks/use-auth'
+import '@/tables/orders'
export const Route = createFileRoute('/_authenticated/orders/')({
+ validateSearch: resourceSearchSchema,
component: OrdersPage,
})
function OrdersPage() {
+ const searchParams = Route.useSearch()
+ const { token } = useAuth()
+
return (
- <div className="space-y-4">
- <div className="flex items-center justify-between">
- <h1 className="text-2xl font-bold">Orders</h1>
- </div>
- <p className="text-muted-foreground">
- Order listing will be implemented here.
- </p>
- </div>
+ <ResourceTable
+ tableKey="orders"
+ queryKey="orders"
+ queryFn={(params) => spreeClient.admin.orders.list(params, { token: token! })}
+ searchParams={searchParams}
+ defaultParams={{ complete: 1 }}
+ actions={
+ <Button size="sm" className="h-[2.125rem]">
+ <PlusIcon className="size-4" />
+ New Order
+ </Button>
+ }
+ />
)
}
diff --git a/packages/admin/src/routes/_authenticated/products/index.tsx b/packages/admin/src/routes/_authenticated/products/index.tsx
index 26a0bf9f61..80d6416a25 100644
--- a/packages/admin/src/routes/_authenticated/products/index.tsx
+++ b/packages/admin/src/routes/_authenticated/products/index.tsx
@@ -1,9 +1,9 @@
import { createFileRoute } from '@tanstack/react-router'
-import { Button } from '@/components/ui/button'
-import { ResourceTable, resourceSearchSchema } from '@/components/resource-table'
+import { PlusIcon } from 'lucide-react'
import { spreeClient } from '@/client'
+import { ResourceTable, resourceSearchSchema } from '@/components/resource-table'
+import { Button } from '@/components/ui/button'
import { useAuth } from '@/hooks/use-auth'
-import { PlusIcon } from 'lucide-react'
import '@/tables/products'
export const Route = createFileRoute('/_authenticated/products/')({
@@ -19,9 +19,7 @@ function ProductsPage() {
<ResourceTable
tableKey="products"
queryKey="products"
- queryFn={(params) =>
- spreeClient.admin.products.list(params, { token: token! })
- }
+ queryFn={(params) => spreeClient.admin.products.list(params, { token: token! })}
searchParams={searchParams}
actions={
<Button size="sm" className="h-[2.125rem]">
diff --git a/packages/admin/src/routes/login.tsx b/packages/admin/src/routes/login.tsx
index ffdbf41d32..bd445fee0a 100644
--- a/packages/admin/src/routes/login.tsx
+++ b/packages/admin/src/routes/login.tsx
@@ -1,13 +1,13 @@
+import { zodResolver } from '@hookform/resolvers/zod'
import { createFileRoute, redirect, useRouter } from '@tanstack/react-router'
-import { useAuth } from '@/hooks/use-auth'
import { useForm } from 'react-hook-form'
import { z } from 'zod/v4'
-import { zodResolver } from '@hookform/resolvers/zod'
-import { cn } from '@/lib/utils'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
+import { useAuth } from '@/hooks/use-auth'
+import { cn } from '@/lib/utils'
const loginSchema = z.object({
email: z.email(),
@@ -75,9 +75,7 @@ function LoginFormCard({
<Card>
<CardHeader className="text-center">
<CardTitle className="text-xl">Welcome back</CardTitle>
- <CardDescription>
- Sign in to your admin account
- </CardDescription>
+ <CardDescription>Sign in to your admin account</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={form.handleSubmit(onSubmit)}>
@@ -104,11 +102,7 @@ function LoginFormCard({
</div>
<div className="grid gap-2">
<Label htmlFor="password">Password</Label>
- <Input
- id="password"
- type="password"
- {...form.register('password')}
- />
+ <Input id="password" type="password" {...form.register('password')} />
{form.formState.errors.password && (
<p className="text-sm text-destructive">
{form.formState.errors.password.message}
@@ -125,7 +119,12 @@ function LoginFormCard({
</Card>
<div className="text-balance text-center text-xs text-muted-foreground">
Powered by{' '}
- <a href="https://spreecommerce.org" className="underline underline-offset-4 hover:text-primary" target="_blank" rel="noreferrer">
+ <a
+ href="https://spreecommerce.org"
+ className="underline underline-offset-4 hover:text-primary"
+ target="_blank"
+ rel="noreferrer"
+ >
Spree Commerce
</a>
</div>
@@ -145,6 +144,7 @@ function GalleryVerticalEnd(props: React.SVGProps<SVGSVGElement>) {
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
+ aria-hidden="true"
{...props}
>
<path d="M7 2h10" />
diff --git a/packages/admin/src/tables/orders.tsx b/packages/admin/src/tables/orders.tsx
new file mode 100644
index 0000000000..5cb0fa36f5
--- /dev/null
+++ b/packages/admin/src/tables/orders.tsx
@@ -0,0 +1,165 @@
+import { Link } from '@tanstack/react-router'
+import { ShoppingCartIcon } from 'lucide-react'
+import { StatusBadge } from '@/components/ui/badge'
+import { formatRelativeTime } from '@/lib/formatters'
+import { defineTable } from '@/lib/table-registry'
+
+defineTable('orders', {
+ title: 'Orders',
+ searchParam: 'multi_search',
+ searchPlaceholder: 'Search orders...',
+ defaultSort: { field: 'completed_at', direction: 'desc' },
+ emptyIcon: <ShoppingCartIcon className="size-8 text-muted-foreground/50" />,
+ emptyMessage: 'No orders found',
+ columns: [
+ {
+ key: 'number',
+ label: 'Number',
+ sortable: true,
+ filterable: true,
+ default: true,
+ render: (order) => (
+ <Link
+ to="/orders/$orderId"
+ params={{ orderId: order.id }}
+ className="font-medium text-zinc-950 no-underline"
+ >
+ #{order.number}
+ </Link>
+ ),
+ },
+ {
+ key: 'completed_at',
+ label: 'Date',
+ sortable: true,
+ default: true,
+ filterType: 'date',
+ className: 'text-sm text-muted-foreground whitespace-nowrap',
+ render: (order) => (order.completed_at ? formatRelativeTime(order.completed_at) : '—'),
+ },
+ {
+ key: 'email',
+ label: 'Customer',
+ sortable: true,
+ filterable: true,
+ default: true,
+ className: 'text-sm',
+ render: (order) => order.email ?? '—',
+ },
+ {
+ key: 'payment_state',
+ label: 'Payment',
+ sortable: true,
+ filterable: true,
+ default: true,
+ filterType: 'status',
+ filterOptions: [
+ { value: 'balance_due', label: 'Balance due' },
+ { value: 'credit_owed', label: 'Credit owed' },
+ { value: 'failed', label: 'Failed' },
+ { value: 'paid', label: 'Paid' },
+ { value: 'void', label: 'Void' },
+ ],
+ render: (order) => (order.payment_state ? <StatusBadge status={order.payment_state} /> : '—'),
+ },
+ {
+ key: 'shipment_state',
+ label: 'Shipment',
+ sortable: true,
+ filterable: true,
+ default: true,
+ filterType: 'status',
+ filterOptions: [
+ { value: 'backorder', label: 'Backorder' },
+ { value: 'canceled', label: 'Canceled' },
+ { value: 'partial', label: 'Partial' },
+ { value: 'pending', label: 'Pending' },
+ { value: 'ready', label: 'Ready' },
+ { value: 'shipped', label: 'Shipped' },
+ ],
+ render: (order) =>
+ order.shipment_state ? <StatusBadge status={order.shipment_state} /> : '—',
+ },
+ {
+ key: 'item_count',
+ label: 'Items',
+ sortable: true,
+ default: true,
+ className: 'text-right tabular-nums text-sm text-muted-foreground',
+ render: (order) => {
+ const count = order.item_count ?? 0
+ return `${count} ${count === 1 ? 'item' : 'items'}`
+ },
+ },
+ {
+ key: 'total',
+ label: 'Total',
+ sortable: true,
+ filterable: true,
+ default: true,
+ filterType: 'number',
+ className: 'text-right tabular-nums whitespace-nowrap font-medium',
+ render: (order) => order.display_total ?? '—',
+ },
+ {
+ key: 'state',
+ label: 'State',
+ sortable: true,
+ filterable: true,
+ default: false,
+ filterType: 'status',
+ filterOptions: [
+ { value: 'cart', label: 'Cart' },
+ { value: 'address', label: 'Address' },
+ { value: 'delivery', label: 'Delivery' },
+ { value: 'payment', label: 'Payment' },
+ { value: 'confirm', label: 'Confirm' },
+ { value: 'complete', label: 'Complete' },
+ { value: 'canceled', label: 'Canceled' },
+ { value: 'returned', label: 'Returned' },
+ { value: 'resumed', label: 'Resumed' },
+ ],
+ render: (order) => <StatusBadge status={order.state} />,
+ },
+ {
+ key: 'created_at',
+ label: 'Created at',
+ sortable: true,
+ default: false,
+ filterType: 'date',
+ className: 'text-sm text-muted-foreground whitespace-nowrap',
+ render: (order) => formatRelativeTime(order.created_at),
+ },
+ {
+ key: 'updated_at',
+ label: 'Updated at',
+ sortable: true,
+ default: false,
+ filterType: 'date',
+ className: 'text-sm text-muted-foreground whitespace-nowrap',
+ render: (order) => formatRelativeTime(order.updated_at),
+ },
+ // Filter-only columns
+ {
+ key: 'first_name',
+ label: 'First name',
+ filterable: true,
+ displayable: false,
+ ransackAttribute: 'bill_address_firstname_i',
+ },
+ {
+ key: 'last_name',
+ label: 'Last name',
+ filterable: true,
+ displayable: false,
+ ransackAttribute: 'bill_address_lastname',
+ },
+ {
+ key: 'sku',
+ label: 'SKU',
+ filterable: true,
+ displayable: false,
+ ransackAttribute: 'line_items_variant_sku',
+ },
+ ],
+})
diff --git a/packages/admin/src/tables/products.tsx b/packages/admin/src/tables/products.tsx
index 22eb891988..959e141484 100644
--- a/packages/admin/src/tables/products.tsx
+++ b/packages/admin/src/tables/products.tsx
@@ -1,8 +1,8 @@
import { Link } from '@tanstack/react-router'
import { PackageIcon } from 'lucide-react'
import { StatusBadge } from '@/components/ui/badge'
-import { defineTable } from '@/lib/table-registry'
import { formatPrice, formatRelativeTime } from '@/lib/formatters'
+import { defineTable } from '@/lib/table-registry'
defineTable('products', {
title: 'Products',
@@ -36,9 +36,7 @@ defineTable('products', {
)}
</div>
<div className="min-w-0">
- <div className="truncate font-medium text-zinc-950">
- {product.name}
- </div>
+ <div className="truncate font-medium text-zinc-950">{product.name}</div>
</div>
</Link>
),
diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rb
index 7b3c117bb3..5a104cbca7 100644
--- a/spree/core/app/models/spree/order.rb
+++ b/spree/core/app/models/spree/order.rb
@@ -109,7 +109,7 @@ module Spree
completed_at email number state payment_state shipment_state
total item_total item_count considered_risky channel
]
- self.whitelisted_ransackable_scopes = %w[refunded partially_refunded search multi_search]
+ self.whitelisted_ransackable_scopes = %w[complete incomplete refunded partially_refunded multi_search]
attr_reader :coupon_code
attr_accessor :temporary_address