Skip to content
Snippets Groups Projects
Commit c9a4bf06 authored by Sebastian Mihalache's avatar Sebastian Mihalache :hammer_pick:
Browse files

fix(manuscript-manager): handle not found error

parent f98b731a
No related branches found
No related tags found
1 merge request!110Sprint 21 Features
......@@ -75,6 +75,7 @@ const AssignHE = ({
<OpenModal
confirmText="Invite"
isFetching={isFetching}
modalKey={`${he.id}-invitehe`}
onConfirm={inviteHandlingEditor(he)}
subtitle={he.name}
title="Confirm Invitation"
......
const { omit, get, last } = require('lodash')
const config = require('config')
const logger = require('@pubsweet/logger')
const statuses = config.get('statuses')
......@@ -206,23 +206,30 @@ const parseUser = ({ user }) => omit(user, sensitiveUserProperties)
const getCollections = async ({ user, models }) => {
const userPermisssions = await getUserPermissions({ user, Team: models.Team })
return Promise.all(
return (await Promise.all(
userPermisssions.map(async up => {
let fragment = {}
let collection = {}
if (up.objectType === 'collection') {
collection = await models.Collection.find(up.objectId)
const latestFragmentId =
collection.fragments[collection.fragments.length - 1]
collection.currentVersion = await models.Fragment.find(latestFragmentId)
} else {
fragment = await models.Fragment.find(up.objectId)
collection = await models.Collection.find(fragment.collectionId)
collection.currentVersion = stripeFragmentByRole({
fragment,
role: up.role,
user,
})
try {
if (up.objectType === 'collection') {
collection = await models.Collection.find(up.objectId)
const latestFragmentId =
collection.fragments[collection.fragments.length - 1]
collection.currentVersion = await models.Fragment.find(
latestFragmentId,
)
} else {
fragment = await models.Fragment.find(up.objectId)
collection = await models.Collection.find(fragment.collectionId)
collection.currentVersion = stripeFragmentByRole({
fragment,
role: up.role,
user,
})
}
} catch (e) {
logger.error(`DB ERROR: ${e.message}`)
return null
}
const status = get(collection, 'status', 'draft')
collection.visibleStatus = get(statuses, `${status}.${up.role}.label`)
......@@ -234,7 +241,7 @@ const getCollections = async ({ user, models }) => {
return stripedColl.coll
}),
)
)).filter(Boolean)
}
module.exports = {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment