diff --git a/README.md b/README.md index 13865e7..4543681 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -Current Sketch File: https://drive.google.com/open?id=1te2BRyotmrfZk538s-tMRWjmUR_Ue7RK +Current Sketch File: N/A # Development 1. Clone the repo ``` -git clone https://github.com/setlife-network/website +git clone https://github.com/JPI-Tech/trshmag.git ``` 2. Install packages diff --git a/src/.DS_Store b/src/.DS_Store index 34db2ce..147099b 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/components/.DS_Store b/src/components/.DS_Store index bcc82c8..79ed83f 100644 Binary files a/src/components/.DS_Store and b/src/components/.DS_Store differ diff --git a/src/components/Calendar.js b/src/components/Calendar.js new file mode 100644 index 0000000..d733b62 --- /dev/null +++ b/src/components/Calendar.js @@ -0,0 +1,142 @@ +import React, { Component } from 'react' + +import { Container, Image, Row, Col } from 'react-bootstrap'; +import moment from 'moment' + +import { API_ROOT } from '../constants' + + +// Moment var currentYear = check.format('YYYY'); +const monthCompare = (a, b) => { + const months = { + 'January-2019.md': 11, + 'February-2019.md': 10, + 'March-2019.md': 9, + 'April-2019.md': 8, + 'May-2019.md': 7, + 'June-2019.md': 6, + 'July-2019.md': 5, + 'August-2019.md': 4, + 'September-2019.md': 3, + 'October-2019.md': 2, + 'November-2019.md': 1, + 'December-2019.md': 0 + } + + return months[a] - months[b] +} + +class Calendar extends Component { + + state = { + newsletters: [], + } + componentDidMount() { + + fetch(`${API_ROOT}/fetchAllNewsletters`) + .then(response => { + if (response.ok) { + return Promise.resolve(response); + } else { + return Promise.reject(new Error(response.statusText)); + } + }) + .then(response => response.json()) + .then(response => { + const newsletters = response + this.setState({ newsletters: newsletters }) + }) + .catch(error => { + console.log('Looks like there was a problem!', error) + this.props.history.push('/') + }) + + } + + + renderNewsletters = () => { + // anti pattern + // this setState(); + const sortedNewsletters = this.state.newsletters.sort(monthCompare) + return this.state.newsletters.map(t => { + + var url = `/newsletters/${t}` + url = url.slice(0, -3) + console.log(url) + return ( + // + + {t} + Feb + March + + // + ) + }); + } + + render() { + const { + content, + changeLanguage, + } = this.props + + return ( + + {this.renderNewsletters()} + + ); + } +} + +export default Calendar + + + +// +// {/*
*/} +//
+// 2019 +//
+// +// January +// Feb +// March +// +// +// April +// May +// June +// +// +// July +// Aug +// Sep +// +// +// Oct +// Nov +// Dec +// +// {/*
*/} +//
+ + +// renderNewsletters = () => { + +// this.state.newsletters.sort(monthCompare) +// return this.state.newsletters.map(t => { + +// var url = `/newsletters/${t}` +// url = url.slice(0, -3) + +// return ( +// +// +// {moment(url.slice(13), 'MMM - Y').format('MMMM YYYY')} +// +// +// ) +// }); +// } + diff --git a/src/components/Header.js b/src/components/Header.js index 8a7f4f1..7f90e2a 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -95,7 +95,7 @@ class Header extends Component { - + {this.renderHeaderLinks()} {/* {this.renderHeaderButton()} */} diff --git a/src/index.js b/src/index.js index b6c007e..2574573 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import React from 'react'; import { render } from 'react-dom'; import { BrowserRouter } from 'react-router-dom'; - +// import Calendar from './components/Calendar.js'; import './styles/index.scss'; import App from './App'; @@ -9,6 +9,7 @@ import App from './App'; render( + {/* */} , document.getElementById('root') ); diff --git a/src/pages/NewslettersPage.js b/src/pages/NewslettersPage.js index 72525ba..8a058e8 100644 --- a/src/pages/NewslettersPage.js +++ b/src/pages/NewslettersPage.js @@ -5,11 +5,13 @@ import moment from 'moment' import Header from '../components/Header' import Footer from '../sections/Footer' +import Calendar from '../components/Calendar.js'; + import { API_ROOT } from '../constants' const Section = styled(Row)` - margin:50px; + margin:10px; ` const monthCompare = (a, b) => { @@ -68,11 +70,11 @@ class NewslettersPage extends Component { url = url.slice(0, -3) return ( -
  • +
    {moment(url.slice(13), 'MMM - Y').format('MMMM YYYY')} -
  • + ) }); } @@ -94,18 +96,17 @@ class NewslettersPage extends Component { {this.state.newsletters && ( -
    - - - -

    +

    + + + {/*

    */} - {this.renderNewsletters()} + {/* {this.renderNewsletters()} */} + -

    + {/*

    */} - - +
    ) } diff --git a/src/sections/Footer.js b/src/sections/Footer.js index e889ee2..a45a38a 100644 --- a/src/sections/Footer.js +++ b/src/sections/Footer.js @@ -25,7 +25,7 @@ const Section = styled(Row)` const Header = () => ( -
    +