@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
20 lines (19 loc) • 791 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
getTotals: (pageSize, currentPage, totalRows, rowCount) => {
let totals = '';
const currentRangeStart = (currentPage - 1) * pageSize;
const currentRangeEnd = currentRangeStart + rowCount;
if (currentRangeStart === 0 && totalRows === currentRangeEnd) {
totals = totalRows === 1 ? `${totalRows} total result` : `${totalRows} total results`;
}
else {
totals =
totalRows > 0
? `Showing <strong>${currentRangeStart + 1}</strong> to <strong>${currentRangeEnd}</strong> of <strong>${totalRows}</strong> results`
: `0-0 of 0`;
}
return totals;
},
};