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

[WIP] Manage Page #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14,294 changes: 0 additions & 14,294 deletions package-lock.json

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"react-router-dom": "^5.0.0",
"react-scripts": "3.0.1",
"react-select": "^3.0.4",
"react-table": "^6.10.0",
"recompose": "^0.30.0"
"react-table": "^7.0.0-beta.12",
"recompose": "^0.30.0",
"styled-components": "^4.4.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
71 changes: 71 additions & 0 deletions src/common/SimpleTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React, { Component } from 'react';
import { useTable } from 'react-table'
import styled from 'styled-components'

const Styles = styled.div`
padding: 1rem;
table {
border-spacing: 0;
border: 1px solid black;
tr {
:last-child {
td {
border-bottom: 0;
}
}
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
:last-child {
border-right: 0;
}
}
}
`

function SimpleTable({ columns, data }) {
// Use the state and functions returned from useTable to build your UI
const {
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
} = useTable({
columns,
data,
})

// Render the UI for your table
return (
<table {...getTableProps()}>
<thead>
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps()}>{column.render('Header')}</th>
))}
</tr>
))}
</thead>
<tbody {...getTableBodyProps()}>
{rows.map(
(row, i) =>
prepareRow(row) || (
<tr {...row.getRowProps()}>
{row.cells.map(cell => {
return <td {...cell.getCellProps()}>{cell.render('Cell')}</td>
})}
</tr>
)
)}
</tbody>
</table>
)
}

export {SimpleTable, Styles}
27 changes: 14 additions & 13 deletions src/components/Feedback/FeedbackTable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {Component} from 'react';
import ReactTable from 'react-table';
import {SimpleTable, Styles} from '../../common/SimpleTable'
import ModalBox from './ModalBox';
import 'react-table/react-table.css';
import './styles.css';

class FeedbackTable extends Component {
Expand Down Expand Up @@ -35,17 +34,18 @@ class FeedbackTable extends Component {
feedback: f['feedback'] ? f['feedback'][0]['comments'] : '',
};
});
return <div>
{this.state.displayModal && this.state.feedbackData ?
<ModalBox

return (<div>
{this.state.displayModal && this.state.feedbackData ?
<ModalBox
feedback={this.state.feedbackData}
onClose={this.hideModalBox}
/>
/>
: null
}
<ReactTable
columns={columns}
<Styles>
<SimpleTable
columns={columns}
data={tableData}
getTdProps={(state, rowInfo, column, instance) => {
return {
Expand All @@ -58,10 +58,10 @@ class FeedbackTable extends Component {
}
const feedbackData = filteredFeedback[0];
console.log(feedbackData);

this.setState({feedbackData: feedbackData});
this.displayModalBox();

if (handleOriginal) {
handleOriginal()
}
Expand All @@ -72,9 +72,10 @@ class FeedbackTable extends Component {
}
}}
/>
</div>
</Styles>
</div>)
}
}


export default FeedbackTable;
export default FeedbackTable;
100 changes: 100 additions & 0 deletions src/components/Post/NewMotions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React, { Component } from 'react';
import styled from 'styled-components'
import {SpeakingTimes, Times} from "../../constants/times";

const Styles = styled.div`
padding: 1rem;
margin-bottom: 200px;
table {
border-spacing: 0;
border: 1px solid black;
tr {
:last-child {
td {
border-bottom: 0;
}
}
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
:last-child {
border-right: 0;
}
}
}
`

class NewMotions extends Component {
constructor(props) {
super(props);
this.state = {
type: "Moderated",
topic: "",
del: "",
time: "5m",
sp_time: "1m",
}

}

onChange = event => {
this.setState({ [event.target.name]: event.target.value });
}

render () {
const {type, topic, del, time, sp_time} = this.state
const isInvalid = topic === '' || del === '' || time === '' || sp_time === '' || Times[time] % SpeakingTimes[sp_time] !== 0;
return (
<Styles>
<div className="box">
<h3>New Motion</h3>
<form onSubmit={event => this.props.broadcast(event, type, topic, del, time, sp_time)}>
<div className="form-group">
<select name="type" value={type} onChange={this.onChange}>
<option value="Moderated">Mod</option>
<option value="Unmoderated">Unmod</option>
<option value="Formal">Formal</option>
</select>
<input
name="topic"
value={topic}
onChange={this.onChange}
type="text"
placeholder="Topic"/>

<input
name="del"
value={del}
onChange={this.onChange}
type="text"
placeholder="Delegate"/>

<select
name="time"
value={time}
onChange={this.onChange}>

{Object.keys(Times).map((key, index) => (<option value={key} key={key}>{key}</option>))}
</select>

<select
name="sp_time"
value={sp_time}
onChange={this.onChange}>
{Object.keys(SpeakingTimes).map((key, index) => (<option value={key} key={key}>{key}</option>))}
</select>

<button disabled={isInvalid} type="submit"> Broadcast </button>
</div>
</form>
</div>
</Styles>
);
}
}

export default NewMotions
68 changes: 68 additions & 0 deletions src/components/Post/NewSpeaker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { Component } from 'react';
import styled from 'styled-components'
import {SpeakingTimes, Times} from "../../constants/times";

const Styles = styled.div`
padding: 1rem;
margin-bottom: 200px;
table {
border-spacing: 0;
border: 1px solid black;
tr {
:last-child {
td {
border-bottom: 0;
}
}
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
:last-child {
border-right: 0;
}
}
}
`

class NewSpeaker extends Component {
constructor(props) {
super(props);
this.state = {
speaker: ""
}

}

onChange = event => {
this.setState({ [event.target.name]: event.target.value });
}

render () {
const {speaker} = this.state
const isInvalid = speaker === '';
return (
<Styles>
<div className="box">
<h3>New Speaker</h3>
<form onSubmit={event => this.props.addSpeaker(event, speaker)}>
<div className="form-group">
<input
name="speaker"
value={speaker}
onChange={this.onChange}
type="text"
placeholder="New Speaker"/>
</div>
<button disabled={isInvalid} type="submit"> Add </button>
</form>
</div>
</Styles>
);
}
}

export default NewSpeaker
Loading