import { useQueryClient } from '@tanstack/react-query' import ClientLibrary from 'components/interfaces/Home/ClientLibrary' import ExampleProject from 'components/interfaces/Home/ExampleProject' import { CLIENT_LIBRARIES, EXAMPLE_PROJECTS } from 'components/interfaces/Home/Home.constants' import Link from 'next/link' import { useEffect, useRef } from 'react' import { Badge, Button, IconArrowRight, IconLoader } from 'ui' import { useParams } from 'common' import { DisplayApiSettings, DisplayConfigSettings } from 'components/ui/ProjectSettings' import { invalidateProjectDetailsQuery } from 'data/projects/project-detail-query' import { invalidateProjectsQuery } from 'data/projects/projects-query' import { useSelectedProject } from 'hooks' import { getWithTimeout } from 'lib/common/fetch' import { API_URL, PROJECT_STATUS } from 'lib/constants' const BuildingState = () => { const { ref } = useParams() const project = useSelectedProject() const queryClient = useQueryClient() const checkServerInterval = useRef() // TODO: move to react-query async function checkServer() { if (!project) return const projectStatus = await getWithTimeout(`${API_URL}/projects/${project.ref}/status`, { timeout: 2000, }) if (projectStatus && !projectStatus.error) { const { status } = projectStatus if (status === PROJECT_STATUS.ACTIVE_HEALTHY) { clearInterval(checkServerInterval.current) if (ref) await invalidateProjectDetailsQuery(queryClient, ref) await invalidateProjectsQuery(queryClient) } } } useEffect(() => { // check server status every 4s checkServerInterval.current = window.setInterval(checkServer, 4000) return () => { clearInterval(checkServerInterval.current) } }, []) if (project === undefined) return null return (

{project?.name}

{project.status === PROJECT_STATUS.UNKNOWN ? 'Initiating project set up' : 'Setting up project'}

{' '} We are provisioning your database and API endpoints

This may take a few minutes

While you wait

Browse the Supabase{' '} documentation .

} />

Not working?

Try refreshing after a couple of minutes.

} />

    If your dashboard hasn't connected within 2 minutes, you can open a support ticket.

    } />
{project.status === PROJECT_STATUS.COMING_UP && (
Client libraries
{CLIENT_LIBRARIES.map((library) => ( ))}
Example projects
{EXAMPLE_PROJECTS.map((project) => ( ))}
)}
) } export default BuildingState const ChecklistItem = ({ description }: any) => { return (
  • {description}
  • ) }