mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 10:25:06 +03:00
* Fix the types for API settings to include protocol. * Use the protocol property in all usages of endpoints. * Update * Lint * Revert changes to retrieving protocol * Remove console.logs --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useParams } from 'common'
|
|
import Snippets from 'components/interfaces/Docs/Snippets'
|
|
import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-config-query'
|
|
|
|
import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'
|
|
import CodeSnippet from './CodeSnippet'
|
|
import PublicSchemaNotEnabledAlert from './PublicSchemaNotEnabledAlert'
|
|
|
|
interface Props {
|
|
selectedLang: 'bash' | 'js'
|
|
}
|
|
|
|
export default function Introduction({ selectedLang }: Props) {
|
|
const { ref: projectRef } = useParams()
|
|
|
|
const { data: settings } = useProjectSettingsV2Query({ projectRef })
|
|
const { data: config } = useProjectPostgrestConfigQuery({ projectRef })
|
|
|
|
const protocol = settings?.app_config?.protocol ?? 'https'
|
|
const hostEndpoint = settings?.app_config?.endpoint
|
|
const endpoint = `${protocol}://${hostEndpoint ?? ''}`
|
|
|
|
const isPublicSchemaEnabled = config?.db_schema
|
|
.split(',')
|
|
.map((name) => name.trim())
|
|
.includes('public')
|
|
|
|
return (
|
|
<div className="doc-section doc-section--client-libraries">
|
|
<article className="code">
|
|
<CodeSnippet selectedLang={selectedLang} snippet={Snippets.init(endpoint)} />
|
|
|
|
{!isPublicSchemaEnabled && <PublicSchemaNotEnabledAlert />}
|
|
</article>
|
|
</div>
|
|
)
|
|
}
|