Skip to content

Commit

Permalink
fix: move project and story dispatch to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
theroyalblah committed Aug 12, 2019
1 parent 739a9f6 commit 85d6bef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 9 additions & 1 deletion client/components/projects/nav-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';

Expand All @@ -9,6 +9,9 @@ import { colors, fonts, fontSizes, spacing } from '~lib/theme';
import { toggleStoryList } from '~redux/actions/toggle-story-list';
import { ReduxState } from '~redux/reducers';

import { setProject } from '~redux/actions/project';
import { setStory } from '~redux/actions/story';

const Header = styled.div`
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -71,6 +74,11 @@ const NavBar = ({ projects, stories }: Props) => {
dispatch(toggleStoryList());
};

useEffect(() => {
dispatch(setProject(projects[0]));
dispatch(setStory(projects[0].stories[0], 1));
}, []);

return (
<>
<Header>
Expand Down
10 changes: 2 additions & 8 deletions client/components/projects/projects-dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import styled from 'styled-components';

import * as Types from '~components/projects/types';
import { colors, fonts, fontSizes } from '~lib/theme';
import { setProject } from '~redux/actions/project';
import { setStory } from '~redux/actions/story';
import { ReduxState } from '~redux/reducers';

import DropDown from '~assets/images/drop-down.svg';

Expand Down Expand Up @@ -98,11 +97,6 @@ const ProjectsDropdown = ({ projects }: Props) => {
setProjectName(newProject.name);
};

useEffect(() => {
dispatch(setProject(projects[0]));
dispatch(setStory(projects[0].stories[0], 1));
}, []);

return (
<>
<ProjectButton onClick={() => toggleVisibility(!isVisible)}>
Expand Down

0 comments on commit 85d6bef

Please sign in to comment.