From 2ea055e43f194b4caca1ef082baa7b743bb1aaaa Mon Sep 17 00:00:00 2001 From: merelendor Date: Mon, 29 Apr 2024 15:04:50 +0300 Subject: [PATCH] questionnaire download empty licences fix --- pages/api/questionnaire/download.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pages/api/questionnaire/download.js b/pages/api/questionnaire/download.js index 053b99d..c0fdaea 100644 --- a/pages/api/questionnaire/download.js +++ b/pages/api/questionnaire/download.js @@ -175,14 +175,20 @@ export default async function handler(req, res) if(questionnaire[group] !== null) { - page.drawText(questionnaire[group], { + let licenses = questionnaire[group]; + if(typeof licenses !== "string") + { + licenses = licenses.join(", "); + } + + page.drawText(licenses, { x: 152, - y: questionnaire[group].length > 500 ? 195 : (questionnaire[group].length > 400) ? 195 : 193, - size: questionnaire[group].length > 500 ? 4 : (questionnaire[group].length > 400) ? 5 : 6, + y: licenses.length > 500 ? 195 : (licenses.length > 400) ? 195 : 193, + size: licenses.length > 500 ? 4 : (licenses.length > 400) ? 5 : 6, font: formFont, color: rgb(0, 0, 0), maxWidth: 412, - lineHeight: questionnaire[group].length > 500 ? 4 : (questionnaire[group].length > 400) ? 5 : 6, + lineHeight: licenses.length > 500 ? 4 : (licenses.length > 400) ? 5 : 6, }); } }