This repository was archived by the owner on Mar 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
feat(bulk-upload): add table for last uploads #654
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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,76 @@ | ||
/** | ||
* Content of the Table component. | ||
*/ | ||
|
||
import React from "react"; | ||
import PT from "prop-types"; | ||
import _ from "lodash"; | ||
|
||
import style from "./style.module.scss"; | ||
|
||
export const TABLE_STATES = { | ||
LOADING_LAST_UPLOADS: "LOADING_LAST_UPLOADS", | ||
RESULT: "RESULT", | ||
}; | ||
|
||
export default function Table({ state, data }) { | ||
const columns = { | ||
created: { | ||
name: "Upload Date", | ||
formatter: (date) => | ||
new Intl.DateTimeFormat("en", { | ||
year: "numeric", | ||
month: "short", | ||
day: "2-digit", | ||
}).format(new Date(date)), | ||
}, | ||
status: { name: "Status" }, | ||
info: { name: "Info" }, | ||
failedRecordsUrl: { | ||
name: "Assets", | ||
formatter: (url) => | ||
url ? ( | ||
<a href={url} target="_blank" rel="noopener noreferrer"> | ||
Download | ||
</a> | ||
) : ( | ||
"N/A" | ||
), | ||
}, | ||
}; | ||
|
||
return state === TABLE_STATES.LOADING_LAST_UPLOADS ? ( | ||
<div className={style.content}> | ||
<h1 className={style.title}>Loading last uploads...</h1> | ||
</div> | ||
) : ( | ||
data.length > 0 && ( | ||
<div className={style.content}> | ||
<h1 className={style.title}>Past 24 Hours Upload Status</h1> | ||
<table className={style.tableContent}> | ||
<tr> | ||
{_.map(_.values(columns), ({ name }) => ( | ||
<th>{name}</th> | ||
))} | ||
</tr> | ||
{_.map(data, (item) => ( | ||
<tr> | ||
{_.map(_.keys(columns), (colKey) => ( | ||
<td> | ||
{columns[colKey].formatter | ||
? columns[colKey].formatter(item[colKey]) | ||
: item[colKey] || "N/A"} | ||
</td> | ||
))} | ||
</tr> | ||
))} | ||
</table> | ||
</div> | ||
) | ||
); | ||
} | ||
|
||
Table.propTypes = { | ||
state: PT.any, | ||
data: PT.array.isRequired, | ||
}; |
This file contains hidden or 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,53 @@ | ||
.content { | ||
margin-top: 15px; | ||
margin-bottom: 15px; | ||
} | ||
|
||
.title { | ||
text-align: center; | ||
color: #252526; | ||
font: 500 14pt Inter; | ||
} | ||
|
||
.tableContent { | ||
margin-top: 15px; | ||
margin-bottom: 15px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: 70%; | ||
} | ||
|
||
table { | ||
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; | ||
border-collapse: collapse; | ||
} | ||
|
||
th { | ||
padding-top: 12px; | ||
padding-bottom: 12px; | ||
text-align: center; | ||
background-color: #3cd656; | ||
color: white; | ||
} | ||
|
||
td { | ||
border: 1px solid #ddd; | ||
padding: 8px; | ||
text-align: center; | ||
} | ||
|
||
tr:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} | ||
tr:hover { | ||
background-color: #ddd; | ||
} | ||
|
||
a { | ||
color: #30a2c7; | ||
text-decoration: none; | ||
&:hover { | ||
color: #56ccf2; | ||
text-decoration: underline; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,8 @@ | ||
.content { | ||
background: #eee; | ||
border-radius: 10px; | ||
margin: auto; | ||
position: relative; | ||
user-select: none; | ||
width: 80%; | ||
} |
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.
TIL about
Intl
- very good usage 👏