|
|
@@ -1,6 +1,7 @@
|
|
|
import { memo } from 'react';
|
|
|
|
|
|
import { Icon } from '@iconify/react';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import { useResponsive } from '@/hooks/useResponsive';
|
|
|
|
|
|
@@ -10,6 +11,12 @@ import { PlanTagType } from '@/defines';
|
|
|
|
|
|
import { useActions } from './useActions';
|
|
|
|
|
|
+const PLAN_TAG_TYPE_I18N_KEY: Record<PlanTagType, string> = {
|
|
|
+ [PlanTagType.NONE]: '',
|
|
|
+ [PlanTagType.MOST_POPULAR]: 'mostPopular',
|
|
|
+ [PlanTagType.LIMITED_TIME]: 'limitedTime',
|
|
|
+};
|
|
|
+
|
|
|
export interface PlanCardProps {
|
|
|
id: number;
|
|
|
title: string;
|
|
|
@@ -23,6 +30,7 @@ export interface PlanCardProps {
|
|
|
|
|
|
const PlanCard = memo(
|
|
|
({ title, subTitle, introduce, tag, tagType, isSelected = false, onClick }: PlanCardProps) => {
|
|
|
+ const { t } = useTranslation();
|
|
|
const { isMobile } = useResponsive();
|
|
|
const { containerRef, titleRef, subTitleRef, introduceRef, textSizes } = useActions(
|
|
|
isMobile,
|
|
|
@@ -45,12 +53,14 @@ const PlanCard = memo(
|
|
|
}`}
|
|
|
onClick={onClick}
|
|
|
>
|
|
|
- {tagType !== PlanTagType.NONE && (
|
|
|
+ {tagType != null && tagType !== PlanTagType.NONE && (
|
|
|
<div
|
|
|
className={`absolute top-[-13.5px] bg-[#0FA4E9] px-4 ${isMobile ? 'end-[21.13px] rounded-[4px] h-[24px]' : 'start-[21.13px] rounded-full py-1'}`}
|
|
|
>
|
|
|
<span className="text-black text-[14px] leading-[24px] font-normal uppercase">
|
|
|
- {tag}
|
|
|
+ {tag?.trim()
|
|
|
+ ? tag
|
|
|
+ : t(`pages.pricing.planTag.${PLAN_TAG_TYPE_I18N_KEY[tagType]}`)}
|
|
|
</span>
|
|
|
</div>
|
|
|
)}
|