-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into missions-branch
- Loading branch information
Showing
6 changed files
with
186 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import propTypes from 'prop-types'; | ||
|
||
const TableData = ({ data }) => (<td className="table-data">{data}</td>); | ||
|
||
TableData.propTypes = { | ||
data: propTypes.string.isRequired, | ||
}; | ||
|
||
export default TableData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import propTypes from 'prop-types'; | ||
import TableData from './TableData'; | ||
import Styles from './TableRow.module.css'; | ||
import { leaveJoinMission } from '../redux/missions/missions'; | ||
|
||
const TableRow = ({ data }) => { | ||
const { | ||
member, | ||
notMember, | ||
active, | ||
inactive, | ||
} = Styles; | ||
const { | ||
description, | ||
id, | ||
name, | ||
joined, | ||
} = data; | ||
const dispatch = useDispatch(); | ||
const jOrL = () => dispatch(leaveJoinMission(id)); | ||
const leaveOrJoin = joined ? 'Leave' : 'Join'; | ||
const Button = (<button onClick={jOrL} className={joined ? member : notMember} type="button">{`${leaveOrJoin} Mission`}</button>); | ||
const Span = (<span className={joined ? active : inactive}>{joined ? 'Active Member' : 'NOT A MEMBER'}</span>); | ||
return ( | ||
<tr className="table-row"> | ||
{[name, description, Span, Button].map((item) => ( | ||
<TableData key={uuidv4()} id={id} data={item} /> | ||
))} | ||
</tr> | ||
); | ||
}; | ||
|
||
TableRow.propTypes = { | ||
data: propTypes.instanceOf(Object).isRequired, | ||
}; | ||
|
||
export default TableRow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.member { | ||
border: 0.5px solid #e9858f; | ||
color: #e9858f; | ||
font-size: 0.8rem; | ||
width: 105px; | ||
height: 20px; | ||
line-height: 20px; | ||
font-weight: bolder; | ||
} | ||
|
||
.notMember { | ||
border: 0.5px solid black; | ||
color: black; | ||
font-size: 0.8rem; | ||
width: 105px; | ||
height: 20px; | ||
line-height: 20px; | ||
} | ||
|
||
.active { | ||
display: inline-block; | ||
background-color: #18a2b8; | ||
text-align: center; | ||
color: white; | ||
font-size: 0.8rem; | ||
width: 105px; | ||
height: 20px; | ||
line-height: 20px; | ||
} | ||
|
||
.inactive { | ||
display: inline-block; | ||
background-color: #6d757d; | ||
font-weight: bolder; | ||
color: white; | ||
font-size: 0.6rem; | ||
width: 105px; | ||
height: 20px; | ||
line-height: 20px; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,46 @@ | ||
const Missions = () => (<div>This is the missions page</div>); | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import TableRow from '../components/TableRow'; | ||
|
||
const Missions = () => { | ||
let state = useSelector((state) => state.missions); | ||
if (state.missions) { | ||
const temp = state.missions; | ||
state = temp; | ||
} | ||
return ( | ||
<table className="mission-table"> | ||
<thead> | ||
<tr className="table-row first-row"> | ||
<th className="th">Misson</th> | ||
<th className="th">Description</th> | ||
<th className="th">Status</th> | ||
<th className="th">Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{state.map((item) => { | ||
const { | ||
description, | ||
id, | ||
name, | ||
joined, | ||
} = item; | ||
return ( | ||
<TableRow | ||
key={item.id} | ||
data={{ | ||
description, | ||
id, | ||
name, | ||
joined, | ||
}} | ||
/> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
); | ||
}; | ||
|
||
export default Missions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters