()
| 61 | } |
| 62 | |
| 63 | export function IntegrationsManager() { |
| 64 | const navigate = useNavigate(); |
| 65 | const location = useLocation(); |
| 66 | const userId = getCurrentUserId(); |
| 67 | const { |
| 68 | providers, |
| 69 | connections, |
| 70 | fetchProviders, |
| 71 | fetchConnections, |
| 72 | refreshConnection, |
| 73 | disconnect, |
| 74 | upsertConnection, |
| 75 | error, |
| 76 | resetError, |
| 77 | loadingProviders, |
| 78 | loadingConnections, |
| 79 | } = useIntegrationStore(); |
| 80 | const { toast } = useToast(); |
| 81 | |
| 82 | const [configProvider, setConfigProvider] = useState<IntegrationProvider | null>(null); |
| 83 | const [connectingProvider, setConnectingProvider] = useState<string | null>(null); |
| 84 | const [refreshingConnectionId, setRefreshingConnectionId] = useState<string | null>(null); |
| 85 | const [deletingConnectionId, setDeletingConnectionId] = useState<string | null>(null); |
| 86 | const [customScopes, setCustomScopes] = useState<Record<string, string>>({}); |
| 87 | |
| 88 | useEffect(() => { |
| 89 | fetchProviders().catch((err) => { |
| 90 | console.error('Failed to load providers', err); |
| 91 | }); |
| 92 | }, [fetchProviders]); |
| 93 | |
| 94 | useEffect(() => { |
| 95 | fetchConnections(userId).catch((err) => { |
| 96 | console.error('Failed to load integrations', err); |
| 97 | }); |
| 98 | }, [fetchConnections, userId]); |
| 99 | |
| 100 | useEffect(() => { |
| 101 | if (!error) { |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | toast({ |
| 106 | title: 'Integration error', |
| 107 | description: error, |
| 108 | variant: 'destructive', |
| 109 | }); |
| 110 | }, [error, toast]); |
| 111 | |
| 112 | useEffect(() => { |
| 113 | const params = new URLSearchParams(location.search); |
| 114 | const connectedProvider = params.get('connected'); |
| 115 | if (connectedProvider) { |
| 116 | toast({ |
| 117 | title: 'Connection established', |
| 118 | description: `Successfully connected to ${connectedProvider}.`, |
| 119 | }); |
| 120 | params.delete('connected'); |
nothing calls this directly
no test coverage detected