Skip to content

Commit

Permalink
Merge branch 'develop' into feat/DEVSU-2429-do-not-display-unsigned-sigs
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 authored Aug 15, 2024
2 parents 88abef1 + 8175b11 commit 0b928de
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
25 changes: 18 additions & 7 deletions app/components/SignatureCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,44 @@ const SignatureCard = ({
const { userDetails } = useSecurity();

const [userSignature, setUserSignature] = useState<UserType>();
const [role, setRole] = useState('');
const [role, setRole] = useState<string>();

useEffect(() => {
if (type) { // need to do these separately because signatures may be null
if (type === 'author') {
setRole('author');
} else if (type === 'reviewer') {
setRole('reviewer');
} else if (type === 'creator') {
setRole('creator');
}
}
if (signatures && type) {
if (type === 'author') {
setUserSignature(signatures.authorSignature);
setRole('author');
} else if (type === 'reviewer') {
setUserSignature(signatures.reviewerSignature);
setRole('reviewer');
} else if (type === 'creator') {
setUserSignature(signatures.creatorSignature);
setRole('bioinformatician');
}
}
}, [signatures, type, setRole]);

const handleSign = useCallback(async () => {
let newReport = null;

let reportRole = role;
// Assign user
try {
if (role === 'creator') {
reportRole = 'bioinformatician';
} else if (role === 'author') {
// Hardcode analyst role here because report does not accept 'author'
reportRole = 'analyst';
}
newReport = await api.post(
`/reports/${report.ident}/user`,
// Hardcode analyst role here because report does not accept 'author'
{ user: userDetails.ident, role: 'analyst' },
{ user: userDetails.ident, role: reportRole },
{},
).request();
} catch (e) {
Expand All @@ -79,7 +91,6 @@ const SignatureCard = ({
snackbar.error('Error assigning user to report: ', e.message);
}
}

// Do signature
try {
const newSignature = await api.put(
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "ipr-client",
"version": "6.31.0",
"version": "6.31.1",
"keywords": [],
"license": "GPL-3.0",
"sideEffects": false,
Expand Down

0 comments on commit 0b928de

Please sign in to comment.