@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
45 lines (44 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const getValues = (res) => {
var _a, _b;
const csrfToken = res.locals.csrfToken || 'csrfToken';
const userId = ((_a = res.locals.user) === null || _a === void 0 ? void 0 : _a.uuid) ? res.locals.user.uuid : 'userId';
const token = ((_b = res.locals.user) === null || _b === void 0 ? void 0 : _b.token) ? res.locals.user.token : 'token';
const pathSuffix = res.locals.pathSuffix || '';
const routePrefix = res.locals.routePrefix || '';
const definitions = res.locals.definitions || [];
const requestedReports = res.locals.requestedReports || [];
const recentlyViewedReports = res.locals.recentlyViewedReports || [];
const bookmarks = res.locals.bookmarks || [];
const { bookmarkingEnabled, downloadingEnabled, definitionsPath, dpdPathFromQuery, dpdPathFromConfig } = res.locals;
return {
csrfToken,
userId,
token,
definitions,
requestedReports,
recentlyViewedReports,
bookmarks,
bookmarkingEnabled,
downloadingEnabled,
dpdPathFromQuery,
dpdPathFromConfig,
definitionsPath,
pathSuffix,
routePrefix,
};
};
const setDdpPathToReqQuery = (req, value) => {
if (value) {
req.query = {
...req.query,
dataProductDefinitionsPath: value,
};
}
return req.query;
};
exports.default = {
getValues,
setDdpPathToReqQuery,
};