-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(requests-table):Implement requests table [Finishes #171380698]
- Loading branch information
1 parent
8c78fbd
commit 89d8953
Showing
54 changed files
with
1,605 additions
and
110 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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
{ | ||
"presets": ["@babel/preset-env","@babel/preset-react"], | ||
"plugins": ["transform-class-properties"] | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"transform-class-properties", | ||
"@babel/plugin-proposal-class-properties", | ||
"@babel/plugin-transform-regenerator", | ||
"@babel/plugin-transform-runtime" | ||
] | ||
} |
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 @@ | ||
version: "2" | ||
checks: | ||
method-lines: | ||
config: | ||
threshold: 40 | ||
method-complexity: | ||
config: | ||
threshold: 6 | ||
exclude_patterns: | ||
- "**/__tests__/" |
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
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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
const requests = { | ||
tripRequests: [ | ||
{ | ||
id: 1, | ||
trips: [ | ||
{ | ||
travelDate: '2020-09-15', | ||
travelFrom: 'Kigali', | ||
travelTo: 'Durban', | ||
}, | ||
], | ||
travelReason: 'Africa Tech Summit', | ||
accommodation: true, | ||
status: 'pending', | ||
}, | ||
{ | ||
id: 2, | ||
trips: [ | ||
{ | ||
travelDate: '2020-09-10', | ||
travelFrom: 'Kigali', | ||
travelTo: 'Dubai', | ||
}, | ||
], | ||
travelReason: 'Africa Tech Summit', | ||
accommodation: true, | ||
status: 'pending', | ||
}, | ||
], | ||
}; | ||
|
||
export default requests; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable no-undef */ | ||
import React from 'react'; | ||
import { createMount } from '@material-ui/core/test-utils'; | ||
import Link from '@material-ui/core/Link'; | ||
import { cleanup } from '@testing-library/react'; | ||
import CustomCard from '../CustomCard'; | ||
|
||
const title = 'Our Company'; | ||
const items = ['Careers', 'About', 'Vision']; | ||
|
||
describe('<CustomCard />', () => { | ||
afterEach(() => cleanup); | ||
|
||
it('Should match the CustomCard snapshot', () => { | ||
const component = createMount()( | ||
<CustomCard title={title} items={items} />, | ||
); | ||
|
||
expect(component.html).toMatchSnapshot(); | ||
expect(component.find(Link)).toHaveLength(3); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
src/components/CustomCard/__tests__/__snapshots__/CustomCard.test.js.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<CustomCard /> Should match the CustomCard snapshot 1`] = `[Function]`; |
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,121 @@ | ||
import React from 'react'; | ||
import PropTypes, { object } from 'prop-types'; | ||
import { withStyles, makeStyles } from '@material-ui/core/styles'; | ||
import Table from '@material-ui/core/Table'; | ||
import TableBody from '@material-ui/core/TableBody'; | ||
import TableCell from '@material-ui/core/TableCell'; | ||
import TableContainer from '@material-ui/core/TableContainer'; | ||
import TableHead from '@material-ui/core/TableHead'; | ||
import TableRow from '@material-ui/core/TableRow'; | ||
import RemoveCircleOutline from '@material-ui/icons/RemoveCircleOutline'; | ||
import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline'; | ||
import ActionsMenu from '../../views/ActionsMenu/ActionsMenu'; | ||
|
||
const StyledTableCell = withStyles((theme) => ({ | ||
head: { | ||
backgroundColor: theme.palette.secondary.contrastText, | ||
color: theme.palette.primary.dark, | ||
}, | ||
body: { | ||
fontSize: 14, | ||
}, | ||
}))(TableCell); | ||
|
||
const StyledTableRow = withStyles((theme) => ({ | ||
root: { | ||
'&:nth-of-type(odd)': { | ||
backgroundColor: theme.palette.action.hover, | ||
}, | ||
}, | ||
}))(TableRow); | ||
|
||
const useStyles = makeStyles({ | ||
table: { | ||
minWidth: 700, | ||
}, | ||
tableCell: { | ||
fontSize: 12, | ||
}, | ||
tableIcons: { | ||
fontSize: 16, | ||
}, | ||
noData: { | ||
fontSize: 14, | ||
color: '#777777', | ||
backgroundColor: '#FFFFFF', | ||
textAlign: 'center', | ||
}, | ||
}); | ||
|
||
const requesterActions = [ | ||
{ | ||
id: 1, | ||
name: 'Edit', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Book Accommodation', | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Rate Accommodation', | ||
}, | ||
{ | ||
id: 4, | ||
name: 'Like/Dislike Accommodation', | ||
}, | ||
]; | ||
|
||
const RequestsTable = ({ requests }) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<TableContainer> | ||
<Table className={classes.table} aria-label="customized table"> | ||
<TableHead> | ||
<TableRow> | ||
<StyledTableCell className={classes.tableCell}>Date</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">Departure</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">Destination</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">Reason</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">Accommodation</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="center">Status</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="center" /> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{requests.length > 0 ? (requests.map((row) => ( | ||
<StyledTableRow key={row.id}> | ||
<StyledTableCell className={classes.tableCell} component="th" scope="row"> | ||
{row.trips[0].travelDate} | ||
</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">{row.trips[0].travelFrom}</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">{row.trips[0].travelTo}</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">{row.travelReason}</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="left">{row.accommodation ? 'Yes' : 'No'}</StyledTableCell> | ||
<StyledTableCell className={classes.tableCell} align="center"> | ||
{row.status === 'pending' ? <RemoveCircleOutline className={classes.tableIcons} htmlColor="#DADADA" /> : <CheckCircleOutline className={classes.tableIcons} htmlColor="#00A799" />} | ||
</StyledTableCell> | ||
<StyledTableCell align="center"> | ||
<ActionsMenu actions={requesterActions} /> | ||
</StyledTableCell> | ||
</StyledTableRow> | ||
)) | ||
) : ( | ||
<StyledTableRow> | ||
<StyledTableCell className={classes.noData} component="th" scope="row" align="center" colSpan={7}> | ||
Oops! Looks like you have not yet made any requests. | ||
</StyledTableCell> | ||
</StyledTableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
); | ||
}; | ||
|
||
RequestsTable.propTypes = { | ||
requests: PropTypes.arrayOf(object).isRequired, | ||
}; | ||
|
||
export default RequestsTable; |
Oops, something went wrong.