import { JwtSecretUpdateStatus } from '@supabase/shared-types/out/events' import { AlertCircle, Loader } from 'lucide-react' import { PropsWithChildren } from 'react' import { useParams } from 'common' import Panel from 'components/ui/Panel' import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query' import { useProjectPostgrestConfigQuery } from 'data/config/project-postgrest-config-query' import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query' import { Input } from 'ui' export const DisplayConfigSettings = () => { const { ref: projectRef } = useParams() const { data: settings, isPending: isProjectSettingsLoading, isError: isProjectSettingsError, } = useProjectSettingsV2Query({ projectRef, }) const { data: config, isError: isPostgrestError } = useProjectPostgrestConfigQuery({ projectRef }) const { data, isError: isJwtSecretUpdateStatusError, isPending: isJwtSecretUpdateStatusLoading, } = useJwtSecretUpdatingStatusQuery({ projectRef }) const jwtSecretUpdateStatus = data?.jwtSecretUpdateStatus const isNotUpdatingJwtSecret = jwtSecretUpdateStatus === undefined || jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updated const jwtSecret = config?.jwt_secret ?? '' const protocol = settings?.app_config?.protocol ?? 'https' const endpoint = settings?.app_config?.endpoint const apiUrl = endpoint ? `${protocol}://${endpoint}` : '-' return ( {isProjectSettingsError || isPostgrestError || isJwtSecretUpdateStatusError ? ( {isProjectSettingsError || isPostgrestError ? 'Failed to retrieve configuration' : 'Failed to update JWT secret'} ) : isProjectSettingsLoading || isPostgrestError || isJwtSecretUpdateStatusLoading ? ( {isProjectSettingsLoading ? 'Retrieving API keys' : 'JWT secret is being updated'} ) : ( <> > )} ) } const ConfigContentWrapper = ({ children }: PropsWithChildren<{}>) => { return ( Project Configuration } > {children} ) }
{isProjectSettingsError || isPostgrestError ? 'Failed to retrieve configuration' : 'Failed to update JWT secret'}
{isProjectSettingsLoading ? 'Retrieving API keys' : 'JWT secret is being updated'}