|
1 | 1 | // src/app/contribute/skill/page.tsx |
2 | 2 | 'use client'; |
| 3 | +import React from 'react'; |
| 4 | +import { Flex, Spinner } from '@patternfly/react-core'; |
| 5 | +import { t_global_spacer_xl as XlSpacerSize } from '@patternfly/react-tokens/dist/esm/t_global_spacer_xl'; |
3 | 6 | import { AppLayout } from '@/components/AppLayout'; |
4 | 7 | import { SkillFormGithub } from '@/components/Contribute/Skill/Github/index'; |
5 | 8 | import { SkillFormNative } from '@/components/Contribute/Skill/Native/index'; |
6 | | -import { t_global_spacer_xl as XlSpacerSize } from '@patternfly/react-tokens'; |
7 | | -import { Flex, Spinner } from '@patternfly/react-core'; |
8 | | -import { useEffect, useState } from 'react'; |
| 9 | +import { useEnvConfig } from '@/context/EnvConfigContext'; |
9 | 10 |
|
10 | 11 | const SkillFormPage: React.FunctionComponent = () => { |
11 | | - const [deploymentType, setDeploymentType] = useState<string | undefined>(); |
12 | | - const [loaded, setLoaded] = useState<boolean>(); |
13 | | - |
14 | | - useEffect(() => { |
15 | | - let canceled = false; |
16 | | - |
17 | | - const getEnvVariables = async () => { |
18 | | - const res = await fetch('/api/envConfig'); |
19 | | - const envConfig = await res.json(); |
20 | | - if (!canceled) { |
21 | | - setDeploymentType(envConfig.DEPLOYMENT_TYPE); |
22 | | - setLoaded(true); |
23 | | - } |
24 | | - }; |
25 | | - |
26 | | - getEnvVariables(); |
| 12 | + const { |
| 13 | + loaded, |
| 14 | + envConfig: { isGithubMode } |
| 15 | + } = useEnvConfig(); |
27 | 16 |
|
28 | | - return () => { |
29 | | - canceled = true; |
30 | | - }; |
31 | | - }, []); |
32 | 17 | return ( |
33 | 18 | <AppLayout className="contribute-page"> |
34 | 19 | {loaded ? ( |
35 | | - <>{deploymentType === 'native' ? <SkillFormNative /> : <SkillFormGithub />}</> |
| 20 | + !isGithubMode ? ( |
| 21 | + <SkillFormNative /> |
| 22 | + ) : ( |
| 23 | + <SkillFormGithub /> |
| 24 | + ) |
36 | 25 | ) : ( |
37 | 26 | <Flex alignItems={{ default: 'alignItemsCenter' }} justifyContent={{ default: 'justifyContentCenter' }} style={{ padding: XlSpacerSize.var }}> |
38 | 27 | <Spinner size="xl" /> |
|
0 commit comments