-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PIMS-1967: Create link to project from property page (#2617)
Co-authored-by: Dylan Barkowsky <[email protected]>
- Loading branch information
1 parent
604f054
commit 5672997
Showing
7 changed files
with
197 additions
and
0 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
78 changes: 78 additions & 0 deletions
78
react-app/src/components/property/AssociatedProjectsTable.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,78 @@ | ||
import React from 'react'; | ||
import { DataGrid, GridCellParams, GridColDef, GridRowsProp } from '@mui/x-data-grid'; | ||
import { useTheme } from '@mui/material'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
interface Project { | ||
Id: number; | ||
ProjectNumber: string; | ||
StatusName: string; | ||
Description: string; | ||
} | ||
|
||
interface AssociatedProjectsTableProps { | ||
linkedProjects: Project[]; | ||
} | ||
|
||
const AssociatedProjectsTable: React.FC<AssociatedProjectsTableProps> = ({ linkedProjects }) => { | ||
const theme = useTheme(); | ||
const columns: GridColDef[] = [ | ||
{ | ||
field: 'ProjectNumber', | ||
headerName: 'Project Number', | ||
width: 150, | ||
renderCell: (params: GridCellParams) => ( | ||
<Link | ||
to={`/projects/${params.row.id}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
style={{ color: theme.palette.primary.main, textDecoration: 'none' }} | ||
> | ||
{String(params.value)} | ||
</Link> | ||
), | ||
}, | ||
{ field: 'StatusName', headerName: 'Status Name', width: 150 }, | ||
{ | ||
field: 'Description', | ||
headerName: 'Description', | ||
width: 550, | ||
renderCell: (params: GridCellParams) => ( | ||
<div style={{ whiteSpace: 'normal', wordWrap: 'break-word', overflow: 'visible' }}> | ||
{String(params.value)} | ||
</div> | ||
), | ||
}, | ||
]; | ||
|
||
const rows: GridRowsProp = linkedProjects.map((project) => ({ | ||
id: project.Id, | ||
ProjectNumber: project.ProjectNumber, | ||
StatusName: project.StatusName, | ||
Description: project.Description, | ||
})); | ||
|
||
return ( | ||
<DataGrid | ||
rows={rows} | ||
columns={columns} | ||
autoHeight | ||
hideFooter | ||
sx={{ | ||
borderStyle: 'none', | ||
'& .MuiDataGrid-columnHeaders': { | ||
borderBottom: 'none', | ||
}, | ||
'& div div div div >.MuiDataGrid-cell': { | ||
borderBottom: 'none', | ||
borderTop: '1px solid rgba(224, 224, 224, 1)', | ||
}, | ||
'& .MuiDataGrid-row:hover': { | ||
backgroundColor: 'transparent', | ||
}, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default AssociatedProjectsTable; |
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