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 ( + //
+ */}
- {this.renderNewsletters()}
+ {/* {this.renderNewsletters()} */}
+