import { PermissionAction } from '@supabase/shared-types/out/constants' import { Loader2 } from 'lucide-react' import { useState } from 'react' import { toast } from 'sonner' import { useParams } from 'common' import AlertError from 'components/ui/AlertError' import { FormHeader } from 'components/ui/Forms/FormHeader' import { useDeleteThirdPartyAuthIntegrationMutation } from 'data/third-party-auth/integration-delete-mutation' import { ThirdPartyAuthIntegration, useThirdPartyAuthIntegrationsQuery, } from 'data/third-party-auth/integrations-query' import { useCheckPermissions } from 'hooks/misc/useCheckPermissions' import { useFlag } from 'hooks/ui/useFlag' import { cn } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' import { AddIntegrationDropdown } from './AddIntegrationDropdown' import { CreateAuth0IntegrationDialog } from './CreateAuth0Dialog' import { CreateAwsCognitoAuthIntegrationDialog } from './CreateAwsCognitoAuthDialog' import { CreateFirebaseAuthIntegrationDialog } from './CreateFirebaseAuthDialog' import { IntegrationCard } from './IntegrationCard' import { getIntegrationType, getIntegrationTypeLabel, INTEGRATION_TYPES, } from './ThirdPartyAuthForm.utils' export const ThirdPartyAuthForm = () => { const thirdPartyAuthEnabled = useFlag('thirdPartyAuth') const { ref: projectRef } = useParams() const { data: integrationsData, isLoading, isError, isSuccess, error, } = useThirdPartyAuthIntegrationsQuery({ projectRef }) const integrations = integrationsData || [] const [selectedIntegration, setSelectedIntegration] = useState() const [selectedIntegrationForDeletion, setSelectedIntegrationForDeletion] = useState() const { mutateAsync: deleteIntegration } = useDeleteThirdPartyAuthIntegrationMutation() const canUpdateConfig = useCheckPermissions(PermissionAction.UPDATE, 'custom_config_gotrue') if (!thirdPartyAuthEnabled) { return null } if (isError) { return ( ) } return (
) : null } docsUrl="https://supabase.com/docs/guides/auth/third-party/overview" />
Billing is based on the number of monthly active users (MAUs) requesting your API throughout the billing period (50 included then you'll be charged{' '} $0.00325 per MAU).
{isLoading && (
)} {isSuccess ? ( integrations.length === 0 ? (

No providers configured yet

) : (
{integrations.map((integration) => { return ( { setSelectedIntegrationForDeletion(integration) }} /> ) })}
) ) : null} {}} onClose={() => setSelectedIntegration(undefined)} /> {}} onClose={() => setSelectedIntegration(undefined)} /> {}} onClose={() => setSelectedIntegration(undefined)} /> setSelectedIntegrationForDeletion(undefined)} onConfirm={async () => { if (!selectedIntegrationForDeletion) { return } const type = getIntegrationType(selectedIntegrationForDeletion) try { await deleteIntegration({ projectRef: projectRef!, tpaId: selectedIntegrationForDeletion.id, }) toast.success(`Successfully deleted ${getIntegrationTypeLabel(type)}.`) setSelectedIntegrationForDeletion(undefined) setSelectedIntegration(undefined) } catch (error) { toast.error(`Failed to delete ${getIntegrationTypeLabel(type)}.`) console.error(error) } }} >

{`Are you sure you want to delete the ${getIntegrationTypeLabel(getIntegrationType(selectedIntegrationForDeletion))} integration?`}

) }