Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/justiceotuya/adding redux #32

Merged
merged 10 commits into from
Jun 6, 2019
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
"react/jsx-tag-spacing": "error",
"react/jsx-no-literals": "error",
"react/jsx-wrap-multilines": "error",
"react/jsx-no-comment-textnodes": "error"
"react/jsx-no-comment-textnodes": "error",
"jsx-a11y/anchor-is-valid": 0
},
"settings": {
"react": {
Expand Down
3 changes: 3 additions & 0 deletions components/landingPage/components/LandingPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
.LandingPage_footer > ul {
list-style-type: none;
padding: 0;
display: flex;
flex-direction: column;
margin: 0;
}

.LandingPage_hero {
Expand Down
5 changes: 3 additions & 2 deletions components/landingPage/components/LandingPage.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';

import LandingPageContent from './LandingPageContent';
import { components } from '../../layout';
import LandingPageContent from './LandingPageContent';
import { LANDING_PAGE_CONTENTS, STRING } from '../constants';

const { PAGE_TITLE } = STRING;
const { PageLayout } = components;
const { PAGE_TITLE } = STRING;

/**
* Function for displaying the landing page
*
Expand Down
1 change: 1 addition & 0 deletions components/landingPage/components/LandingPage.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';

import LandingPage from './LandingPage';

describe('LandingPage', () => {
Expand Down
21 changes: 10 additions & 11 deletions components/landingPage/components/LandingPageContent.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import { Button, Typography } from 'antd';
import PropTypes from 'prop-types';
import Link from 'next/link';
import PropTypes from 'prop-types';
import React from 'react';

const { Title, Paragraph } = Typography;
const { Paragraph, Title } = Typography;

/**
* Function used to generate section layout content for landing page
* @function
* @param {Number} level - The Number from 1-5 representing the header level h1-h5
* @param {String} title- The Title of that Section
*@param {String} paragraphText- The Text of that section
* @param {Boolean} isButtonPresent- If true, a button is shown on that section
* @param {String} buttonText- the text on the button
* @param {String} buttonLink- the link that the button leads to
* @param {String} buttonText- the text on the button
* @param {Boolean} columnSection - if true, the section will be stacked
* @param {Boolean} isButtonPresent- If true, a button is shown on that section
* @param {Boolean} isImagePresent - if true, the image is shown
* @param {String} imageLink- the link to an image in the section
* @param {Number} level - The Number from 1-5 representing the header level h1-h5
*@param {String} paragraphText- The Text of that section
* @param {Boolean} reverseSection - if true, the image and section position is swapped
* @param {Boolean} isImagePresent - if true, the image is shown
* @param {Boolean} columnSection - if true, the section will be stacked
* @param {String} title- The Title of that Section
* @return {Object} The landing page content component which is used to populate the landing page
*/

Expand Down
4 changes: 2 additions & 2 deletions components/landingPage/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const {

const LANDING_PAGE_CONTENTS = [
{
buttonLink: 'http://localhost:3000/api/users/login',
buttonLink: '/api/users/login',
buttonText: LANDING_PAGE_MAIN_CONTENT_BUTTON_TEXT,
columnSection: false,
imageLink: '../../../static/connected.svg',
Expand Down Expand Up @@ -84,7 +84,7 @@ const LANDING_PAGE_CONTENTS = [
title: LANDING_PAGE_LEVEL_4_CONTENT_TITLE,
},
{
buttonLink: 'http://localhost:3000/api/users/login',
buttonLink: '/api/users/login',
buttonText: LANDING_PAGE_LEVEL_5_BUTTON_TEXT,
columnSection: false,
imageLink: '../../../static/hangout.svg',
Expand Down
3 changes: 1 addition & 2 deletions components/layout/components/FooterListCreator.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import Link from 'next/link';
import PropTypes from 'prop-types';
import React from 'react';

const FooterListCreator = props => {
const { list } = props;
Expand Down
40 changes: 16 additions & 24 deletions components/layout/components/NavHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import Head from 'next/head';
import {
Layout, Menu, Button, Input
Button, Input, Layout, Menu
} from 'antd';
import Head from 'next/head';
import Link from 'next/link';
import PropTypes from 'prop-types';
import React from 'react';

import {
MENU_ITEMS, STRINGS
IMAGE_ALT, IMAGE_URLS, LINKS, MENU_ITEMS, STRINGS
} from '../constants';

const { HEADER_TITLE, LOGIN, LOGOUT } = STRINGS;

const { Header } = Layout;
const { HEADER_TITLE, LOGIN, LOGOUT } = STRINGS;
const { HELPME_LOGO } = IMAGE_URLS;
const { HELPME_LOGO_DESC } = IMAGE_ALT;
const { LOGIN_LINK } = LINKS;
const { Search } = Input;

/**
Expand All @@ -23,7 +24,7 @@ const { Search } = Input;
* @return {Object} head metadata which is inserted in every page
*/
function NavHeader(props) {
const { title, handleSearch, searchValue } = props;
const { handleSearch, searchValue, title } = props;
let isAuthenticated;
// fake Authentication for development
if (global.location !== undefined && global.location.pathname === '/') {
Expand All @@ -36,28 +37,19 @@ function NavHeader(props) {
<>
{/* head parametes */}
<Head>
<meta charSet="UTF-8" />
<meta name="viewport" content="width=device-width initial-scale=1.0" />
<meta httpEquiv="X-UA-Compatible" content="ie=edge" />
<link rel="shortcut icon" href="../../static/favicon.ico" type="image/x-icon" />
<link rel="icon" href="../../static/favicon.ico" type="image/x-icon" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
/>
<title>{!title ? HEADER_TITLE : title}</title>
</Head>
{/* navheader for mobile */}
<Header theme="light" className="layout_header-mobile">
<Link href="http://localhost:3000/api/users/login">
<Link href={LOGIN_LINK}>
<a>
<img src="../../../static/logo.png" alt="helpme logo" className="logo" />
<img src={HELPME_LOGO} alt={HELPME_LOGO_DESC} className="logo" />
</a>
</Link>
{/* hide when authenticated */}
{isAuthenticated ? null : (
<Button className="LandingPage_login_button" type="primary">
<Link href="http://localhost:3000/api/users/login">
<Link href={LOGIN_LINK}>
<a>{LOGIN}</a>
</Link>
</Button>
Expand All @@ -67,7 +59,7 @@ function NavHeader(props) {
<Header theme="light" className="layout_header-desktop">
<Link href="/">
<a>
<img src="../../../static/logo.png" alt="helpme logo" className="logo" />
<img src={HELPME_LOGO} alt={HELPME_LOGO_DESC} className="logo" />
</a>
</Link>
{isAuthenticated ? (
Expand All @@ -76,7 +68,7 @@ function NavHeader(props) {
<Search
placeholder="input search text"
onSearch={handleSearch}
style={{ width: 200 }}
className="search"
value={searchValue}
/>
{/* navbar for authenticated desktop */}
Expand Down Expand Up @@ -107,7 +99,7 @@ function NavHeader(props) {
</>
) : (
<Button className="LandingPage_login_button" type="primary">
<Link href="/http://localhost:3000/api/users/login">
<Link href={LOGIN_LINK}>
<a>{LOGIN}</a>
</Link>
</Button>
Expand All @@ -126,5 +118,5 @@ NavHeader.propTypes = {
NavHeader.defaultProps = {
handleSearch: null,
searchValue: '',
title: 'welcome to Helpme',
title: 'Welcome to Helpme',
};
15 changes: 9 additions & 6 deletions components/layout/components/PageFooter.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import Link from 'next/link';
import { Layout } from 'antd';
import Link from 'next/link';
import React from 'react';

import { FOOTER_FIRST_COLUMN, FOOTER_SECOND_COLUMN } from '../constants';
import {
FOOTER_FIRST_COLUMN, FOOTER_SECOND_COLUMN, IMAGE_ALT, IMAGE_URLS
} from '../constants';
import FooterListCreator from './FooterListCreator';

const { Content, Footer } = Layout;
const { HELPME_LOGO_DESC } = IMAGE_ALT;
const { HELPME_LOGO_LIGHT } = IMAGE_URLS;

/**
* footer function that is infused into all pages
Expand All @@ -21,8 +24,8 @@ export default function PageFooter() {
<Link href="/">
<a>
<img
src="../../../static/logo-light.png"
alt="helpme logo"
src={HELPME_LOGO_LIGHT}
alt={HELPME_LOGO_DESC}
className="logo"
/>
</a>
Expand Down
4 changes: 4 additions & 0 deletions components/layout/components/PageLayout.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
margin-top: 64px;
}

.search{
width: 200px
}

.ant-layout {
background: #ffffff;
}
Expand Down
7 changes: 4 additions & 3 deletions components/layout/components/PageLayout.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* eslint-disable react/require-default-props */
import React from 'react';
import { Layout } from 'antd';
import PropTypes from 'prop-types';
import React from 'react';

import NavHeader from './NavHeader';
import Sidebar from './Sidebar';
import PageFooter from './PageFooter';
import Sidebar from './Sidebar';
import { STRINGS } from '../constants';

const { HEADER_TITLE } = STRINGS;
const { Content } = Layout;
const { HEADER_TITLE } = STRINGS;

/**
* Function for displaying the landing page
* @function
Expand Down
3 changes: 2 additions & 1 deletion components/layout/components/PageLayout.test.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';

import NavHeader from './NavHeader';
import PageFooter from './PageFooter';
import Sidebar from './Sidebar';
import PageLayout from './PageLayout';
justiceotuya marked this conversation as resolved.
Show resolved Hide resolved
import Sidebar from './Sidebar';

describe('PageLayout , NavHeader, PageFooter,Sidebar and PageLayout', () => {
it('NavHeader should render without crashing', () => {
Expand Down
6 changes: 3 additions & 3 deletions components/layout/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
import { Layout, Menu, Icon } from 'antd';
import { Icon, Layout, Menu } from 'antd';
import Link from 'next/link';
import PropTypes from 'prop-types';
import React from 'react';

import { SIDEBAR_MENU_ITEMS } from '../constants';

const { Sider } = Layout;

/**
* Function that controls the sidebar which displays on mobile
* @function
Expand Down
45 changes: 29 additions & 16 deletions components/layout/constants.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
// eslint-disable-next-line import/prefer-default-export

export const MENU_ITEMS = [
{
href: '/home',
key: 1,
text: 'Home',
}, {
href: '/forum',
key: 2,
text: 'Forum',
}, {
href: '/Dairy',
key: 3,
text: 'Dairy',
},
];

export const FOOTER_FIRST_COLUMN = [
{
href: '/',
Expand All @@ -39,6 +23,35 @@ export const FOOTER_SECOND_COLUMN = [
},
];

export const IMAGE_ALT = {
HELPME_LOGO_DESC: 'helpme logo',
};

export const IMAGE_URLS = {
HELPME_LOGO: '../../../static/logo.png',
HELPME_LOGO_LIGHT: '../../../static/logo-light.png',
};

export const LINKS = {
LOGIN_LINK: '/api/users/login',
};

export const MENU_ITEMS = [
{
href: '/home',
key: 1,
text: 'Home',
}, {
href: '/forum',
key: 2,
text: 'Forum',
}, {
href: '/Dairy',
key: 3,
text: 'Dairy',
},
];

export const SIDEBAR_MENU_ITEMS = [
{
href: '/#',
Expand Down
11 changes: 11 additions & 0 deletions components/timeLine/actionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const actionTypes = {
ADD_POST_TO_TIMELINE: 'ADD_POST_TO_TIMELINE',
CLEAR_STATUS_FIELD: 'CLEAR_STATUS_FIELD',
FETCH_PROFILE_DATA_FAILURE: 'FETCH_PROFILE_DATA_FAILURE',
FETCH_PROFILE_DATA_SUCCESS: 'PROFILE_DATA_SUCCESS',
FETCH_PROFILE_REQUEST: 'FETCH_PROFILE_REQUEST',
TOGGLE_MODAL: 'TOGGLE MODAL',
UPDATE_STATUS: 'UPDATE_STATUS',
};

export default actionTypes;
Loading