import { useEffect, useState } from "react"; import { Helmet } from "react-helmet"; import { faArrowUpRightFromSquare, faBookOpen, faBugs, faCircleInfo } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useNavigate, useSearch } from "@tanstack/react-router"; import { Alert, AlertDescription, Button, Card, CardTitle, FormControl, Input, Select, SelectItem } from "@app/components/v2"; import { ROUTE_PATHS } from "@app/const/routes"; import { useWorkspace } from "@app/context"; import { useCreateIntegration } from "@app/hooks/api"; import { useGetIntegrationAuthApps, useGetIntegrationAuthById } from "@app/hooks/api/integrationAuth"; import { IntegrationsListPageTabs } from "@app/types/integrations"; export const FlyioConfigurePage = () => { const navigate = useNavigate(); const { mutateAsync } = useCreateIntegration(); const { currentWorkspace } = useWorkspace(); const integrationAuthId = useSearch({ from: ROUTE_PATHS.SecretManager.Integratons.FlyioConfigurePage.id, select: (el) => el.integrationAuthId }); const { data: integrationAuth, isPending: isIntegrationAuthLoading } = useGetIntegrationAuthById( (integrationAuthId as string) ?? "" ); const { data: integrationAuthApps = [], isPending: isIntegrationAuthAppsLoading } = useGetIntegrationAuthApps({ integrationAuthId: (integrationAuthId as string) ?? "" }); const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState( currentWorkspace.environments[0].slug ); const [secretPath, setSecretPath] = useState("/"); const [targetApp, setTargetApp] = useState(""); const [isLoading, setIsLoading] = useState(false); useEffect(() => { // TODO: handle case where apps can be empty if (integrationAuthApps) { if (integrationAuthApps.length > 0) { setTargetApp(integrationAuthApps[0].name); } else { setTargetApp("none"); } } }, [integrationAuthApps]); const handleButtonClick = async () => { try { if (!integrationAuth?.id) return; setIsLoading(true); await mutateAsync({ integrationAuthId: integrationAuth?.id, isActive: true, app: targetApp, sourceEnvironment: selectedSourceEnvironment, secretPath }); setIsLoading(false); navigate({ to: "/projects/$projectId/secret-manager/integrations", params: { projectId: currentWorkspace.id }, search: { selectedTab: IntegrationsListPageTabs.NativeIntegrations } }); } catch (err) { console.error(err); } }; return integrationAuth && selectedSourceEnvironment && integrationAuthApps && targetApp ? (
) : (
Something went wrong. Please contact{" "} support@infisical.com {" "} if the issue persists.