diff --git a/web/src/components/pagination.tsx b/web/src/components/pagination.tsx index c959667..04b9298 100644 --- a/web/src/components/pagination.tsx +++ b/web/src/components/pagination.tsx @@ -20,6 +20,8 @@ import { ChevronLeftIcon, ChevronRightIcon, + DoubleArrowLeftIcon, + DoubleArrowRightIcon, } from '@radix-ui/react-icons' import { Button } from '@/components/ui/button' import { @@ -30,6 +32,7 @@ import { SelectValue, } from '@/components/ui/select' import { useTranslation } from 'react-i18next' +import { showNumbers } from '@/lib/utils' interface PaginationProps { totalItems: number @@ -66,6 +69,9 @@ export function EnvelopeListPagination({ setPageIndex(newPageIndex) } + const currentPage = pageIndex + 1; + const pageNumbers = showNumbers(currentPage, pageCount) + return (
@@ -94,6 +100,14 @@ export function EnvelopeListPagination({ {t("table.page")} {pageIndex + 1} {t("table.of")} {pageCount}
+ + + {pageNumbers.map((pageNumber, index) => ( +
+ {pageNumber === '...' ? ( + ... + ) : ( + + )} +
+ ))} +
diff --git a/web/src/features/mailbox/components/mail-list.tsx b/web/src/features/mailbox/components/mail-list.tsx index cddc18f..d018200 100644 --- a/web/src/features/mailbox/components/mail-list.tsx +++ b/web/src/features/mailbox/components/mail-list.tsx @@ -142,7 +142,6 @@ export function MailList({ />
- {/* LEFT AREA: From + Subject + Tags */}

{item.from}

@@ -154,7 +153,6 @@ export function MailList({ {item.subject} - {/* TAGS BELOW SUBJECT */}
{item.tags?.map((tag, i) => (
- {/* RIGHT AREA – actions & meta */}
{hasAttachments && (
diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index 19fb029..5464615 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -171,4 +171,36 @@ export const dateFnsLocaleMap: Record = { 'sv-se': sv, no: nb, 'no-no': nb, -}; \ No newline at end of file +}; + + +export function showNumbers(current: number, total: number) { + const max = 5 + const result = [] + + if (total <= max) { + for (let i = 1; i <= total; i++) { + result.push(i) + } + } else { + result.push(1) + if (current <= 3) { + for (let i = 2; i <= 4; i++) { + result.push(i) + } + result.push('...', total) + } else if (current >= total - 2) { + result.push('...') + for (let i = total - 3; i <= total; i++) { + result.push(i) + } + } else { + result.push('...') + for (let i = current - 1; i <= current + 1; i++) { + result.push(i) + } + result.push('...', total) + } + } + return result +} \ No newline at end of file