import { ChevronDown, RefreshCw, Unlink } from 'lucide-react' import Image from 'next/image' import { useState } from 'react' import { toast } from 'sonner' import { Badge, Button, Card, CardContent, cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from 'ui' import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal' import { PageSection, PageSectionContent, PageSectionDescription, PageSectionMeta, PageSectionSummary, PageSectionTitle, } from 'ui-patterns/PageSection' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { useGitHubAuthorizationDeleteMutation } from '@/data/integrations/github-authorization-delete-mutation' import { useGitHubAuthorizationQuery } from '@/data/integrations/github-authorization-query' import { BASE_PATH } from '@/lib/constants' import { openInstallGitHubIntegrationWindow } from '@/lib/github' export const AccountConnections = () => { const { data: gitHubAuthorization, isPending: isLoading, isSuccess, isError, error, } = useGitHubAuthorizationQuery() const [isRemoveModalOpen, setIsRemoveModalOpen] = useState(false) const isConnected = gitHubAuthorization !== null const { mutate: removeAuthorization, isPending: isRemoving } = useGitHubAuthorizationDeleteMutation({ onSuccess: () => { toast.success('GitHub authorization removed successfully') setIsRemoveModalOpen(false) }, }) const handleConnect = () => { openInstallGitHubIntegrationWindow('authorize') } const handleReauthenticate = () => { openInstallGitHubIntegrationWindow('authorize') } const handleRemove = () => { removeAuthorization() } return ( Connections Connect your Briven account with other services. {isLoading && ( )} {isError && (

Failed to load GitHub connection status: {error?.message}

)} {isSuccess && (
{`GitHub

GitHub

Sync repos to Briven projects for automatic branch creation and merging

{isConnected ? ( <> Connected { event.preventDefault() handleReauthenticate() }} >

Re-authenticate

setIsRemoveModalOpen(true)} >

Remove connection

) : ( )}
)}
setIsRemoveModalOpen(false)} onConfirm={handleRemove} loading={isRemoving} >

Removing this authorization will disconnect your GitHub account from Briven. You can reconnect at any time.

) }