Skip to content

Commit

Permalink
Refactor instance owner code to work with useEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
henrycatalinismith committed Dec 27, 2024
1 parent 5087dd5 commit 6f21047
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/core/env/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import IApiClient from 'core/api/client/IApiClient';

type EnvVars = {
FEAT_AREAS?: string | null;
INSTANCE_OWNER_HREF?: string | null;
INSTANCE_OWNER_NAME?: string | null;
MUIX_LICENSE_KEY: string | null;
ZETKIN_APP_DOMAIN: string | null;
ZETKIN_GEN2_ORGANIZE_URL?: string | null;
Expand Down
19 changes: 11 additions & 8 deletions src/features/surveys/components/surveyForm/SurveyFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import messageIds from 'features/surveys/l10n/messageIds';
import { Msg, useMessages } from 'core/i18n';
import SurveyContainer from './SurveyContainer';
import theme from 'theme';
import { useEnv } from 'core/hooks';

const SurveyFooter: FC = () => {
const env = useEnv();
const messages = useMessages(messageIds);

const links = useMemo(
Expand All @@ -19,16 +21,17 @@ const SurveyFooter: FC = () => {
},
{
href:
process.env.ZETKIN_PRIVACY_POLICY_LINK ||
messages.surveyForm.policy.link(),
typeof env.vars.ZETKIN_PRIVACY_POLICY_LINK === 'string'
? env.vars.ZETKIN_PRIVACY_POLICY_LINK
: messages.surveyForm.policy.link(),
text: messages.surveyFooter.links.privacy(),
},
...(typeof process.env.NEXT_PUBLIC_INSTANCE_OWNER_NAME === 'string' &&
typeof process.env.NEXT_PUBLIC_INSTANCE_OWNER_NAME_HREF === 'string'
...(typeof process.env.INSTANCE_OWNER_NAME === 'string' &&
typeof process.env.INSTANCE_OWNER_HREF === 'string'
? [
{
href: process.env.NEXT_PUBLIC_INSTANCE_OWNER_NAME_HREF,
text: process.env.NEXT_PUBLIC_INSTANCE_OWNER_NAME,
href: env.vars.INSTANCE_OWNER_HREF as string,
text: env.vars.INSTANCE_OWNER_NAME as string,
},
]
: []),
Expand All @@ -49,7 +52,7 @@ const SurveyFooter: FC = () => {
<Msg id={messageIds.surveyFooter.text} />
</Typography>
</Box>
{typeof process.env.NEXT_PUBLIC_INSTANCE_OWNER_NAME === 'string' && (
{typeof env.vars.INSTANCE_OWNER_NAME === 'string' && (
<Box pb={4}>
<Typography
color={theme.palette.secondary.light}
Expand All @@ -60,7 +63,7 @@ const SurveyFooter: FC = () => {
<Msg
id={messageIds.surveyFooter.hostingOrganization}
values={{
name: process.env.NEXT_PUBLIC_INSTANCE_OWNER_NAME,
name: env.vars.INSTANCE_OWNER_NAME,
}}
/>
</Typography>
Expand Down

0 comments on commit 6f21047

Please sign in to comment.