generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds end-to-end feature for archiving and deleting user accounts (#1449)
* adds db migration file * adds backend feature to soft del and hard del users with their projects * adds endpoints to client * fixes broken endpoints * adds functionality to prevent archived users logging in * refactors migration and account service * adds frontend user feedback for archived users on log in * fixes functionality to retrieve all archived projects by security admin * edits migration for selecting all archived projects * adds db migration and service for unarchiving user * adds route and controller for unarchive endpoint * adds controller for unarchive endpoint * fixes unarchiveUser service * adds code to prevent self archive and self delete * adds frontend functionality to archive and delete users * updates migration reports * small fix to address line endings issues when working on branches between windows and unix systems * automatic linting fixes by lerna * fixes lerna issues, refactors, lints
- Loading branch information
Showing
21 changed files
with
9,978 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { createUseStyles } from "react-jss"; | ||
import * as projectService from "../../services/project.service"; | ||
import { useToast } from "../../contexts/Toast"; | ||
|
||
const useStyles = createUseStyles({ | ||
main: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "flex-start", | ||
alignItems: "center" | ||
}, | ||
pageTitle: { | ||
marginTop: "2em" | ||
}, | ||
pageSubtitle: { | ||
marginTop: "0.5em", | ||
textAlign: "center", | ||
fontSize: "20px", | ||
fontWeight: "normal", | ||
fontStyle: "normal" | ||
}, | ||
table: { | ||
minWidth: "80%", | ||
margin: "20px" | ||
}, | ||
tr: { | ||
margin: "0.5em" | ||
}, | ||
td: { | ||
padding: "0.2em", | ||
textAlign: "left" | ||
}, | ||
thead: { | ||
fontWeight: "bold", | ||
backgroundColor: "#0f2940", | ||
color: "white", | ||
"& td": { | ||
padding: ".4em" | ||
} | ||
}, | ||
tbody: { | ||
"& tr td": { | ||
padding: ".4em 0" | ||
}, | ||
"& tr:hover": { | ||
background: "#f0e300" | ||
} | ||
}, | ||
link: { | ||
textDecoration: "underline" | ||
} | ||
}); | ||
|
||
const ProjectsArchive = () => { | ||
const [archivedProjects, setArchivedProjects] = useState([]); | ||
|
||
const classes = useStyles(); | ||
// const toast = useToast(); | ||
const { add } = useToast(); | ||
|
||
useEffect(() => { | ||
const getArchivedProjects = async () => { | ||
try { | ||
const response = await projectService.getAllArchivedProjects(); | ||
if (response.status === 200) { | ||
setArchivedProjects(response.data); | ||
} else { | ||
add("Failed to get archived projects."); | ||
} | ||
} catch (err) { | ||
add("Error - Could not display archived projects."); | ||
} | ||
}; | ||
getArchivedProjects(); | ||
}, [add]); | ||
|
||
return ( | ||
<div className={classes.main}> | ||
<h1 className={classes.pageTitle}>Archived Projects</h1> | ||
<div className={classes.pageSubtitle}> | ||
<Link to="/roles" className={classes.link}> | ||
Return to Active Roles | ||
</Link> | ||
</div> | ||
<div className={classes.pageSubtitle}> | ||
<Link to="/archivedaccounts" className={classes.link}> | ||
See Archived Users | ||
</Link> | ||
</div> | ||
|
||
<table className={classes.table}> | ||
<thead className={classes.thead}> | ||
<tr className={classes.tr}> | ||
<td className={classes.td}>Name</td> | ||
<td className={classes.td}>Address</td> | ||
<td className={classes.td}>Created By</td> | ||
<td className={classes.td}>Created On</td> | ||
<td className={classes.td}>Last Modified</td> | ||
<td className={classes.td}>Archive Date</td> | ||
</tr> | ||
</thead> | ||
<tbody className={classes.tbody}> | ||
{archivedProjects.map(project => ( | ||
<tr key={project.id}> | ||
<td className={classes.td}>{project.name}</td> | ||
<td className={classes.td}>{project.address}</td> | ||
<td | ||
className={classes.td} | ||
>{`${project.lastName}, ${project.firstName}`}</td> | ||
<td className={classes.td}> | ||
{new Date(project.dateCreated).toLocaleDateString()} | ||
</td> | ||
<td className={classes.td}> | ||
{new Date(project.dateModified).toLocaleDateString()} | ||
</td> | ||
<td className={classes.td}> | ||
{new Date(project.archivedAt).toLocaleDateString()} | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProjectsArchive; |
Oops, something went wrong.