diff --git a/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx b/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx index 5389ba7b..d06d06e0 100644 --- a/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx +++ b/packages/frontend/src/components/projects/project/settings/EnvironmentVariablesTabPanel.tsx @@ -13,9 +13,9 @@ import { import AddEnvironmentVariableRow from './AddEnvironmentVariableRow'; import DisplayEnvironmentVariables from './DisplayEnvironmentVariables'; -import environmentVariablesData from '../../../../assets/environment-variables.json'; import { EnvironmentVariable, Environments } from '../../../../types/project'; import HorizontalLine from '../../../HorizontalLine'; +import { useOutletContext, useParams } from 'react-router-dom'; export type EnvironmentVariablesFormValues = { variables: { @@ -30,6 +30,15 @@ export type EnvironmentVariablesFormValues = { }; export const EnvironmentVariablesTabPanel = () => { + const { id } = useParams(); + + // @ts-expect-error create context type for projects + const { projects } = useOutletContext(); + + const currProject = useMemo(() => { + return projects.find((data: any) => Number(data.id) === Number(id)); + }, [id]); + const { handleSubmit, register, @@ -63,8 +72,8 @@ export const EnvironmentVariablesTabPanel = () => { }, [isSubmitSuccessful, reset]); const getEnvironmentVariable = useCallback((environment: Environments) => { - return (environmentVariablesData as EnvironmentVariable[]).filter((item) => - item.environments.includes(environment), + return (currProject.environmentVariables as EnvironmentVariable[]).filter( + (item) => item.environments.includes(environment), ); }, []); diff --git a/packages/frontend/src/types/project.ts b/packages/frontend/src/types/project.ts index 299ab8cb..62358e02 100644 --- a/packages/frontend/src/types/project.ts +++ b/packages/frontend/src/types/project.ts @@ -18,6 +18,7 @@ export interface ProjectDetails { repositoryId: number; members: MemberPermission[]; ownerId: number; + environmentVariables: EnvironmentVariable[]; } export interface MemberPermission { diff --git a/packages/gql-client/src/gql-queries.ts b/packages/gql-client/src/gql-queries.ts index 8b7babe8..4e4f7b5c 100644 --- a/packages/gql-client/src/gql-queries.ts +++ b/packages/gql-client/src/gql-queries.ts @@ -44,6 +44,11 @@ query { } environmentVariables { id + environments + key + value + createdAt + updatedAt } createdAt updatedAt