import { FC, useEffect, useState } from 'react' import { Helmet } from 'react-helmet-async' import { useTranslation } from 'react-i18next' import SidebarHint from './components/SidebarHint' import SupportImage from '../../assets/images/support.png' import { ArrowLeft, Building, CloseCircle, Component, Crown, InfoCircle, TickCircle } from 'iconsax-react' import Tabs from '../../components/Tabs' import { useGetSupportPlans } from './hooks/useSupportData' import { NumberFormat } from '../../config/func' import { PlanItemType, featureItemType } from './types/SupportTypes' import SupportSkeleton from './components/SupportSkeleton' import SupportIcon from './components/SupportIcon' import { SupportPlanFeatureKey } from './enum/SupportEnum' import BuyPlan from './components/BuyPlan' import { Link } from 'react-router-dom' import { Pages } from '../../config/Pages' const Support: FC = () => { const { data, isLoading } = useGetSupportPlans() const { t } = useTranslation('global') const [activeTab, setActiveTab] = useState('') useEffect(() => { if (data?.data?.supportPlans?.length > 0 && !activeTab) { setActiveTab(data.data.supportPlans[0].id) } }, [data, activeTab]) if (isLoading || !data?.data) { return } return (
داناک | {t('support.title')}
{t('support.title')}
بیشتر بدانید
({ icon: index === 0 ? : index === 1 ? : , label: plan.name, value: plan.id }))} active={activeTab} onChange={setActiveTab} />
support
{ data?.data?.supportPlans?.map((item: PlanItemType) => { return (
{item.name}
سالیانه
{item.price === 0 ? 'رایگان' : NumberFormat(item.price)}
{item.price === 0 ? ' ' : 'تومان'}
) }) }
{ data?.data?.supportPlans?.[0]?.features.map((row: featureItemType) => (
{t(`support.${row.featureKey}`)}
)) }
{ data?.data?.supportPlans?.map((item: PlanItemType) => (
{ item.features.map((row) => (
{ row.featureType === 'boolean' ? row.featureValue === 'true' ? : :
{row.featureValue} {row.featureKey === 'ticket_limit' && ' (روزانه)'}
}
)) }
)) }
{/* Mobile View */}
{ data?.data?.supportPlans?.map((plan: PlanItemType) => ( activeTab === plan.id && (
support
{plan.name}
سالیانه
{plan.price === 0 ? 'رایگان' : NumberFormat(plan.price)}
{plan.price === 0 ? ' ' : 'تومان'}
{ plan.features.map((row: featureItemType) => (
{t(`support.${row.featureKey}`)}
{ row.featureType === 'boolean' ? row.featureValue === 'true' ? : :
{row.featureValue} {row.featureKey === 'ticket_limit' && ' (روزانه)'}
}
)) }
) )) }
) } export default Support