feat: enhance admin dashboard UX and functionality

Improve table view layout, dark theme, data protection, schema config, and documentation links. Add theme system, data protection, and professional polish.

#VERCEL_SKIP

Co-authored-by: Allan K. Koech <44490960+allankoechke@users.noreply.github.com>
This commit is contained in:
v0
2025-06-23 12:44:58 +00:00
parent 8d83b194d7
commit a07e558cbc
13 changed files with 551 additions and 347 deletions

View File

@@ -2,85 +2,50 @@
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;
body {
font-family: Arial, Helvetica, sans-serif;
}
@layer utilities {
.text-balance {
text-wrap: balance;
}
}
@layer base { @layer base {
:root { :root {
--background: 0 0% 100%; --background: 0 0% 100%;
--foreground: 0 0% 3.9%; --foreground: 222.2 84% 4.9%;
--card: 0 0% 100%; --card: 0 0% 100%;
--card-foreground: 0 0% 3.9%; --card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%; --popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%; --popover-foreground: 222.2 84% 4.9%;
--primary: 0 0% 9%; --primary: 221.2 83.2% 53.3%;
--primary-foreground: 0 0% 98%; --primary-foreground: 210 40% 98%;
--secondary: 0 0% 96.1%; --secondary: 210 40% 96%;
--secondary-foreground: 0 0% 9%; --secondary-foreground: 222.2 84% 4.9%;
--muted: 0 0% 96.1%; --muted: 210 40% 96%;
--muted-foreground: 0 0% 45.1%; --muted-foreground: 215.4 16.3% 46.9%;
--accent: 0 0% 96.1%; --accent: 210 40% 96%;
--accent-foreground: 0 0% 9%; --accent-foreground: 222.2 84% 4.9%;
--destructive: 0 84.2% 60.2%; --destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%; --destructive-foreground: 210 40% 98%;
--border: 0 0% 89.8%; --border: 214.3 31.8% 91.4%;
--input: 0 0% 89.8%; --input: 214.3 31.8% 91.4%;
--ring: 0 0% 3.9%; --ring: 221.2 83.2% 53.3%;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
--radius: 0.5rem; --radius: 0.5rem;
--sidebar-background: 0 0% 98%;
--sidebar-foreground: 240 5.3% 26.1%;
--sidebar-primary: 240 5.9% 10%;
--sidebar-primary-foreground: 0 0% 98%;
--sidebar-accent: 240 4.8% 95.9%;
--sidebar-accent-foreground: 240 5.9% 10%;
--sidebar-border: 220 13% 91%;
--sidebar-ring: 217.2 91.2% 59.8%;
} }
.dark { .dark {
--background: 0 0% 3.9%; --background: 222.2 84% 4.9%;
--foreground: 0 0% 98%; --foreground: 210 40% 98%;
--card: 0 0% 3.9%; --card: 222.2 84% 4.9%;
--card-foreground: 0 0% 98%; --card-foreground: 210 40% 98%;
--popover: 0 0% 3.9%; --popover: 222.2 84% 4.9%;
--popover-foreground: 0 0% 98%; --popover-foreground: 210 40% 98%;
--primary: 0 0% 98%; --primary: 217.2 91.2% 59.8%;
--primary-foreground: 0 0% 9%; --primary-foreground: 222.2 84% 4.9%;
--secondary: 0 0% 14.9%; --secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 0 0% 98%; --secondary-foreground: 210 40% 98%;
--muted: 0 0% 14.9%; --muted: 217.2 32.6% 17.5%;
--muted-foreground: 0 0% 63.9%; --muted-foreground: 215 20.2% 65.1%;
--accent: 0 0% 14.9%; --accent: 217.2 32.6% 17.5%;
--accent-foreground: 0 0% 98%; --accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%; --destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%; --destructive-foreground: 210 40% 98%;
--border: 0 0% 14.9%; --border: 217.2 32.6% 17.5%;
--input: 0 0% 14.9%; --input: 217.2 32.6% 17.5%;
--ring: 0 0% 83.1%; --ring: 224.3 76.3% 94.1%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
--sidebar-background: 240 5.9% 10%;
--sidebar-foreground: 240 4.8% 95.9%;
--sidebar-primary: 224.3 76.3% 48%;
--sidebar-primary-foreground: 0 0% 100%;
--sidebar-accent: 240 3.7% 15.9%;
--sidebar-accent-foreground: 240 4.8% 95.9%;
--sidebar-border: 240 3.7% 15.9%;
--sidebar-ring: 217.2 91.2% 59.8%;
} }
} }

View File

@@ -4,6 +4,7 @@ import * as React from "react"
import { LoginForm } from "@/components/login-form" import { LoginForm } from "@/components/login-form"
import { AdminDashboard } from "@/components/admin-dashboard" import { AdminDashboard } from "@/components/admin-dashboard"
import { Toaster } from "@/components/ui/toaster" import { Toaster } from "@/components/ui/toaster"
import { ThemeProvider } from "@/components/theme-provider"
export default function Page() { export default function Page() {
const [token, setToken] = React.useState<string | null>(null) const [token, setToken] = React.useState<string | null>(null)
@@ -37,9 +38,9 @@ export default function Page() {
} }
return ( return (
<> <ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
{!token ? <LoginForm onLogin={handleLogin} /> : <AdminDashboard token={token} onLogout={handleLogout} />} {!token ? <LoginForm onLogin={handleLogin} /> : <AdminDashboard token={token} onLogout={handleLogout} />}
<Toaster /> <Toaster />
</> </ThemeProvider>
) )
} }

View File

@@ -1,7 +1,7 @@
"use client" "use client"
import * as React from "react" import * as React from "react"
import { Table, Settings, Shield, LogOut, FileText, RefreshCw } from "lucide-react" import { Table, Settings, Shield, LogOut, FileText, RefreshCw, ExternalLink } from "lucide-react"
import { import {
Sidebar, Sidebar,
SidebarContent, SidebarContent,
@@ -22,6 +22,7 @@ import { SettingsSection } from "./settings/settings-section"
import { LogsSection } from "./logs/logs-section" import { LogsSection } from "./logs/logs-section"
import { SyncSection } from "./sync/sync-section" import { SyncSection } from "./sync/sync-section"
import { useToast } from "@/hooks/use-toast" import { useToast } from "@/hooks/use-toast"
import { ThemeToggle } from "./theme-toggle"
interface AdminDashboardProps { interface AdminDashboardProps {
token: string token: string
@@ -144,6 +145,17 @@ export function AdminDashboard({ token, onLogout }: AdminDashboardProps) {
</SidebarContent> </SidebarContent>
<SidebarFooter> <SidebarFooter>
<SidebarMenu> <SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton asChild>
<a href="https://docs.example.com" target="_blank" rel="noopener noreferrer">
<ExternalLink className="h-4 w-4" />
<span>Documentation</span>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
<SidebarMenuItem>
<ThemeToggle />
</SidebarMenuItem>
<SidebarMenuItem> <SidebarMenuItem>
<SidebarMenuButton onClick={handleLogout}> <SidebarMenuButton onClick={handleLogout}>
<LogOut className="h-4 w-4" /> <LogOut className="h-4 w-4" />

View File

@@ -1,5 +1,5 @@
"use client" "use client"
import { Eye, EyeOff, Settings } from "lucide-react" import { Eye, EyeOff } from "lucide-react"
import { Button } from "@/components/ui/button" import { Button } from "@/components/ui/button"
import { import {
@@ -40,7 +40,7 @@ export function ColumnVisibilityDropdown({ table, visibleColumns, onVisibilityCh
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="outline" size="sm"> <Button variant="outline" size="sm">
<Settings className="h-4 w-4 mr-2" /> <Eye className="h-4 w-4 mr-2" />
Columns Columns
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>

View File

@@ -29,10 +29,12 @@ interface EditItemDrawerProps {
export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUpdate }: EditItemDrawerProps) { export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUpdate }: EditItemDrawerProps) {
const [formData, setFormData] = React.useState<any>({}) const [formData, setFormData] = React.useState<any>({})
const [isLoading, setIsLoading] = React.useState(false) const [isLoading, setIsLoading] = React.useState(false)
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)
React.useEffect(() => { React.useEffect(() => {
if (open && item) { if (open && item) {
setFormData({ ...item }) setFormData({ ...item })
setHasUnsavedChanges(false)
} }
}, [open, item]) }, [open, item])
@@ -57,14 +59,26 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
...prev, ...prev,
[fieldName]: value, [fieldName]: value,
})) }))
setHasUnsavedChanges(true)
} }
const isSystemField = (fieldName: string) => { const isSystemField = (fieldName: string) => {
return ["id", "created", "updated"].includes(fieldName) return ["id", "created", "updated"].includes(fieldName)
} }
const handleClose = () => {
if (hasUnsavedChanges) {
if (confirm("You have unsaved changes. Are you sure you want to close?")) {
setHasUnsavedChanges(false)
onClose()
}
} else {
onClose()
}
}
return ( return (
<Drawer open={open} onOpenChange={onClose}> <Drawer open={open} onOpenChange={handleClose}>
<DrawerContent side="right" className="w-[700px] max-w-[95vw]"> <DrawerContent side="right" className="w-[700px] max-w-[95vw]">
<DrawerHeader> <DrawerHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
@@ -72,7 +86,7 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
<Edit className="h-5 w-5" /> <Edit className="h-5 w-5" />
<DrawerTitle>Edit Record</DrawerTitle> <DrawerTitle>Edit Record</DrawerTitle>
</div> </div>
<Button variant="ghost" size="sm" onClick={onClose}> <Button variant="ghost" size="sm" onClick={handleClose}>
<X className="h-4 w-4" /> <X className="h-4 w-4" />
</Button> </Button>
</div> </div>
@@ -110,7 +124,7 @@ export function EditItemDrawer({ table, item, apiClient, open, onClose, onItemUp
<DrawerFooter> <DrawerFooter>
<div className="flex gap-3"> <div className="flex gap-3">
<Button variant="outline" onClick={onClose} className="flex-1"> <Button variant="outline" onClick={handleClose} className="flex-1">
Cancel Cancel
</Button> </Button>
<Button onClick={handleSubmit} disabled={isLoading} className="flex-1"> <Button onClick={handleSubmit} disabled={isLoading} className="flex-1">

View File

@@ -35,11 +35,15 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
const [rules, setRules] = React.useState(table.rules) const [rules, setRules] = React.useState(table.rules)
const [isLoading, setIsLoading] = React.useState(false) const [isLoading, setIsLoading] = React.useState(false)
const [activeTab, setActiveTab] = React.useState("schema") const [activeTab, setActiveTab] = React.useState("schema")
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)
const [systemFieldsCollapsed, setSystemFieldsCollapsed] = React.useState(true)
React.useEffect(() => { React.useEffect(() => {
if (open) { if (open) {
setColumns(table.fields || []) setColumns(table.fields || [])
setRules(table.rules) setRules(table.rules)
setHasUnsavedChanges(false)
setSystemFieldsCollapsed(true)
} }
}, [open, table]) }, [open, table])
@@ -64,6 +68,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
const addColumn = () => { const addColumn = () => {
setColumns([...columns, { name: "", type: "string", primaryKey: false, nullable: true }]) setColumns([...columns, { name: "", type: "string", primaryKey: false, nullable: true }])
setHasUnsavedChanges(true)
} }
const removeColumn = (index: number) => { const removeColumn = (index: number) => {
@@ -77,6 +82,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
const updateColumn = (index: number, field: string, value: any) => { const updateColumn = (index: number, field: string, value: any) => {
const updatedColumns = columns.map((col, i) => (i === index ? { ...col, [field]: value } : col)) const updatedColumns = columns.map((col, i) => (i === index ? { ...col, [field]: value } : col))
setColumns(updatedColumns) setColumns(updatedColumns)
setHasUnsavedChanges(true)
} }
const handleSaveSchema = async () => { const handleSaveSchema = async () => {
@@ -113,8 +119,19 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
return ["id", "created", "updated", "email", "password"].includes(columnName) return ["id", "created", "updated", "email", "password"].includes(columnName)
} }
const handleClose = () => {
if (hasUnsavedChanges) {
if (confirm("You have unsaved changes. Are you sure you want to close?")) {
setHasUnsavedChanges(false)
onClose()
}
} else {
onClose()
}
}
return ( return (
<Drawer open={open} onOpenChange={onClose}> <Drawer open={open} onOpenChange={handleClose}>
<DrawerContent side="right" className="w-[900px] max-w-[95vw]"> <DrawerContent side="right" className="w-[900px] max-w-[95vw]">
<DrawerHeader> <DrawerHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
@@ -162,167 +179,352 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
</ScrollArea> </ScrollArea>
</div> </div>
) : ( ) : (
<div className="space-y-4"> <>
{columns.map((column, index) => { {/* System Fields - Collapsible */}
const isSystem = isSystemColumn(column.name) {columns.filter((col) => isSystemColumn(col.name)).length > 0 && (
return ( <Collapsible
<div key={index} className={`border rounded-lg ${isSystem ? "bg-muted/50" : ""}`}> open={!systemFieldsCollapsed}
<div className="p-4 space-y-4"> onOpenChange={(open) => setSystemFieldsCollapsed(!open)}
{/* Basic Info */} >
<div className="grid grid-cols-1 md:grid-cols-3 gap-4"> <CollapsibleTrigger asChild>
<div className="md:col-span-2"> <Button variant="ghost" className="w-full justify-between p-2 mb-4">
<Label className="text-sm font-medium mb-2 block">Column Name</Label> <span className="text-sm font-medium">
<div className="flex items-center gap-2"> System Fields ({columns.filter((col) => isSystemColumn(col.name)).length})
<Input </span>
placeholder="Column name" <ChevronDown
value={column.name} className={`h-4 w-4 transition-transform ${systemFieldsCollapsed ? "" : "rotate-180"}`}
onChange={(e) => updateColumn(index, "name", e.target.value)} />
disabled={isSystem} </Button>
className={`flex-1 ${isSystem ? "bg-muted" : ""}`} </CollapsibleTrigger>
/> <CollapsibleContent className="space-y-4 mb-6">
{isSystem && ( {columns.map((column, index) => {
<Badge variant="outline" className="text-xs"> const isSystem = isSystemColumn(column.name)
System if (!isSystem) return null
</Badge> return (
)} <div key={index} className="border rounded-lg bg-muted/50">
<div className="p-4 space-y-4">
{/* Basic Info */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="md:col-span-2">
<Label className="text-sm font-medium mb-2 block">Column Name</Label>
<div className="flex items-center gap-2">
<Input
placeholder="Column name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem}
className={`flex-1 ${isSystem ? "bg-muted" : ""}`}
/>
{isSystem && (
<Badge variant="outline" className="text-xs">
System
</Badge>
)}
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Data Type</Label>
<Select
value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem}
>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{/* Basic Properties */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`primary-${index}`}
checked={column.primaryKey}
onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`primary-${index}`} className="text-sm">
Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={!column.nullable}
onChange={(e) => updateColumn(index, "nullable", !e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
{/* Advanced Options - Collapsible */}
<Collapsible>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between p-2">
<span className="text-sm">Advanced Options</span>
<ChevronDown className="h-4 w-4" />
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 pt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<Label className="text-sm font-medium mb-2 block">Default Value</Label>
<Input
placeholder="Default value"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Max Length</Label>
<Input
type="number"
placeholder="Max length"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Description</Label>
<Textarea
placeholder="Column description"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
</CollapsibleContent>
</Collapsible>
{/* Delete Button */}
<div className="flex justify-end pt-2 border-t">
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => removeColumn(index)}
disabled={columns.length === 1 || isSystem}
className={`text-destructive hover:text-destructive ${isSystem ? "opacity-30" : ""}`}
>
<Trash2 className="h-4 w-4 mr-2" />
Remove Column
</Button>
</div>
</div> </div>
</div> </div>
<div> )
<Label className="text-sm font-medium mb-2 block">Data Type</Label> })}
<Select </CollapsibleContent>
value={column.type} </Collapsible>
onValueChange={(value) => updateColumn(index, "type", value)} )}
disabled={isSystem}
>
<SelectTrigger className={isSystem ? "bg-muted" : ""}>
<SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{/* Basic Properties */} {/* Regular Fields */}
<div className="grid grid-cols-2 md:grid-cols-4 gap-4"> <div className="space-y-4">
<div className="flex items-center space-x-2"> {columns.map((column, index) => {
<input const isSystem = isSystemColumn(column.name)
type="checkbox" if (isSystem) return null // Skip system fields as they're in collapsible section
id={`primary-${index}`} return (
checked={column.primaryKey} <div key={index} className="border rounded-lg">
onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)} <div className="p-4 space-y-4">
disabled={isSystem} {/* Basic Info */}
className="rounded" <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
/> <div className="md:col-span-2">
<Label htmlFor={`primary-${index}`} className="text-sm"> <Label className="text-sm font-medium mb-2 block">Column Name</Label>
Primary Key <div className="flex items-center gap-2">
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={!column.nullable}
onChange={(e) => updateColumn(index, "nullable", !e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
{/* Advanced Options - Collapsible */}
<Collapsible>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between p-2">
<span className="text-sm">Advanced Options</span>
<ChevronDown className="h-4 w-4" />
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 pt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<Label className="text-sm font-medium mb-2 block">Default Value</Label>
<Input <Input
placeholder="Default value" placeholder="Column name"
value={column.name}
onChange={(e) => updateColumn(index, "name", e.target.value)}
disabled={isSystem} disabled={isSystem}
className={isSystem ? "bg-muted" : ""} className={`flex-1 ${isSystem ? "bg-muted" : ""}`}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Max Length</Label>
<Input
type="number"
placeholder="Max length"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/> />
{isSystem && (
<Badge variant="outline" className="text-xs">
System
</Badge>
)}
</div> </div>
</div> </div>
<div> <div>
<Label className="text-sm font-medium mb-2 block">Description</Label> <Label className="text-sm font-medium mb-2 block">Data Type</Label>
<Textarea <Select
placeholder="Column description" value={column.type}
onValueChange={(value) => updateColumn(index, "type", value)}
disabled={isSystem} disabled={isSystem}
className={isSystem ? "bg-muted" : ""} >
rows={2} <SelectTrigger className={isSystem ? "bg-muted" : ""}>
/> <SelectValue />
</SelectTrigger>
<SelectContent>
{dataTypes.map((type) => (
<SelectItem key={type} value={type}>
{type.toUpperCase()}
</SelectItem>
))}
</SelectContent>
</Select>
</div> </div>
</CollapsibleContent> </div>
</Collapsible>
{/* Delete Button */} {/* Basic Properties */}
<div className="flex justify-end pt-2 border-t"> <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<Button <div className="flex items-center space-x-2">
type="button" <input
variant="ghost" type="checkbox"
size="sm" id={`primary-${index}`}
onClick={() => removeColumn(index)} checked={column.primaryKey}
disabled={columns.length === 1 || isSystem} onChange={(e) => updateColumn(index, "primaryKey", e.target.checked)}
className={`text-destructive hover:text-destructive ${isSystem ? "opacity-30" : ""}`} disabled={isSystem}
> className="rounded"
<Trash2 className="h-4 w-4 mr-2" /> />
Remove Column <Label htmlFor={`primary-${index}`} className="text-sm">
</Button> Primary Key
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`required-${index}`}
checked={!column.nullable}
onChange={(e) => updateColumn(index, "nullable", !e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`required-${index}`} className="text-sm">
Required
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`unique-${index}`}
checked={column.unique || false}
onChange={(e) => updateColumn(index, "unique", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`unique-${index}`} className="text-sm">
Unique
</Label>
</div>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id={`files-${index}`}
checked={column.isFile || false}
onChange={(e) => updateColumn(index, "isFile", e.target.checked)}
disabled={isSystem}
className="rounded"
/>
<Label htmlFor={`files-${index}`} className="text-sm">
File Field
</Label>
</div>
</div>
{/* Advanced Options - Collapsible */}
<Collapsible>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="w-full justify-between p-2">
<span className="text-sm">Advanced Options</span>
<ChevronDown className="h-4 w-4" />
</Button>
</CollapsibleTrigger>
<CollapsibleContent className="space-y-4 pt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<Label className="text-sm font-medium mb-2 block">Default Value</Label>
<Input
placeholder="Default value"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Max Length</Label>
<Input
type="number"
placeholder="Max length"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
/>
</div>
</div>
<div>
<Label className="text-sm font-medium mb-2 block">Description</Label>
<Textarea
placeholder="Column description"
disabled={isSystem}
className={isSystem ? "bg-muted" : ""}
rows={2}
/>
</div>
</CollapsibleContent>
</Collapsible>
{/* Delete Button */}
<div className="flex justify-end pt-2 border-t">
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => removeColumn(index)}
disabled={columns.length === 1 || isSystem}
className={`text-destructive hover:text-destructive ${isSystem ? "opacity-30" : ""}`}
>
<Trash2 className="h-4 w-4 mr-2" />
Remove Column
</Button>
</div>
</div> </div>
</div> </div>
</div> )
) })}
})} </div>
</div> </>
)} )}
{table.type !== "view" && ( {table.type !== "view" && (
@@ -451,7 +653,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
<DrawerFooter> <DrawerFooter>
<div className="flex gap-3"> <div className="flex gap-3">
<Button variant="outline" onClick={onClose} className="flex-1"> <Button variant="outline" onClick={handleClose} className="flex-1">
Cancel Cancel
</Button> </Button>
<Button <Button

View File

@@ -161,31 +161,25 @@ export function TableDetailView({ table, onBack, apiClient, onTableUpdate }: Tab
<Card> <Card>
<CardHeader> <CardHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div className="flex items-center gap-4"> <div>
<div> <CardTitle>Table Data</CardTitle>
<CardTitle>Table Data</CardTitle> <CardDescription>Current records in the {table.name} table</CardDescription>
<CardDescription>Current records in the {table.name} table</CardDescription> </div>
</div> <div className="flex items-center gap-2">
{selectedItems.length > 0 && ( {selectedItems.length > 0 && (
<Button <Button variant="destructive" size="sm" onClick={handleDeleteSelected} disabled={isDeleting}>
variant="destructive"
size="sm"
onClick={handleDeleteSelected}
disabled={isDeleting}
className="ml-auto"
>
<Trash2 className="h-4 w-4 mr-2" /> <Trash2 className="h-4 w-4 mr-2" />
{isDeleting {isDeleting
? "Deleting..." ? "Deleting..."
: `Delete ${selectedItems.length} item${selectedItems.length > 1 ? "s" : ""}`} : `Delete ${selectedItems.length} item${selectedItems.length > 1 ? "s" : ""}`}
</Button> </Button>
)} )}
<ColumnVisibilityDropdown
table={table}
visibleColumns={visibleColumns}
onVisibilityChange={setVisibleColumns}
/>
</div> </div>
<ColumnVisibilityDropdown
table={table}
visibleColumns={visibleColumns}
onVisibilityChange={setVisibleColumns}
/>
</div> </div>
</CardHeader> </CardHeader>
<CardContent> <CardContent>

View File

@@ -17,8 +17,12 @@ interface TableDocsDrawerProps {
} }
export function TableDocsDrawer({ table, open, onClose }: TableDocsDrawerProps) { export function TableDocsDrawer({ table, open, onClose }: TableDocsDrawerProps) {
const handleClose = () => {
onClose()
}
return ( return (
<Drawer open={open} onOpenChange={onClose}> <Drawer open={open} onOpenChange={handleClose}>
<DrawerContent side="right" className="w-[1000px] max-w-[95vw]"> <DrawerContent side="right" className="w-[1000px] max-w-[95vw]">
<DrawerHeader> <DrawerHeader>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">

View File

@@ -1,10 +1,6 @@
'use client' "use client"
import { ThemeProvider as NextThemesProvider } from "next-themes"
import * as React from 'react' import type { ThemeProviderProps } from "next-themes"
import {
ThemeProvider as NextThemesProvider,
type ThemeProviderProps,
} from 'next-themes'
export function ThemeProvider({ children, ...props }: ThemeProviderProps) { export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider> return <NextThemesProvider {...props}>{children}</NextThemesProvider>

View File

@@ -0,0 +1,31 @@
"use client"
import * as React from "react"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { SidebarMenuButton } from "@/components/ui/sidebar"
export function ThemeToggle() {
const { theme, setTheme } = useTheme()
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
if (!mounted) {
return (
<SidebarMenuButton>
<div className="h-4 w-4" />
<span>Theme</span>
</SidebarMenuButton>
)
}
return (
<SidebarMenuButton onClick={() => setTheme(theme === "dark" ? "light" : "dark")}>
{theme === "dark" ? <Sun className="h-4 w-4" /> : <Moon className="h-4 w-4" />}
<span>{theme === "dark" ? "Light Mode" : "Dark Mode"}</span>
</SidebarMenuButton>
)
}

View File

@@ -46,7 +46,7 @@
"input-otp": "1.4.1", "input-otp": "1.4.1",
"lucide-react": "^0.454.0", "lucide-react": "^0.454.0",
"next": "15.2.4", "next": "15.2.4",
"next-themes": "^0.4.4", "next-themes": "latest",
"react": "^19", "react": "^19",
"react-day-picker": "8.10.1", "react-day-picker": "8.10.1",
"react-dom": "^19", "react-dom": "^19",

10
pnpm-lock.yaml generated
View File

@@ -120,8 +120,8 @@ importers:
specifier: 15.2.4 specifier: 15.2.4
version: 15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0) version: 15.2.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
next-themes: next-themes:
specifier: ^0.4.4 specifier: latest
version: 0.4.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0) version: 0.4.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
react: react:
specifier: ^19 specifier: ^19
version: 19.0.0 version: 19.0.0
@@ -1604,8 +1604,8 @@ packages:
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true hasBin: true
next-themes@0.4.4: next-themes@0.4.6:
resolution: {integrity: sha512-LDQ2qIOJF0VnuVrrMSMLrWGjRMkq+0mpgl6e0juCLqdJ+oo8Q84JRWT6Wh11VDQKkMMe+dVzDKLWs5n87T+PkQ==} resolution: {integrity: sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==}
peerDependencies: peerDependencies:
react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
@@ -3369,7 +3369,7 @@ snapshots:
nanoid@3.3.11: {} nanoid@3.3.11: {}
next-themes@0.4.4(react-dom@19.0.0(react@19.0.0))(react@19.0.0): next-themes@0.4.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
dependencies: dependencies:
react: 19.0.0 react: 19.0.0
react-dom: 19.0.0(react@19.0.0) react-dom: 19.0.0(react@19.0.0)

View File

@@ -1,96 +1,81 @@
import type { Config } from "tailwindcss"; import type { Config } from "tailwindcss"
const config: Config = { const config: Config = {
darkMode: ["class"], darkMode: ["class"],
content: [ content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}", "./pages/**/*.{ts,tsx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}", "./components/**/*.{ts,tsx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}", "./app/**/*.{ts,tsx}",
"*.{js,ts,jsx,tsx,mdx}" "./src/**/*.{ts,tsx}",
"*.{js,ts,jsx,tsx,mdx}",
], ],
prefix: "",
theme: { theme: {
extend: { container: {
colors: { center: true,
background: 'hsl(var(--background))', padding: "2rem",
foreground: 'hsl(var(--foreground))', screens: {
card: { "2xl": "1400px",
DEFAULT: 'hsl(var(--card))', },
foreground: 'hsl(var(--card-foreground))' },
}, extend: {
popover: { colors: {
DEFAULT: 'hsl(var(--popover))', border: "hsl(var(--border))",
foreground: 'hsl(var(--popover-foreground))' input: "hsl(var(--input))",
}, ring: "hsl(var(--ring))",
primary: { background: "hsl(var(--background))",
DEFAULT: 'hsl(var(--primary))', foreground: "hsl(var(--foreground))",
foreground: 'hsl(var(--primary-foreground))' primary: {
}, DEFAULT: "hsl(var(--primary))",
secondary: { foreground: "hsl(var(--primary-foreground))",
DEFAULT: 'hsl(var(--secondary))', },
foreground: 'hsl(var(--secondary-foreground))' secondary: {
}, DEFAULT: "hsl(var(--secondary))",
muted: { foreground: "hsl(var(--secondary-foreground))",
DEFAULT: 'hsl(var(--muted))', },
foreground: 'hsl(var(--muted-foreground))' destructive: {
}, DEFAULT: "hsl(var(--destructive))",
accent: { foreground: "hsl(var(--destructive-foreground))",
DEFAULT: 'hsl(var(--accent))', },
foreground: 'hsl(var(--accent-foreground))' muted: {
}, DEFAULT: "hsl(var(--muted))",
destructive: { foreground: "hsl(var(--muted-foreground))",
DEFAULT: 'hsl(var(--destructive))', },
foreground: 'hsl(var(--destructive-foreground))' accent: {
}, DEFAULT: "hsl(var(--accent))",
border: 'hsl(var(--border))', foreground: "hsl(var(--accent-foreground))",
input: 'hsl(var(--input))', },
ring: 'hsl(var(--ring))', popover: {
chart: { DEFAULT: "hsl(var(--popover))",
'1': 'hsl(var(--chart-1))', foreground: "hsl(var(--popover-foreground))",
'2': 'hsl(var(--chart-2))', },
'3': 'hsl(var(--chart-3))', card: {
'4': 'hsl(var(--chart-4))', DEFAULT: "hsl(var(--card))",
'5': 'hsl(var(--chart-5))' foreground: "hsl(var(--card-foreground))",
}, },
sidebar: { },
DEFAULT: 'hsl(var(--sidebar-background))', borderRadius: {
foreground: 'hsl(var(--sidebar-foreground))', lg: "var(--radius)",
primary: 'hsl(var(--sidebar-primary))', md: "calc(var(--radius) - 2px)",
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))', sm: "calc(var(--radius) - 4px)",
accent: 'hsl(var(--sidebar-accent))', },
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))', keyframes: {
border: 'hsl(var(--sidebar-border))', "accordion-down": {
ring: 'hsl(var(--sidebar-ring))' from: { height: "0" },
} to: { height: "var(--radix-accordion-content-height)" },
}, },
borderRadius: { "accordion-up": {
lg: 'var(--radius)', from: { height: "var(--radix-accordion-content-height)" },
md: 'calc(var(--radius) - 2px)', to: { height: "0" },
sm: 'calc(var(--radius) - 4px)' },
}, },
keyframes: { animation: {
'accordion-down': { "accordion-down": "accordion-down 0.2s ease-out",
from: { "accordion-up": "accordion-up 0.2s ease-out",
height: '0' },
}, },
to: {
height: 'var(--radix-accordion-content-height)'
}
},
'accordion-up': {
from: {
height: 'var(--radix-accordion-content-height)'
},
to: {
height: '0'
}
}
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out'
}
}
}, },
plugins: [require("tailwindcss-animate")], plugins: [require("tailwindcss-animate")],
}; } satisfies Config
export default config;
export default config