chore: replace function expression with inline statement

replace destructuring for better static analysis

remove unused variables
This commit is contained in:
Christian Andolf
2024-11-05 10:14:52 +01:00
parent 28c30b2416
commit f6b3cf8b92
25 changed files with 75 additions and 78 deletions

View File

@@ -13,13 +13,13 @@ export default async function MembershipNumber({
color,
membership,
}: MembershipNumberProps) {
const { formatMessage } = await getIntl()
const intl = await getIntl()
const classNames = membershipNumberVariants({ className, color })
return (
<div className={classNames}>
<Caption color="pale">
{formatMessage({ id: "Membership ID" })}
{intl.formatMessage({ id: "Membership ID" })}
{": "}
</Caption>
<span className={styles.icon}>

View File

@@ -18,7 +18,7 @@ export default async function Friend({
membership,
name,
}: FriendProps) {
const { formatMessage } = await getIntl()
const intl = await getIntl()
if (!membership?.membershipLevel) {
return null
}
@@ -28,7 +28,7 @@ export default async function Friend({
<section className={styles.friend}>
<header className={styles.header}>
<Body color="white" textTransform="bold" textAlign="center">
{formatMessage(
{intl.formatMessage(
isHighestLevel
? { id: "Highest level" }
: { id: `Level ${membershipLevels[membership.membershipLevel]}` }

View File

@@ -44,15 +44,13 @@ async function PointsColumn({
title,
subtitle,
}: PointsColumnProps) {
const { formatMessage, formatNumber } = await getIntl()
const intl = await getIntl()
function number() {
if (typeof points === "number") {
return formatNumber(points)
} else if (typeof nights === "number") {
return formatNumber(nights)
}
return "N/A"
let number = "N/A"
if (typeof points === "number") {
number = intl.formatNumber(points)
} else if (typeof nights === "number") {
number = intl.formatNumber(nights)
}
return (
@@ -63,16 +61,16 @@ async function PointsColumn({
textAlign="center"
className={styles.firstRow}
>
{formatMessage({
{intl.formatMessage({
id: title,
})}
</Body>
<Title color="white" level="h2" textAlign="center">
{number()}
{number}
</Title>
{subtitle ? (
<Body color="white" textAlign="center">
{formatMessage({ id: subtitle })}
{intl.formatMessage({ id: subtitle })}
</Body>
) : null}
</article>

View File

@@ -10,7 +10,7 @@ import { NextLevelPointsColumn, YourPointsColumn } from "./PointsColumn"
import { UserProps } from "@/types/components/myPages/user"
export default async function Points({ user }: UserProps) {
const { formatMessage } = await getIntl()
const intl = await getIntl()
const membership = getMembership(user.memberships)
@@ -27,7 +27,7 @@ export default async function Points({ user }: UserProps) {
{nextLevel && (
<NextLevelPointsColumn
points={membership?.pointsRequiredToNextlevel}
subtitle={`${formatMessage({ id: "next level:" })} ${nextLevel.name}`}
subtitle={`${intl.formatMessage({ id: "next level:" })} ${nextLevel.name}`}
/>
)}
{/* TODO: Show NextLevelNightsColumn when nightsToTopTier data is correct from Antavo */}