update tariff plan for annual
This commit is contained in:
@@ -70,7 +70,7 @@ export async function getUserFilesInfo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchTariffs() {
|
export async function fetchTariffs(tariffTerm: 'MONTHLY' | 'YEAR') {
|
||||||
const token = await getSessionData('token');
|
const token = await getSessionData('token');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -81,7 +81,8 @@ export async function fetchTariffs() {
|
|||||||
msg_id: 30001,
|
msg_id: 30001,
|
||||||
message_body: {
|
message_body: {
|
||||||
action: 'get',
|
action: 'get',
|
||||||
user_token: token
|
user_token: token,
|
||||||
|
tariff_term: tariffTerm
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { fetchTariffs, fetchTokensBundle } from '@/app/actions/action';
|
import { fetchTokensBundle } from '@/app/actions/action';
|
||||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
import { convertBytes } from '@/app/lib/convertBytes';
|
import { convertBytes } from '@/app/lib/convertBytes';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
|
|||||||
@@ -23,15 +23,16 @@ interface Tariff {
|
|||||||
|
|
||||||
export default function PaymentTabTariffs() {
|
export default function PaymentTabTariffs() {
|
||||||
const t = useTranslations('Global');
|
const t = useTranslations('Global');
|
||||||
|
const [billingPer, setBillingPer] = useState<'MONTHLY' | 'YEAR'>('MONTHLY');
|
||||||
const {
|
const {
|
||||||
data: tariffData,
|
data: tariffData,
|
||||||
isLoading,
|
isLoading,
|
||||||
isError,
|
isError,
|
||||||
error
|
error
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ['tariffData'],
|
queryKey: ['tariffData', billingPer],
|
||||||
queryFn: () => {
|
queryFn: () => {;
|
||||||
return fetchTariffs();
|
return fetchTariffs(billingPer);
|
||||||
},
|
},
|
||||||
select: (data: Tariff[] | null): Tariff[] => {
|
select: (data: Tariff[] | null): Tariff[] => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -53,7 +54,6 @@ export default function PaymentTabTariffs() {
|
|||||||
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
const [isProcessing, setIsProcessing] = useState<boolean>(false);
|
||||||
const [showWidget, setShowWidget] = useState<boolean>(false);
|
const [showWidget, setShowWidget] = useState<boolean>(false);
|
||||||
const [yooMoneyConfig, setYooMoneyConfig] = useState<YooMoneyCheckoutWidgetConfig | null>(null);
|
const [yooMoneyConfig, setYooMoneyConfig] = useState<YooMoneyCheckoutWidgetConfig | null>(null);
|
||||||
const [billingPer, setBillingPer] = useState<'per-month' | 'per-year'>('per-month');
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
async function createPayment(value: number, tariff: number) {
|
async function createPayment(value: number, tariff: number) {
|
||||||
@@ -184,7 +184,7 @@ export default function PaymentTabTariffs() {
|
|||||||
setShowWidget(false);
|
setShowWidget(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeBilling(type: 'per-month' | 'per-year') {
|
function changeBilling(type: 'MONTHLY' | 'YEAR') {
|
||||||
setBillingPer(type)
|
setBillingPer(type)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,17 +198,17 @@ export default function PaymentTabTariffs() {
|
|||||||
<div className="billing-toggle">
|
<div className="billing-toggle">
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
className={`billing-btn ${billingPer === 'per-month' ? 'active' : ''} `}
|
className={`billing-btn ${billingPer === 'MONTHLY' ? 'active' : ''} `}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
changeBilling('per-month');
|
changeBilling('MONTHLY');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('per-month')}
|
{t('per-month')}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`billing-btn ${billingPer === 'per-year' ? 'active' : ''} `}
|
className={`billing-btn ${billingPer === 'YEAR' ? 'active' : ''} `}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
changeBilling('per-year');
|
changeBilling('YEAR');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('annual')}
|
{t('annual')}
|
||||||
@@ -216,7 +216,64 @@ export default function PaymentTabTariffs() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{billingPer === 'per-month' && (
|
{billingPer === 'MONTHLY' && (
|
||||||
|
<div className="subscription-grid">
|
||||||
|
{tariffData?.map((item: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
price: number;
|
||||||
|
tokens: number;
|
||||||
|
maxFilesCount: number;
|
||||||
|
diskSize: number;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className="plan-card animate-card" key={item.id}>
|
||||||
|
<div className="plan-header">
|
||||||
|
<h3 className="plan-name">
|
||||||
|
{t.has(item.name) ? t(item.name) : item.name}
|
||||||
|
</h3>
|
||||||
|
<div className="plan-price">{item.price ?? 0} ₽</div>
|
||||||
|
<div className="plan-period">{t('per-month')}</div>
|
||||||
|
<div className="plan-tokens">{item.tokens ?? 0} токенов включено</div>
|
||||||
|
</div>
|
||||||
|
<ul className="plan-features">
|
||||||
|
<li className="plan-feature">
|
||||||
|
<span className="feature-icon">✓</span>
|
||||||
|
{item.maxFilesCount} файлов в месяц
|
||||||
|
</li>
|
||||||
|
<li className="plan-feature">
|
||||||
|
<span className="feature-icon">✓</span>
|
||||||
|
{item.diskSize ? convertBytes(item.diskSize) : 0} хранилища
|
||||||
|
</li>
|
||||||
|
<li className="plan-feature">
|
||||||
|
<span className="feature-icon">✓</span>
|
||||||
|
Базовые модули защиты
|
||||||
|
</li>
|
||||||
|
<li className="plan-feature">
|
||||||
|
<span className="feature-icon">✓</span>
|
||||||
|
Поддержка 24/7
|
||||||
|
</li>
|
||||||
|
<li className="plan-feature">
|
||||||
|
<span className="feature-icon not">✗</span>
|
||||||
|
API доступ
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div className="flex justify-center">
|
||||||
|
<button
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={() => openPaymentWindow(item.price, item.name, item.tokens, item.id)}
|
||||||
|
>
|
||||||
|
Выбрать план
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{billingPer === 'YEAR' && (
|
||||||
<div className="subscription-grid">
|
<div className="subscription-grid">
|
||||||
{tariffData?.map((item: {
|
{tariffData?.map((item: {
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
@@ -345,6 +345,7 @@
|
|||||||
"distribution-analytics": "Distribution analytics",
|
"distribution-analytics": "Distribution analytics",
|
||||||
"annual": "Annual",
|
"annual": "Annual",
|
||||||
"per-month": "Per month",
|
"per-month": "Per month",
|
||||||
|
"per-year": "Per year",
|
||||||
"violation-count": "Violation count",
|
"violation-count": "Violation count",
|
||||||
"your-files": "Your files",
|
"your-files": "Your files",
|
||||||
"files-under-protection": "Files under protection",
|
"files-under-protection": "Files under protection",
|
||||||
|
|||||||
@@ -345,6 +345,7 @@
|
|||||||
"distribution-analytics": "Аналитика распространения",
|
"distribution-analytics": "Аналитика распространения",
|
||||||
"annual": "Годовая",
|
"annual": "Годовая",
|
||||||
"per-month": "Помесячно",
|
"per-month": "Помесячно",
|
||||||
|
"per-year": "В год",
|
||||||
"violation-count": "Количество нарушений",
|
"violation-count": "Количество нарушений",
|
||||||
"your-files": "Ваши файлы",
|
"your-files": "Ваши файлы",
|
||||||
"files-under-protection": "Файлов под защитой",
|
"files-under-protection": "Файлов под защитой",
|
||||||
|
|||||||
Reference in New Issue
Block a user