import { JwtSecretUpdateStatus } from '@supabase/shared-types/out/events' import { useParams } from 'common' import { PropsWithChildren } from 'react' import { IconAlertCircle, IconLoader, Input } from 'ui' import Panel from 'components/ui/Panel' import { useJwtSecretUpdatingStatusQuery } from 'data/config/jwt-secret-updating-status-query' import { useProjectSettingsQuery } from 'data/config/project-settings-query' import { DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants' const DisplayConfigSettings = () => { const { ref: projectRef } = useParams() const { data: settings, isLoading: isProjectSettingsLoading, isError: isProjectSettingsError, } = useProjectSettingsQuery({ projectRef, }) const { data, isError: isJwtSecretUpdateStatusError, isLoading: isJwtSecretUpdateStatusLoading, } = useJwtSecretUpdatingStatusQuery({ projectRef }) const jwtSecretUpdateStatus = data?.jwtSecretUpdateStatus const isNotUpdatingJwtSecret = jwtSecretUpdateStatus === undefined || jwtSecretUpdateStatus === JwtSecretUpdateStatus.Updated // Get the API service const jwtSecret = settings?.project?.jwt_secret ?? '' const apiService = (settings?.services ?? []).find( (x: any) => x.app.id == DEFAULT_PROJECT_API_SERVICE_ID ) const apiConfig = apiService?.app_config const apiUrl = `${apiConfig?.protocol ?? 'https'}://${apiConfig?.endpoint ?? '-'}` return ( {isProjectSettingsError || isJwtSecretUpdateStatusError ? (

{isProjectSettingsError ? 'Failed to retrieve configuration' : 'Failed to update JWT secret'}

) : isProjectSettingsLoading || isJwtSecretUpdateStatusLoading ? (

{isProjectSettingsLoading ? 'Retrieving API keys' : 'JWT secret is being updated'}

) : ( <> )}
) } export default DisplayConfigSettings const ConfigContentWrapper = ({ children }: PropsWithChildren<{}>) => { return (
Project Configuration
} > {children}
) }