Introduction.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { useParams } from 'common'
  2. import CodeSnippet from './CodeSnippet'
  3. import { DocSection } from './DocSection'
  4. import PublicSchemaNotEnabledAlert from './PublicSchemaNotEnabledAlert'
  5. import Snippets from '@/components/interfaces/Docs/Snippets'
  6. import { InlineLink } from '@/components/ui/InlineLink'
  7. import { useProjectPostgrestConfigQuery } from '@/data/config/project-postgrest-config-query'
  8. import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
  9. interface Props {
  10. selectedLang: 'bash' | 'js'
  11. }
  12. export default function Introduction({ selectedLang }: Props) {
  13. const { ref: projectRef } = useParams()
  14. const { data: settings } = useProjectSettingsV2Query({ projectRef })
  15. const { data: config, isSuccess } = useProjectPostgrestConfigQuery({ projectRef })
  16. const protocol = settings?.app_config?.protocol ?? 'https'
  17. const hostEndpoint = settings?.app_config?.endpoint
  18. const endpoint = `${protocol}://${hostEndpoint ?? ''}`
  19. const isPublicSchemaEnabled = config?.db_schema
  20. .split(',')
  21. .map((name) => name.trim())
  22. .includes('public')
  23. return (
  24. <DocSection
  25. title="Connect to your project"
  26. content={
  27. <>
  28. <p>
  29. All projects have a RESTful endpoint that you can use with your project's API key to
  30. query and manage your database. These can be obtained from the{' '}
  31. <InlineLink href={`/project/${projectRef}/integrations/data_api/overview`}>
  32. API settings
  33. </InlineLink>
  34. .
  35. </p>
  36. <p>
  37. You can initialize a new Briven client using the <code>createClient()</code> method.
  38. The Briven client is your entrypoint to the rest of the Briven functionality and is
  39. the easiest way to interact with everything we offer within the Briven ecosystem.
  40. </p>
  41. </>
  42. }
  43. snippets={
  44. <>
  45. <CodeSnippet selectedLang={selectedLang} snippet={Snippets.init(endpoint)} />
  46. {isSuccess && !isPublicSchemaEnabled && <PublicSchemaNotEnabledAlert />}
  47. </>
  48. }
  49. />
  50. )
  51. }