-
Notifications
You must be signed in to change notification settings - Fork 17
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
88 table view #104
Merged
Merged
88 table view #104
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dc3c9cb
Create DeliveryTable component; Add to DeliveryNeeded
allthesignals 79aa9db
Swap out table dep for already-installed Material
allthesignals e76e08a
Provide timestamp data in API response
allthesignals bea6f10
Sort by and show epoch timestamp, descending
allthesignals 526fe5c
Format timestamp for readability
allthesignals b02423c
Add i18 for table column names
allthesignals 9136ee4
Merge branch 'master' into 88-table-view
piratefsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you replace these row field strings with those in lib/airtable/tables/requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mjmaurer sure! But how do I import ~airtable/tables/requests into the react app?
If I follow, we're using these row field strings to avoid weird property names ("Cross Street #1").
import Requests from "~airtable/tables/requests";
throwsImporting with relative path throws errors about the dependencies of the thing being imported.
Any ideas? Am I totally missing something? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @alllthesignals! Michael is out atm, Sherminn here. I think we probably don't have path aliasing set up for the react app, so you might just have to use relative path e.g.
../../lib/airtable
. Since this is non-blocking, plus we have other places in the webapp where we need to fix this, im going to go ahead and merge this first and follow up with a new issue to handle hardcoding of airtable field keys.This table view will be important for the upcoming work for #122, where volunteers can pick up delivery straight from the map. thank you for your contribution!