-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create DeliveryTable component; Add to DeliveryNeeded Includes changes to the grid system so that the table and explainer text can show in the same view. * Swap out table dep for already-installed Material Replaces the ts-react-json-table dependency with material-ui, which is already installed and available. * Provide timestamp data in API response * Sort by and show epoch timestamp, descending * Format timestamp for readability * Add i18 for table column names Co-authored-by: Sher Minn Chong <me@piratefsh.net>
- Loading branch information
1 parent
884b5f2
commit 05759ac
Showing
7 changed files
with
169 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from "react"; | ||
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 Paper from "@material-ui/core/Paper"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
const useStyles = makeStyles({ | ||
container: { | ||
maxHeight: 440, | ||
}, | ||
}); | ||
|
||
const DeliveryTable = ({ rows }) => { | ||
const { t: str } = useTranslation(); | ||
const classes = useStyles(); | ||
|
||
// sort happens in-place | ||
rows.sort((rowA, rowB) => rowB.timestamp - rowA.timestamp); | ||
|
||
// format data for presentation | ||
const formattedRows = rows.map((row) => { | ||
const timestamp = new Date(row.timestamp * 1000); | ||
|
||
return { | ||
...row, | ||
timestamp: `${timestamp.toLocaleDateString()}: ${timestamp.toLocaleTimeString()}`, | ||
}; | ||
}); | ||
|
||
return ( | ||
<TableContainer className={classes.container} component={Paper}> | ||
<Table aria-label="simple table"> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>{str("webapp:zoneFinder.label.code")}</TableCell> | ||
<TableCell align="right"> | ||
{str("webapp:zoneFinder.label.crossStreetFirst")} | ||
</TableCell> | ||
<TableCell align="right"> | ||
{str("webapp:zoneFinder.label.crossStreetSecond")} | ||
</TableCell> | ||
<TableCell align="right"> | ||
{str("webapp:zoneFinder.label.firstName")} | ||
</TableCell> | ||
<TableCell align="right"> | ||
{str("webapp:zoneFinder.label.slackLink")} | ||
</TableCell> | ||
<TableCell align="right"> | ||
{str("webapp:zoneFinder.label.timestamp")} | ||
</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{formattedRows.map((row) => ( | ||
<TableRow key={row.Code}> | ||
<TableCell component="th" scope="row"> | ||
{row.Code} | ||
</TableCell> | ||
<TableCell align="right">{row["Cross Street #1"]}</TableCell> | ||
<TableCell align="right">{row["Cross Street #2"]}</TableCell> | ||
<TableCell align="right">{row["First Name"]}</TableCell> | ||
<TableCell align="right"> | ||
<a | ||
href={row.slackPermalink} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Slack | ||
</a> | ||
</TableCell> | ||
<TableCell align="right">{row.timestamp}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
); | ||
}; | ||
|
||
export default DeliveryTable; |
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