Build responsive React dashboards with TypeScript, shadcn/ui, TanStack Query, and Supabase for event-studio...
Expert in building React dashboards for the event-studio project.
Tech Stack: React 18 + TypeScript + Vite + shadcn/ui + TanStack Query + Supabase
Structure:
src/
āāā pages/Dashboard*.tsx # Route components
āāā features/[feature]/hooks/ # Custom hooks (useEvents, etc.)
āāā components/ui/ # shadcn/ui components
āāā integrations/supabase/ # Supabase client & types
Key Patterns:
supabase client from @/integrations/supabase/client)@/components/ui/)Copy this checklist and track your progress:
Dashboard Implementation:
- [ ] 1. Identify data requirements (tables, metrics)
- [ ] 2. Create custom hook in features/[feature]/hooks/
- [ ] 3. Build page in src/pages/Dashboard*.tsx
- [ ] 4. Add metric cards and main content
- [ ] 5. Add route in App.tsx
- [ ] 6. Test loading/error states
Ask user to clarify:
Pattern: Create in src/features/[feature]/hooks/use*.ts
import { useQuery } from '@tanstack/react-query';
import { supabase } from '@/integrations/supabase/client';
export function useDashboardMetrics() {
return useQuery({
queryKey: ['dashboard-metrics'],
queryFn: async () => {
const { data, error } = await supabase
.from('events')
.select('*, bookings(count)');
if (error) throw error;
return data;
},
});
}
For more patterns: See resources/query-patterns.ts
Template:
import Sidebar from '@/components/Sidebar';
import { Card } from '@/components/ui/card';
const DashboardNew = () => {
const { data, isLoading, error } = useYourHook();
if (isLoading) return <PageLoader />;
if (error) return <ErrorAlert error={error} />;
return (
<div className="flex min-h-screen bg-gray-50">
<Sidebar />
<main className="flex-1 p-8">
<h1 className="text-3xl font-bold mb-6">Dashboard Title</h1>
{/* Metrics Grid */}
<div className="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
{/* MetricCard components */}
</div>
{/* Main Content */}
<Card className="p-6">
{/* DataTable or Charts */}
</Card>
</main>
</div>
);
};
export default DashboardNew;
Import from resources:
import {
MetricCard,
DataTable,
StatusBadge,
EmptyState,
ErrorAlert
} from '../skills/frontend-dashboard/resources/component-patterns';
See complete examples: resources/component-patterns.tsx
// Simple query
const { data } = await supabase.from('events').select('*');
// With joins
const { data } = await supabase
.from('events')
.select('*, bookings(*), organizer:users(full_name)');
// With filters
const { data } = await supabase
.from('events')
.select('*')
.eq('status', 'active')
.gte('start_date', date);
More patterns: See resources/supabase-patterns.ts
// Metric Card
<MetricCard
title="Total Revenue"
value="$125,000"
change={12.5}
icon={<DollarSign />}
/>
// Data Table
<DataTable
data={events}
columns={[
{ key: 'title', label: 'Event' },
{ key: 'status', label: 'Status', render: (v) => <StatusBadge status={v} /> }
]}
onEdit={(row) => handleEdit(row)}
/>
// Empty State
<EmptyState
title="No events yet"
description="Get started by creating your first event"
action={{ label: "Create Event", onClick: () => navigate('/new') }}
/>
7 layout patterns in resources/layout-examples.tsx:
User: "Create a dashboard page showing all events with metrics"
Your Process:
src/features/events/hooks/useEventsDashboard.ts):export function useEventsDashboard() {
return useQuery({
queryKey: ['events-dashboard'],
queryFn: async () => {
const { data, error } = await supabase
.from('events')
.select('*, bookings(count, total_amount.sum())')
.order('created_at', { ascending: false });
if (error) throw error;
return data;
},
});
}
Create page (src/pages/DashboardEvents.tsx) with:
Add route in App.tsx:
<Route path="/dashboard/events" element={<DashboardEvents />} />
User: "Add a revenue analytics page with charts"
Your Response:
useRevenueAnalytics hook fetching bookings with date groupingrecharts packageUser: "Create a bookings dashboard with search and filters"
Your Implementation:
Always:
md:, lg: prefixes)any)Performance:
queryKey)React.memo if neededUX:
sonner)Complete examples and patterns:
resources/component-patterns.tsx - Reusable components (MetricCard, DataTable, etc.)resources/query-patterns.ts - TanStack Query hooks and patternsresources/supabase-patterns.ts - Supabase query examplesresources/layout-examples.tsx - 7 dashboard layout templatesQuery not refetching: Use invalidateQueries in mutation onSuccess
RLS blocking queries: Check Supabase RLS policies allow the operation
TypeScript errors: Regenerate types with npx supabase gen types typescript
Not responsive: Use Tailwind responsive prefixes, test in dev tools