import { IS_PLATFORM, useParams } from 'common' import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider' import { BASE_PATH } from 'lib/constants' import { useTrack } from 'lib/telemetry/track' import { Code, Table2 } from 'lucide-react' import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useAiAssistantStateSnapshot } from 'state/ai-assistant-state' import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state' import { Button, Card, CardContent, ToggleGroup, ToggleGroupItem } from 'ui' import { GettingStarted } from './GettingStarted' import { GettingStartedAction, GettingStartedState, GettingStartedStep, } from './GettingStarted.types' import { getCodeWorkflowSteps, getNoCodeWorkflowSteps } from './GettingStarted.utils' import { useGettingStartedProgress } from './useGettingStartedProgress' import { ConnectButton } from '@/components/interfaces/ConnectButton/ConnectButton' interface GettingStartedSectionProps { value: GettingStartedState onChange: (v: GettingStartedState) => void } export function GettingStartedSection({ value, onChange }: GettingStartedSectionProps) { const { ref } = useParams() const track = useTrack() const aiSnap = useAiAssistantStateSnapshot() const { openSidebar } = useSidebarManagerSnapshot() const workflow: 'no-code' | 'code' | null = value === 'code' || value === 'no-code' ? value : null const [previousWorkflow, setPreviousWorkflow] = useState<'no-code' | 'code' | null>(null) const statuses = useGettingStartedProgress() const openAiChat = useCallback( (name: string, initialInput: string) => { openSidebar(SIDEBAR_KEYS.AI_ASSISTANT) aiSnap.newChat({ name, initialInput }) }, [aiSnap, openSidebar] ) const connectActions: GettingStartedAction[] = useMemo(() => { return [ { label: 'Connect', component: , }, ] }, []) const codeSteps: GettingStartedStep[] = useMemo( () => getCodeWorkflowSteps({ ref, openAiChat, connectActions, statuses, }), [connectActions, openAiChat, ref, statuses] ) const noCodeSteps: GettingStartedStep[] = useMemo( () => getNoCodeWorkflowSteps({ ref, openAiChat, connectActions, statuses, }), [connectActions, openAiChat, ref, statuses] ) const steps = workflow === 'code' ? codeSteps : workflow === 'no-code' ? noCodeSteps : [] const hasTrackedExposure = useRef(false) useEffect(() => { if (!IS_PLATFORM) return if (hasTrackedExposure.current) return hasTrackedExposure.current = true track('home_getting_started_section_exposed', { workflow: workflow === 'no-code' ? 'no_code' : workflow === 'code' ? 'code' : null, }) }, [workflow, track]) return (

Getting started

{ if (v) { const newWorkflow = v as 'no-code' | 'code' setPreviousWorkflow(workflow) onChange(newWorkflow) track('home_getting_started_workflow_clicked', { workflow: newWorkflow === 'no-code' ? 'no_code' : 'code', is_switch: previousWorkflow !== null, }) } }} > No-code Code
{steps.length === 0 ? (
Supabase Grafana Supabase Grafana

Choose a preferred workflow

With Supabase, you have the flexibility to adopt a workflow that works for you. You can do everything via the dashboard, or manage your entire project within your own codebase.

) : ( { if (workflow) { track('home_getting_started_step_clicked', { workflow: workflow === 'no-code' ? 'no_code' : 'code', step_number: stepIndex + 1, step_title: stepTitle, action_type: actionType, was_completed: wasCompleted, }) } }} /> )}
) }