From ad5c1a4125cb2f7914886d3ca1ad6560c1854481 Mon Sep 17 00:00:00 2001 From: Leonard Martin Date: Tue, 26 Mar 2019 10:26:30 +0000 Subject: [PATCH] Don't assume an open task exists on a project When viewing a granted licence then there is no open task associated with the project version, so reading its id fails. Check first that a task exists before trying to read it. --- pages/project-versions/read/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/project-versions/read/index.js b/pages/project-versions/read/index.js index 0cb44775..91b5ed95 100644 --- a/pages/project-versions/read/index.js +++ b/pages/project-versions/read/index.js @@ -21,7 +21,7 @@ module.exports = settings => { res.locals.static.establishments = req.user.profile.establishments; res.locals.scripts = ['/public/js/project/bundle.js']; const task = get(req.project, 'openTasks[0]'); - res.locals.static.taskId = task.id; + res.locals.static.taskId = task ? task.id : null; res.locals.static.isActionable = get(task, 'data.data.version') === req.versionId; res.locals.model = req.model; res.template = require('./views/index.jsx').default;