From 2c7afca94d7c6aa6ed19a7b34b6cf380faa6a103 Mon Sep 17 00:00:00 2001 From: Andrew Farquharson Date: Sat, 24 Nov 2018 01:02:36 +0000 Subject: [PATCH 1/5] added two nav links --- src/components/02_molecule/Navigation/Navigation.jsx | 4 ++-- src/routes.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/02_molecule/Navigation/Navigation.jsx b/src/components/02_molecule/Navigation/Navigation.jsx index b8104e5..8f1fbd8 100644 --- a/src/components/02_molecule/Navigation/Navigation.jsx +++ b/src/components/02_molecule/Navigation/Navigation.jsx @@ -5,9 +5,9 @@ import breakpoints from '../../../styles/breakpoints'; const links = [ ['Home', '/', 'home'], - // ['Features', '/features', 'features'], + ['Features', '/features', 'features'], ['Recipes', '/recipes', 'recipes'], - // ['Magazine', '/magazine', 'magazine'], + ['Magazine', '/magazine', 'magazine'], ]; const Navigation = () => ( diff --git a/src/routes.js b/src/routes.js index 342bd88..8a98d51 100644 --- a/src/routes.js +++ b/src/routes.js @@ -14,12 +14,24 @@ const routes = [ exact: true, strict: true, }, + { + path: '/features', + component: RecipeLanding, + exact: true, + strict: true, + }, { path: '/recipes', component: RecipeLanding, exact: true, strict: true, }, + { + path: '/magazine', + component: RecipeLanding, + exact: true, + strict: true, + }, ]; export default routes; From 8d8d29ecdea58f4a9fd01c5d2c41b2b63a1df335 Mon Sep 17 00:00:00 2001 From: ABE1112 Date: Sat, 24 Nov 2018 16:01:41 -0500 Subject: [PATCH 2/5] first go --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8bf8ca4..c064793 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "contenta_react", "version": "0.1.0", "engines": { - "yarn": "0.27.5", - "node": "6.x" + "yarn": "1.12.3", + "node": "10.13.0" }, "private": true, "dependencies": { From 91e1d746ecf2cb882eca627b1fad998e9ab0fab4 Mon Sep 17 00:00:00 2001 From: ABE1112 Date: Sat, 24 Nov 2018 16:44:03 -0500 Subject: [PATCH 3/5] added feature and magazine folders with jsx files --- .../FeatureLanding/FeatureLanding.jsx | 76 +++++++++++++++++++ .../MagazineLanding/MagazineLanding.jsx | 76 +++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 src/components/04_template/FeatureLanding/FeatureLanding.jsx create mode 100644 src/components/04_template/MagazineLanding/MagazineLanding.jsx diff --git a/src/components/04_template/FeatureLanding/FeatureLanding.jsx b/src/components/04_template/FeatureLanding/FeatureLanding.jsx new file mode 100644 index 0000000..83ea748 --- /dev/null +++ b/src/components/04_template/FeatureLanding/FeatureLanding.jsx @@ -0,0 +1,76 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import * as landingPageActions from '../../../actions/landingPages'; +import * as loadingBarActions from 'react-redux-loading-bar'; +import Default from '../../05_page/Default/Default'; +import TeaserFeatured from '../../03_organism/TeaserFeatured/TeaserFeatured'; +import TeaserList from '../../03_organism/TeaserList/TeaserList'; + +class FeatureLanding extends Component { + componentDidMount() { + if (!this.props.landingPageCategories.length) { + this.props.showLoading(); + this.props.loadRecipeLandingPage(); + } + } + componentWillReceiveProps(nextProps) { + if (nextProps.landingPageCategories.length) { + this.props.hideLoading(); + } + } + render() { + if (this.props.landingPageCategories.length) { + return ( + +
+ + {this.props.landingPageCategories.map(category => ( +
+

{this.props.categories[category.id].title}

+ ({ + id: recipe, + title: this.props.recipes[recipe].title, + subtitle: this.props.recipes[recipe].time > 0 ? `${this.props.recipes[recipe].time}m` : '', + image: this.props.files[this.props.recipes[recipe].image].uri, + }))}/> +
+ ))} + +
+
+ ); + } + return null; + } +} + +FeatureLanding.defaultProps = { + categories: {}, + files: {}, + landingPageCategories: {}, + recipes: {}, +}; + +FeatureLanding.loadData = [landingPageActions.loadRecipeLandingPage]; + +export default connect((state) => ({ + categories: state.api.categories, + files: state.api.files, + landingPageCategories: state.landingPages.categories, + recipes: state.api.recipes, +}), { ...landingPageActions, ...loadingBarActions })(FeatureLanding); diff --git a/src/components/04_template/MagazineLanding/MagazineLanding.jsx b/src/components/04_template/MagazineLanding/MagazineLanding.jsx new file mode 100644 index 0000000..c35ea51 --- /dev/null +++ b/src/components/04_template/MagazineLanding/MagazineLanding.jsx @@ -0,0 +1,76 @@ +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import * as landingPageActions from '../../../actions/landingPages'; +import * as loadingBarActions from 'react-redux-loading-bar'; +import Default from '../../05_page/Default/Default'; +import TeaserFeatured from '../../03_organism/TeaserFeatured/TeaserFeatured'; +import TeaserList from '../../03_organism/TeaserList/TeaserList'; + +class MagazineLanding extends Component { + componentDidMount() { + if (!this.props.landingPageCategories.length) { + this.props.showLoading(); + this.props.loadRecipeLandingPage(); + } + } + componentWillReceiveProps(nextProps) { + if (nextProps.landingPageCategories.length) { + this.props.hideLoading(); + } + } + render() { + if (this.props.landingPageCategories.length) { + return ( + +
+ + {this.props.landingPageCategories.map(category => ( +
+

{this.props.categories[category.id].title}

+ ({ + id: recipe, + title: this.props.recipes[recipe].title, + subtitle: this.props.recipes[recipe].time > 0 ? `${this.props.recipes[recipe].time}m` : '', + image: this.props.files[this.props.recipes[recipe].image].uri, + }))}/> +
+ ))} + +
+
+ ); + } + return null; + } +} + +MagazineLanding.defaultProps = { + categories: {}, + files: {}, + landingPageCategories: {}, + recipes: {}, +}; + +MagazineLanding.loadData = [landingPageActions.loadRecipeLandingPage]; + +export default connect((state) => ({ + categories: state.api.categories, + files: state.api.files, + landingPageCategories: state.landingPages.categories, + recipes: state.api.recipes, +}), { ...landingPageActions, ...loadingBarActions })(MagazineLanding); From 4c75e0e5ee7339f824171d9dd4a69fdf300931ac Mon Sep 17 00:00:00 2001 From: Andrew Farquharson Date: Sun, 25 Nov 2018 03:27:23 +0000 Subject: [PATCH 4/5] created routes for features and magazine --- src/actions/landingPages.js | 96 +++++++++++++++++++ .../MagazineLanding/MagazineLanding.jsx | 4 +- src/routes.js | 2 + 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/src/actions/landingPages.js b/src/actions/landingPages.js index 82217a4..3865fa6 100644 --- a/src/actions/landingPages.js +++ b/src/actions/landingPages.js @@ -14,6 +14,32 @@ export function storeRecipeLandingPage(categories, recipesByCategory) { }; } +export const STORE_FEATURE_LANDING_PAGE = 'LOAD_FEATURE_LANDING_PAGE'; +export function storeFeatureLandingPage(categories, recipesByCategory) { + return { + type: STORE_RECIPE_LANDING_PAGE, + payload: { + categories, + recipesByCategory, + }, + }; +} + +export const STORE_MAGAZINE_LANDING_PAGE = 'LOAD_MAGAZINE_LANDING_PAGE'; +export function storeMagazineLandingPage(categories, recipesByCategory) { + return { + type: STORE_MAGAZINE_LANDING_PAGE, + payload: { + categories, + recipesByCategory, + }, + }; +} + + + + + export function loadRecipeLandingPage() { return function (dispatch) { let pageCategories = []; @@ -46,3 +72,73 @@ export function loadRecipeLandingPage() { }); }; } + + + + +export function loadFeLandingPage() { + return function (dispatch) { + let pageCategories = []; + return axios(`${api}/categories`) + .then((result) => { + dispatch(apiActions.storeAPIData(result.data)); + return result.data.data; + }) + .then(categories => categories.map(category => category.id)) + .then((categories) => { + pageCategories = categories; + return Promise.all(categories.map(category => + axios(`${api}/recipes`, { + params: { + 'filter[category.uuid][value]': category, + 'page[limit]': 4, + sort: 'created', + include: 'image,image.thumbnail', + isPromoted: true, + }, + }), + )); + }) + .then((result) => { + result.forEach((recipesInCategory) => { + dispatch(apiActions.storeAPIData(recipesInCategory.data)); + }); + + dispatch(storeFeatureLandingPage(pageCategories, result)); + }); + }; +} + + +export function loadMagazineLandingPage() { + return function (dispatch) { + let pageCategories = []; + return axios(`${api}/categories`) + .then((result) => { + dispatch(apiActions.storeAPIData(result.data)); + return result.data.data; + }) + .then(categories => categories.map(category => category.id)) + .then((categories) => { + pageCategories = categories; + return Promise.all(categories.map(category => + axios(`${api}/recipes`, { + params: { + 'filter[category.uuid][value]': category, + 'page[limit]': 4, + sort: 'created', + include: 'image,image.thumbnail', + isPromoted: true, + }, + }), + )); + }) + .then((result) => { + result.forEach((recipesInCategory) => { + dispatch(apiActions.storeAPIData(recipesInCategory.data)); + }); + + dispatch(storeMagazineLandingPage(pageCategories, result)); + }); + }; +} diff --git a/src/components/04_template/MagazineLanding/MagazineLanding.jsx b/src/components/04_template/MagazineLanding/MagazineLanding.jsx index c35ea51..15cc5e6 100644 --- a/src/components/04_template/MagazineLanding/MagazineLanding.jsx +++ b/src/components/04_template/MagazineLanding/MagazineLanding.jsx @@ -10,7 +10,7 @@ class MagazineLanding extends Component { componentDidMount() { if (!this.props.landingPageCategories.length) { this.props.showLoading(); - this.props.loadRecipeLandingPage(); + this.props.loadMagazineLandingPage(); } } componentWillReceiveProps(nextProps) { @@ -66,7 +66,7 @@ MagazineLanding.defaultProps = { recipes: {}, }; -MagazineLanding.loadData = [landingPageActions.loadRecipeLandingPage]; +MagazineLanding.loadData = [landingPageActions.loadMagazineLandingPage]; export default connect((state) => ({ categories: state.api.categories, diff --git a/src/routes.js b/src/routes.js index 8a98d51..f14ea61 100644 --- a/src/routes.js +++ b/src/routes.js @@ -5,7 +5,9 @@ * It returns an array of Redux Thunks. */ import Home from './components/04_template/Home/Home'; +import FeatureLanding from './components/04_template/FeatureLanding/FeatureLanding'; import RecipeLanding from './components/04_template/RecipeLanding/RecipeLanding'; +import MagazineLanding from './components/04_template/MagazineLanding/MagazineLanding'; const routes = [ { From 900211c183fa6eec9f513ff5f7de2d6a4208f917 Mon Sep 17 00:00:00 2001 From: Andrew Farquharson Date: Sun, 25 Nov 2018 04:01:04 +0000 Subject: [PATCH 5/5] edit placeholder text feature, magazine pages --- src/actions/landingPages.js | 11 ++--------- .../04_template/FeatureLanding/FeatureLanding.jsx | 12 ++++++------ .../04_template/MagazineLanding/MagazineLanding.jsx | 4 ++-- src/routes.js | 4 ++-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/actions/landingPages.js b/src/actions/landingPages.js index 3865fa6..c6b81f6 100644 --- a/src/actions/landingPages.js +++ b/src/actions/landingPages.js @@ -28,7 +28,7 @@ export function storeFeatureLandingPage(categories, recipesByCategory) { export const STORE_MAGAZINE_LANDING_PAGE = 'LOAD_MAGAZINE_LANDING_PAGE'; export function storeMagazineLandingPage(categories, recipesByCategory) { return { - type: STORE_MAGAZINE_LANDING_PAGE, + type: STORE_RECIPE_LANDING_PAGE, payload: { categories, recipesByCategory, @@ -36,10 +36,6 @@ export function storeMagazineLandingPage(categories, recipesByCategory) { }; } - - - - export function loadRecipeLandingPage() { return function (dispatch) { let pageCategories = []; @@ -73,10 +69,7 @@ export function loadRecipeLandingPage() { }; } - - - -export function loadFeLandingPage() { +export function loadFeatureLandingPage() { return function (dispatch) { let pageCategories = []; return axios(`${api}/categories`) diff --git a/src/components/04_template/FeatureLanding/FeatureLanding.jsx b/src/components/04_template/FeatureLanding/FeatureLanding.jsx index 83ea748..39196e1 100644 --- a/src/components/04_template/FeatureLanding/FeatureLanding.jsx +++ b/src/components/04_template/FeatureLanding/FeatureLanding.jsx @@ -10,7 +10,7 @@ class FeatureLanding extends Component { componentDidMount() { if (!this.props.landingPageCategories.length) { this.props.showLoading(); - this.props.loadRecipeLandingPage(); + this.props.loadFeatureLandingPage(); } } componentWillReceiveProps(nextProps) { @@ -24,8 +24,8 @@ class FeatureLanding extends Component {
))} ({ categories: state.api.categories, diff --git a/src/components/04_template/MagazineLanding/MagazineLanding.jsx b/src/components/04_template/MagazineLanding/MagazineLanding.jsx index 15cc5e6..994f763 100644 --- a/src/components/04_template/MagazineLanding/MagazineLanding.jsx +++ b/src/components/04_template/MagazineLanding/MagazineLanding.jsx @@ -24,8 +24,8 @@ class MagazineLanding extends Component {