@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
22 lines (18 loc) • 695 B
text/typescript
export default {
getTotals: (pageSize: number, currentPage: number, totalRows: number, rowCount: number): string => {
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
},
}