chore: remove destructuring of intl.formatMessage

This commit is contained in:
Arvid Norlin
2024-08-14 09:39:26 +02:00
parent 6f293be3a7
commit 6c15f1ae3a
3 changed files with 17 additions and 14 deletions

View File

@@ -13,11 +13,11 @@ import styles from "./row.module.css"
import type { RowProps } from "@/types/components/myPages/myPage/earnAndBurn" import type { RowProps } from "@/types/components/myPages/myPage/earnAndBurn"
export default function Row({ transaction }: RowProps) { export default function Row({ transaction }: RowProps) {
const { formatMessage } = useIntl() const intl = useIntl()
const description = const description =
transaction.hotelName && transaction.city transaction.hotelName && transaction.city
? `${transaction.hotelName}, ${transaction.city} ${transaction.nights} ${formatMessage({ id: "nights" })}` ? `${transaction.hotelName}, ${transaction.city} ${transaction.nights} ${intl.formatMessage({ id: "nights" })}`
: `${transaction.nights} ${formatMessage({ id: "nights" })}` : `${transaction.nights} ${intl.formatMessage({ id: "nights" })}`
const arrival = dt(transaction.checkinDate) const arrival = dt(transaction.checkinDate)
.locale(getLang()) .locale(getLang())
.format("DD MMM YYYY") .format("DD MMM YYYY")

View File

@@ -1,6 +1,5 @@
"use client" "use client"
import { useIntl } from "react-intl" import { useIntl } from "react-intl"
import { ChevronDownIcon } from "@/components/Icons" import { ChevronDownIcon } from "@/components/Icons"
@@ -25,7 +24,7 @@ export default function DesktopTable({
showMore, showMore,
hasMore, hasMore,
}: TablePropsPagination) { }: TablePropsPagination) {
const { formatMessage } = useIntl() const intl = useIntl()
return ( return (
<div className={styles.container}> <div className={styles.container}>
@@ -37,7 +36,7 @@ export default function DesktopTable({
{tableHeadings.map((heading) => ( {tableHeadings.map((heading) => (
<th key={heading} className={styles.th}> <th key={heading} className={styles.th}>
<Body textTransform="bold"> <Body textTransform="bold">
{formatMessage({ id: heading })} {intl.formatMessage({ id: heading })}
</Body> </Body>
</th> </th>
))} ))}
@@ -61,7 +60,7 @@ export default function DesktopTable({
}} }}
> >
<ChevronDownIcon color="burgundy" height={24} width={24} /> <ChevronDownIcon color="burgundy" height={24} width={24} />
{formatMessage({ id: "Show more" })} {intl.formatMessage({ id: "Show more" })}
</button> </button>
</div> </div>
) : null} ) : null}
@@ -80,7 +79,7 @@ export default function DesktopTable({
<tbody> <tbody>
<tr> <tr>
<td colSpan={tableHeadings.length} className={styles.placeholder}> <td colSpan={tableHeadings.length} className={styles.placeholder}>
{formatMessage({ id: "No transactions available" })} {intl.formatMessage({ id: "No transactions available" })}
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -18,7 +18,7 @@ export default function MobileTable({
showMore, showMore,
hasMore, hasMore,
}: TablePropsPagination) { }: TablePropsPagination) {
const { formatMessage } = useIntl() const intl = useIntl()
return ( return (
<div className={styles.container}> <div className={styles.container}>
@@ -27,11 +27,13 @@ export default function MobileTable({
<tr> <tr>
<Body asChild> <Body asChild>
<th className={styles.th}> <th className={styles.th}>
{formatMessage({ id: "Transactions" })} {intl.formatMessage({ id: "Transactions" })}
</th> </th>
</Body> </Body>
<Body asChild> <Body asChild>
<th className={styles.th}>{formatMessage({ id: "Points" })}</th> <th className={styles.th}>
{intl.formatMessage({ id: "Points" })}
</th>
</Body> </Body>
</tr> </tr>
</thead> </thead>
@@ -52,7 +54,7 @@ export default function MobileTable({
<span>{`${transaction.hotelName}, ${transaction.city}`}</span> <span>{`${transaction.hotelName}, ${transaction.city}`}</span>
) : null} ) : null}
<span> <span>
{`${transaction.nights} ${formatMessage({ id: transaction.nights === 1 ? "night" : "nights" })}`} {`${transaction.nights} ${intl.formatMessage({ id: transaction.nights === 1 ? "night" : "nights" })}`}
</span> </span>
</td> </td>
<AwardPoints awardPoints={transaction.awardPoints} /> <AwardPoints awardPoints={transaction.awardPoints} />
@@ -61,7 +63,9 @@ export default function MobileTable({
) : ( ) : (
<tr> <tr>
<td className={styles.placeholder} colSpan={2}> <td className={styles.placeholder} colSpan={2}>
{formatMessage({ id: "There are no transactions to display" })} {intl.formatMessage({
id: "There are no transactions to display",
})}
</td> </td>
</tr> </tr>
)} )}
@@ -76,7 +80,7 @@ export default function MobileTable({
}} }}
> >
<ChevronDownIcon height={24} width={24} /> <ChevronDownIcon height={24} width={24} />
{formatMessage({ id: "Show more" })} {intl.formatMessage({ id: "Show more" })}
</button> </button>
) : null} ) : null}
</div> </div>