Skip to content

Commit

Permalink
dont get experiments if not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
mimecuvalo committed Mar 7, 2023
1 parent b2d3d3f commit c4e89dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/Help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import {
Typography,
} from '@mui/material';
import { F, defineMessages, useIntl } from 'i18n';
import { MouseEvent, useEffect, useState } from 'react';
import { MouseEvent, useContext, useEffect, useState } from 'react';
import { styled, useTheme } from '@mui/material/styles';

import { $Experiment } from 'app/experiments';
import Cookies from 'js-cookie';
import { Help as HelpIcon } from '@mui/icons-material';
import Link from './Link';
import UserContext from 'app/UserContext';

const HelpContainer = styled('div')`
display: inline-block;
Expand All @@ -35,6 +36,7 @@ const messages = defineMessages({
// `;

export default function Help() {
const { user } = useContext(UserContext);
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>();
const [experiments, setExperiments] = useState<$Experiment[]>([]);
const [isExperimentsOpen, setIsExperimentsOpen] = useState(false);
Expand All @@ -49,8 +51,10 @@ export default function Help() {
const json = await response.json();
setExperiments(json.experiments ?? {});
}
fetchData();
}, [setExperiments]);
if (user) {
fetchData();
}
}, [setExperiments, user]);

const allExperiments = Object.keys(experiments).map((name: string) => ({
name,
Expand Down

0 comments on commit c4e89dd

Please sign in to comment.