feat(SW-164): Add pagination for friendship transactions

This commit is contained in:
Arvid Norlin
2024-08-13 11:33:06 +02:00
parent 2282e35a71
commit 6f293be3a7
13 changed files with 202 additions and 91 deletions

View File

@@ -0,0 +1,91 @@
"use client"
import { useIntl } from "react-intl"
import { ChevronDownIcon } from "@/components/Icons"
import Body from "@/components/TempDesignSystem/Text/Body"
import Row from "./Row"
import styles from "./desktop.module.css"
import type { TablePropsPagination } from "@/types/components/myPages/myPage/earnAndBurn"
const tableHeadings = [
"Arrival date",
"Description",
"Booking number",
"Transaction date",
"Points",
]
export default function DesktopTable({
transactions,
showMore,
hasMore,
}: TablePropsPagination) {
const { formatMessage } = useIntl()
return (
<div className={styles.container}>
{transactions.length ? (
<div>
<table className={styles.table}>
<thead className={styles.thead}>
<tr>
{tableHeadings.map((heading) => (
<th key={heading} className={styles.th}>
<Body textTransform="bold">
{formatMessage({ id: heading })}
</Body>
</th>
))}
</tr>
</thead>
<tbody>
{transactions.map((transaction, idx) => (
<Row
key={`${transaction.confirmationNumber}-${idx}`}
transaction={transaction}
/>
))}
</tbody>
</table>
{hasMore ? (
<div className={styles.footer}>
<button
className={styles.loadMoreButton}
onClick={() => {
showMore()
}}
>
<ChevronDownIcon color="burgundy" height={24} width={24} />
{formatMessage({ id: "Show more" })}
</button>
</div>
) : null}
</div>
) : (
<table className={styles.table}>
<thead className={styles.thead}>
<tr>
{tableHeadings.map((heading) => (
<th key={heading} className={styles.th}>
{heading}
</th>
))}
</tr>
</thead>
<tbody>
<tr>
<td colSpan={tableHeadings.length} className={styles.placeholder}>
{formatMessage({ id: "No transactions available" })}
</td>
</tr>
</tbody>
</table>
)}
</div>
)
}