-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from jadmsaadaot/SUBMIT-task#170
Integrate internal documents table in package page with backend
- Loading branch information
Showing
12 changed files
with
159 additions
and
122 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
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
49 changes: 49 additions & 0 deletions
49
submit-web/src/components/Submission/InternalDocuments/Row.tsx
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,49 @@ | ||
import { Link as MuiLink, TableRow, Typography } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { InternalStaffDocument } from "@/models/SubmissionItem"; | ||
import { getObjectFromS3 } from "@/components/Shared/Table/utils"; | ||
import { notify } from "@/components/Shared/Snackbar/snackbarStore"; | ||
import { StyledTableCell } from "@/components/Shared/Table/common"; | ||
|
||
type RowProps = { | ||
internalStaffDocument: InternalStaffDocument; | ||
}; | ||
|
||
export default function Row({ internalStaffDocument }: RowProps) { | ||
const [pendingGetObject, setPendingGetObject] = useState(false); | ||
const { name, url, created_by } = internalStaffDocument; | ||
|
||
const downloadDocument = async () => { | ||
try { | ||
if (pendingGetObject) return; | ||
setPendingGetObject(true); | ||
await getObjectFromS3({ name, url }); | ||
} catch (e) { | ||
notify.error("Failed to download document"); | ||
} finally { | ||
setPendingGetObject(false); | ||
} | ||
}; | ||
return ( | ||
<TableRow> | ||
<StyledTableCell colSpan={2}> | ||
<Typography | ||
variant="body1" | ||
color="inherit" | ||
sx={{ | ||
overflow: "clip", | ||
textOverflow: "ellipsis", | ||
cursor: "pointer", | ||
mx: 0.5, | ||
}} | ||
> | ||
<MuiLink onClick={downloadDocument}>{name}</MuiLink> | ||
</Typography> | ||
</StyledTableCell> | ||
<StyledTableCell align="right">{created_by || ""}</StyledTableCell> | ||
<StyledTableCell align="right"></StyledTableCell> | ||
<StyledTableCell align="right"></StyledTableCell> | ||
<StyledTableCell align="right"></StyledTableCell> | ||
</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
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
Oops, something went wrong.