Files
supabase/apps/studio/components/interfaces/HomeNew/TableQuickstart/TablePicker.tsx
Sean Oliver ec4bc204b1 feat: Add TableQuickstart experiment for onboarding flow
Implements a growth engineering experiment to improve new user onboarding
by providing AI-powered and template-based table creation options.

Features:
- AI prompt interface for describing app requirements
- Pre-built templates for common app types (social media, e-commerce, blog, etc.)
- Seamless integration with existing table editor
- State management using Valtio for reliable data flow
- PostHog feature flag controlled (tableQuickstart)

Technical implementation:
- Uses Valtio proxy-based state management instead of sessionStorage
- Properly handles quickstart flow to prevent race conditions
- Integrates with TableEditor via useQuickstartData hook
- Cleans up state appropriately to prevent panel re-opening issues
- Full TypeScript support with proper type definitions

The experiment aims to reduce time-to-value for new users by providing
smart defaults and reducing the SQL knowledge barrier for initial setup.
2025-09-17 16:01:40 -07:00

38 lines
1.1 KiB
TypeScript

import { useState } from 'react'
import { TablePreviewCard } from './TablePreviewCard'
import type { TableSuggestion } from './types'
interface TablePickerProps {
tables: readonly TableSuggestion[]
onSelectTable: (table: TableSuggestion) => void
loading?: boolean
}
export const TablePicker = ({ tables, onSelectTable, loading }: TablePickerProps) => {
const [selectedIndex, setSelectedIndex] = useState<number | null>(null)
const handleSelectTable = (index: number) => {
setSelectedIndex(index)
onSelectTable(tables[index])
}
if (tables.length === 0) return null
return (
<div className="space-y-6">
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 items-stretch">
{tables.map((table, index) => (
<div key={table.tableName} className="relative h-full">
<TablePreviewCard
table={table}
isActive={selectedIndex === index}
onClick={() => handleSelectTable(index)}
disabled={loading}
/>
</div>
))}
</div>
</div>
)
}