diff --git a/frontend/src/hooks/api/integrationAuth/queries.tsx b/frontend/src/hooks/api/integrationAuth/queries.tsx index 7e5d3d711..96c23e4cc 100644 --- a/frontend/src/hooks/api/integrationAuth/queries.tsx +++ b/frontend/src/hooks/api/integrationAuth/queries.tsx @@ -297,6 +297,7 @@ const fetchIntegrationAuthRailwayEnvironments = async ({ integrationAuthId: string; appId: string; }) => { + if (appId === "none") return []; const { data: { environments } } = await apiRequest.get<{ environments: Environment[] }>( @@ -318,6 +319,7 @@ const fetchIntegrationAuthRailwayServices = async ({ integrationAuthId: string; appId: string; }) => { + if (appId === "none") return []; const { data: { services } } = await apiRequest.get<{ services: Service[] }>( diff --git a/frontend/src/pages/integrations/railway/create.tsx b/frontend/src/pages/integrations/railway/create.tsx index 4c4a04a3e..229c633c2 100644 --- a/frontend/src/pages/integrations/railway/create.tsx +++ b/frontend/src/pages/integrations/railway/create.tsx @@ -76,10 +76,15 @@ export default function RailwayCreateIntegrationPage() { } }, [targetEnvironments]); - const filteredServices = targetServices?.concat({ - name: "", - serviceId: "" - }); + useEffect(() => { + if (targetServices) { + if (targetServices.length > 0) { + setTargetServiceId(targetServices[0].serviceId); + } else { + setTargetServiceId("none"); + } + } + }, [targetServices]); const handleButtonClick = async () => { try { @@ -125,7 +130,7 @@ export default function RailwayCreateIntegrationPage() { selectedSourceEnvironment && integrationAuthApps && targetEnvironments && - filteredServices ? ( + targetServices ? (
Railway Integration @@ -180,6 +185,7 @@ export default function RailwayCreateIntegrationPage() { value={targetEnvironmentId} onValueChange={(val) => setTargetEnvironmentId(val)} className="w-full border border-mineshaft-500" + isDisabled={targetEnvironments.length === 0} > {targetEnvironments.length > 0 ? ( targetEnvironments.map((targetEnvironment) => ( @@ -202,15 +208,22 @@ export default function RailwayCreateIntegrationPage() { value={targetServiceId} onValueChange={(val) => setTargetServiceId(val)} className="w-full border border-mineshaft-500" + isDisabled={targetServices.length === 0} > - {filteredServices.map((targetService) => ( - - {targetService.name} + {targetServices.length > 0 ? ( + targetServices.map((targetService) => ( + + {targetService.name} + + )) + ) : ( + + No services found - ))} + )}