Skip to content

Commit

Permalink
set header values throughout application
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxnelson997 committed Jun 16, 2018
1 parent baf8c93 commit 3a2e056
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/components/auth/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import SigninForm from './signinForm';

class Signin extends Component {

componentDidMount() {
this.props.updateHeader('Welcome to HOA Manager!', 'Please login to continue', false);
}

onSubmit = (fields) => {
this.props.signIn(fields, () => {
this.props.history.push('/dashboard');
Expand Down
4 changes: 4 additions & 0 deletions src/components/auth/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class Signup extends Component {
})
}

componentDidMount() {
this.props.updateHeader('Welcome to HOA Manager!', 'Please login to continue', false);
}

render() {
return (
<div className='sign-up'>
Expand Down
15 changes: 14 additions & 1 deletion src/components/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import React, { Component } from "react";

import { connect } from 'react-redux';
import * as actions from '../actions';

import TabNav from './tabnav';
import NewsletterGrid from "./newsletter/newsletterGrid";
import RequestsGrid from "./requests/requestsGrid";

class Dashboard extends Component {

componentDidMount() {
this.props.updateHeader(`Welcome ${this.props.name}`, 'HOA Management', true);
}

constructor(props) {
super(props);

Expand Down Expand Up @@ -49,4 +56,10 @@ class Dashboard extends Component {

}

export default Dashboard;
function mapStateToProps(state) {
return {
name: state.auth.user.fullname
}
}

export default connect(mapStateToProps, actions)(Dashboard);
10 changes: 6 additions & 4 deletions src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export function Header({ title, subtitle }) {
)
}

export function HeaderBar() {
return (
<div className='bar'></div>
)
export function HeaderBar({hideBar}) {
if(hideBar) {
return <div></div>
} else {
return <div className='bar'></div>
}
}
12 changes: 8 additions & 4 deletions src/components/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ import { Header, HeaderBar } from './header';

class Layout extends Component {
render() {
const { title, subtitle, hideBar } = this.props;
return (
<div className='layout-grid'>
<Header
title='Welcome to HOA Manager!'
subtitle='Please login to continue'
title={title}
subtitle={subtitle}
/>
<HeaderBar/>
{this.props.hideBar ? '' : <HeaderBar/>}
{this.props.children}
</div>
)
}
}

function mapStateToProps(state) {
return state;
const header = state.header;
return {
...header
}
}

Layout = connect(mapStateToProps)(Layout);
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/headerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const INITIAL_STATE = {
}

export default function(state = INITIAL_STATE, action) {
switch (key) {
switch (action.type) {
case UPDATE_HEADER:
const { title, subtitle, hideBar } = action.payload;
return {
Expand Down
4 changes: 3 additions & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { reducer as form } from 'redux-form';
import auth from './authReducer';
import newsletters from './newsletterReducer';
import requests from './requestsReducer';
import header from './headerReducer';

const rootReducer = combineReducers({
form,
auth,
newsletters,
requests
requests,
header
});

export default rootReducer;
2 changes: 1 addition & 1 deletion src/style/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body {
height: 100vh;

display: grid;
grid-template-rows: [page-s header-s] 13.6rem [header-e bar-s] 4rem [bar-e content-s] 1fr [content-e page-e];
grid-template-rows: [page-s header-s] 13.6rem [header-e bar-s] auto [bar-e content-s] 1fr [content-e page-e];
grid-template-columns: [page-s] 14rem [content-s] 1fr [content-e] 14rem [page-e]
}

Expand Down

0 comments on commit 3a2e056

Please sign in to comment.