import { Card, Title, Text, Stack, Group, Button, Badge, Alert, } from '@mantine/core'; import { IconBrandGoogle, IconBrandAzure, IconLink, IconLinkOff, IconAlertCircle } from '@tabler/icons-react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { notifications } from '@mantine/notifications'; import api from '../../services/api'; export function LinkedAccounts() { const queryClient = useQueryClient(); const { data: providers } = useQuery({ queryKey: ['sso-providers'], queryFn: async () => { const { data } = await api.get('/auth/sso/providers'); return data; }, }); const { data: profile } = useQuery({ queryKey: ['auth-profile'], queryFn: async () => { const { data } = await api.get('/auth/profile'); return data; }, }); const unlinkMutation = useMutation({ mutationFn: (provider: string) => api.delete(`/auth/sso/unlink/${provider}`), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['auth-profile'] }); notifications.show({ message: 'Account unlinked', color: 'orange' }); }, onError: (err: any) => notifications.show({ message: err.response?.data?.message || 'Failed to unlink', color: 'red' }), }); const noProviders = !providers?.google && !providers?.azure; return (
Linked Accounts Connect third-party accounts for single sign-on
{noProviders && ( }> No SSO providers are configured. Contact your administrator to enable Google or Microsoft SSO. )} {providers?.google && (
Google Sign in with your Google account
)} {providers?.azure && (
Microsoft Sign in with your Microsoft account
)}
); }