From cf9e4d384a90b571844734220877a859c5621c74 Mon Sep 17 00:00:00 2001 From: wildscotsmen Date: Fri, 21 Sep 2018 15:11:52 -0400 Subject: [PATCH] Updated application to include report page and also added basic component for report form. --- src/components/Main.js | 11 +- src/components/ReportForm.js | 210 +++++++++++++++++++++++++++++++++++ src/pages/Report.js | 15 +++ 3 files changed, 232 insertions(+), 4 deletions(-) create mode 100644 src/components/ReportForm.js create mode 100644 src/pages/Report.js diff --git a/src/components/Main.js b/src/components/Main.js index df578c0..cba1468 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -9,6 +9,7 @@ import Home from '../pages/Home'; import Map from '../pages/Map'; import Quiz from '../pages/Quiz'; import Sighting from '../pages/Sighting'; +import Report from '../pages/Report'; import Info from '../pages/Info'; function TabContainer(props) { @@ -48,6 +49,7 @@ class SimpleTabs extends React.Component { + @@ -55,10 +57,11 @@ class SimpleTabs extends React.Component { {value === 0 && } - {value === 1 && } - {value === 2 && } - {value === 3 && } - {value === 4 && } + {value === 1 && } + {value === 2 && } + {value === 3 && } + {value === 4 && } + {value === 5 && } ); } diff --git a/src/components/ReportForm.js b/src/components/ReportForm.js new file mode 100644 index 0000000..cab0f04 --- /dev/null +++ b/src/components/ReportForm.js @@ -0,0 +1,210 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +// import classNames from 'classnames'; +import { withStyles } from '@material-ui/core/styles'; +import MenuItem from '@material-ui/core/MenuItem'; +import TextField from '@material-ui/core/TextField'; + +const styles = theme => ({ + container: { + display: 'flex', + flexWrap: 'wrap', + }, + textField: { + marginLeft: theme.spacing.unit, + marginRight: theme.spacing.unit, + marginTop: theme.spacing.unit, + }, + dense: { + marginTop: 30, + }, + menu: { + width: 200, + }, +}); + +function formatDate(date) { + var d = new Date(date), + month = '' + (d.getMonth() + 1), + day = '' + d.getDate(), + year = d.getFullYear(); + + if (month.length < 2) month = '0' + month; + if (day.length < 2) day = '0' + day; + + return [year, month, day].join('-'); +} + +/** + * Types of sightings. Label is what is + * viewed in the application, value is + * what is stored in the database. +*/ +const sightingTypes = [ + { + value: 'visual', + label: 'Visual', + }, + { + value: 'roadkill', + label: 'Roadkill', + }, + { + value: 'trapped', + label: 'Trapped', + }, + { + value: 'viewed_tracks', + label: 'Viewed Tracks', + }, + { + value: 'photo', + label: 'Photo', + }, + { + value: 'other', + label: 'Other', + }, +]; + +/** + * Levels of confidence. Label is what is + * viewed in the application, value is + * what is stored in the database. +*/ +const confidenceLevels = [ + { + value: '1', + label: '1 - Strongly unconfident', + }, + { + value: '2', + label: '2 - Unconfident', + }, + { + value: '3', + label: '3 - Somewhat confident', + }, + { + value: '4', + label: '4 - Confident', + }, + { + value: '5', + label: '5 - Very confident', + }, + ]; + +class ReportForm extends React.Component { + state = { + date: formatDate(new Date()), + time: '00:00', + multiline: 'Controlled', + type: '', + confidence: '' + }; + + handleChange = name => event => { + this.setState({ + [name]: event.target.value, + }); + }; + + render() { + const { classes } = this.props; + + return ( +
+ + {sightingTypes.map(option => ( + + {option.label} + + ))} + + + + {confidenceLevels.map(option => ( + + {option.label} + + ))} + + + + + + + + ); + } +} + +ReportForm.propTypes = { + classes: PropTypes.object.isRequired, +}; + +export default withStyles(styles)(ReportForm); \ No newline at end of file diff --git a/src/pages/Report.js b/src/pages/Report.js new file mode 100644 index 0000000..3a46a74 --- /dev/null +++ b/src/pages/Report.js @@ -0,0 +1,15 @@ +import React, { Component } from 'react'; +import ReportForm from '../components/ReportForm'; +import Typography from '@material-ui/core/Typography'; + +class Report extends Component { + render() { + return ( + + + + ); + } +} + +export default Report;