add tariff table, add edit tariff modal window

This commit is contained in:
smanylov
2026-05-29 18:43:37 +07:00
parent 96808c4a12
commit 8928960c34
7 changed files with 900 additions and 164 deletions
@@ -1,78 +1,6 @@
import TariffManagment from '@/app/ui/tariff-management/tariff-management';
export default function Page() { export default function Page() {
return ( return (
<div className="admin-content"> <TariffManagment />
<div className="content-header">
<h3>Управление тарифными планами</h3>
<div className="content-header-actions">
<button className="btn btn-primary">
<span></span>
<span>Создать тариф</span>
</button>
</div>
</div>
<div className="content-body" id="plans-container">
<div className="stats-grid">
<div className="stat-card">
<div className="stat-card-header">
<span className="stat-card-title">FREE</span>
<div className="stat-card-icon blue">🆓</div>
</div>
<div className="stat-card-value">0</div>
<div className="stat-card-label">100 токенов</div>
<div className="stat-card-footer">
<button className="btn btn-outline btn-sm">Редактировать</button>
</div>
</div>
<div className="stat-card">
<div className="stat-card-header">
<span className="stat-card-title">MINI (TELEGRAM)</span>
<div className="stat-card-icon cyan"></div>
</div>
<div className="stat-card-value">500</div>
<div className="stat-card-label">500 токенов</div>
<div className="stat-card-footer">
<button className="btn btn-outline btn-sm">Редактировать</button>
</div>
</div>
<div className="stat-card">
<div className="stat-card-header">
<span className="stat-card-title">BASIC</span>
<div className="stat-card-icon green"></div>
</div>
<div className="stat-card-value">990</div>
<div className="stat-card-label">1,000 токенов</div>
<div className="stat-card-footer">
<button className="btn btn-outline btn-sm">Редактировать</button>
</div>
</div>
<div className="stat-card">
<div className="stat-card-header">
<span className="stat-card-title">PRO</span>
<div className="stat-card-icon purple">💎</div>
</div>
<div className="stat-card-value">2,990</div>
<div className="stat-card-label">5,000 токенов</div>
<div className="stat-card-footer">
<button className="btn btn-outline btn-sm">Редактировать</button>
</div>
</div>
<div className="stat-card">
<div className="stat-card-header">
<span className="stat-card-title">BUSINESS</span>
<div className="stat-card-icon orange">🏢</div>
</div>
<div className="stat-card-value">9,990</div>
<div className="stat-card-label">20,000 токенов</div>
<div className="stat-card-footer">
<button className="btn btn-outline btn-sm">Редактировать</button>
</div>
</div>
</div>
</div>
</div>
) )
} }
+105
View File
@@ -0,0 +1,105 @@
'use server'
import { getSessionData } from '@/app/actions/session';
import { API_BASE_URL } from '@/app/actions/definitions';
export async function fetchTariffs(page: number) {
const token = await getSessionData('token');
try {
const response = await fetch(`${API_BASE_URL}/api/admin/info`, {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 40004,
message_body: {
action: 'get_all',
page: page,
page_size: 8
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
if (response.ok) {
const parsed = await response.json();
if (parsed.message_code === 0) {
return parsed.message_body.message_body;
} else {
return null;
}
} else {
throw new Error(`${response.status}`);
}
} catch (error) {
return null;
}
}
export async function updateTariffs(
id: number,
tariffPrice: number,
tariffName: string,
type: string,
tariffTokens: number,
maxFiles: number,
diskSize: number,
maxUsers: number,
description: string,
tariffTerm: 'MONTHLY' | 'YEAR',
accountType: 'b2c' | 'b2b' | 'token'
) {
const token = await getSessionData('token');
console.log(`updateTariffs - ${id}`);
try {
const response = await fetch(`${API_BASE_URL}/api/admin/info`, {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 40003,
message_body: {
action: 'update',
id: id,
tariff_price: tariffPrice,
tariff_name: tariffName,
type: type,
tariff_tokens: tariffTokens,
max_files: maxFiles,
disk_size: diskSize,
max_users: maxUsers,
description: description,
tariff_term: tariffTerm,
account_type: accountType
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
if (response.ok) {
const parsed = await response.json();
console.log(parsed);
if (parsed.message_code === 0) {
return parsed.message_body.message_body;
} else {
return null;
}
} else {
throw new Error(`${response.status}`);
}
} catch (error) {
return null;
}
}
@@ -0,0 +1,42 @@
import { useQuery } from '@tanstack/react-query';
import { fetchTariffs } from '@/app/actions/tariffActions';
export interface Tariff {
id: number;
type: string;
name: string;
price: number;
tokens: number;
maxFilesCount: number;
diskSize: number;
maxUsers: number;
tariffTerm: string;
description: string;
}
export interface TariffsData {
page: number;
page_size: number;
sort_by: string;
sort_direction: 'asc' | 'desc';
total_pages: number;
total_elements: number;
tariffs: Tariff[];
}
export const useTariffsData = (page: number) => {
return useQuery({
queryKey: ['tariffsData', page],
queryFn: () => {
return fetchTariffs(page);
},
select: (data: TariffsData | null) => {
if (!data) {
return null;
}
return data;
},
refetchInterval: 30000,
placeholderData: (previousData) => previousData
});
};
+105 -90
View File
@@ -2,6 +2,7 @@
@use './edit-permissions-modal.scss'; @use './edit-permissions-modal.scss';
@use './animation.scss'; @use './animation.scss';
@use './file-moderation-modal.scss'; @use './file-moderation-modal.scss';
@use './tariff-edit-modal.scss';
:root { :root {
--primary-color: #2563eb; --primary-color: #2563eb;
@@ -528,13 +529,27 @@
} }
.stat-card-title { .stat-card-title {
font-size: 13px; font-size: 14px;
color: var(--text-secondary); color: var(--text-secondary);
font-weight: 500; font-weight: 500;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.5px; letter-spacing: 0.5px;
} }
.stat-card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
}
.tariff-term-badge {
background: #eff6ff;
padding: 2px 12px;
border-radius: 8px;
font-size: 11px;
}
.stat-card-value { .stat-card-value {
/* width: 40px; */ /* width: 40px; */
width: auto; width: auto;
@@ -786,95 +801,6 @@
} }
} }
.tanstak-table-pagination {
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
margin-top: 1.5rem;
gap: 1rem;
@media (min-width: 768px) {
flex-direction: row;
}
.pagination-info {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.875rem;
&-pages {
color: v.$text-p;
}
&-files {
color: v.$text-s;
}
}
.pagination-controls {
display: flex;
align-items: center;
gap: 0.5rem;
.arrow {
padding-left: 0.5rem;
padding-right: 0.5rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
border: 2px solid v.$border-color-1;
border-radius: 10px;
box-shadow: 0 1px 2px #0000000d;
color: var(--primary-color);
.icon {
width: 18px;
}
/* */
&:hover {
background-color: v.$bg-light;
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
&-pages {
display: flex;
align-items: center;
gap: 0.25rem;
button {
border: 2px solid v.$border-color-1;
padding: 0.25rem 0.75rem;
border-radius: 10px;
color: var(--primary-color);
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
&.current {
background-color: var(--primary-color);
color: v.$white;
}
&.other {
&:hover {
background-color: v.$bg-light;
}
}
}
}
}
}
.tanstak-table-block { .tanstak-table-block {
overflow-x: auto; overflow-x: auto;
border-radius: 0.5rem; border-radius: 0.5rem;
@@ -1217,6 +1143,95 @@
} }
} }
.tanstak-table-pagination {
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
margin-top: 1.5rem;
gap: 1rem;
@media (min-width: 768px) {
flex-direction: row;
}
.pagination-info {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.875rem;
&-pages {
color: v.$text-p;
}
&-files {
color: v.$text-s;
}
}
.pagination-controls {
display: flex;
align-items: center;
gap: 0.5rem;
.arrow {
padding-left: 0.5rem;
padding-right: 0.5rem;
padding-top: 0.25rem;
padding-bottom: 0.25rem;
border: 2px solid v.$border-color-1;
border-radius: 10px;
box-shadow: 0 1px 2px #0000000d;
color: var(--primary-color);
.icon {
width: 18px;
}
/* */
&:hover {
background-color: v.$bg-light;
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
&-pages {
display: flex;
align-items: center;
gap: 0.25rem;
button {
border: 2px solid v.$border-color-1;
padding: 0.25rem 0.75rem;
border-radius: 10px;
color: var(--primary-color);
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
&.current {
background-color: var(--primary-color);
color: v.$white;
}
&.other {
&:hover {
background-color: v.$bg-light;
}
}
}
}
}
}
.empty-state { .empty-state {
text-align: center; text-align: center;
padding: 60px 20px; padding: 60px 20px;
+194
View File
@@ -0,0 +1,194 @@
@use './variable.scss' as v;
.tariff-edit-modal {
padding: 1.5rem;
min-width: 500px;
max-width: 600px;
max-height: 80vh;
overflow-y: auto;
&__title {
font-size: 1.5rem;
font-weight: bold;
margin-bottom: 1.5rem;
color: #111827;
}
&__content {
display: flex;
flex-direction: column;
gap: 1rem;
}
&__info-section {
border-bottom: 1px solid #e5e7eb;
padding-bottom: 0.75rem;
&:last-of-type {
border-bottom: none;
}
}
&__label {
display: block;
font-size: 0.875rem;
font-weight: 500;
color: #374151;
margin-bottom: 0.5rem;
}
&__value {
color: #111827;
word-break: break-word;
font-size: 0.875rem;
}
&__input {
width: 100%;
padding: 0.5rem;
border: 1px solid #e5e7eb;
border-radius: 0.25rem;
font-size: 0.875rem;
font-family: inherit;
color: #111827;
background-color: #ffffff;
transition: all 0.2s;
&:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
&::placeholder {
color: #9ca3af;
}
&:disabled {
background-color: #f3f4f6;
cursor: not-allowed;
}
&[type="number"] {
-moz-appearance: textfield;
&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
display: none;
}
}
}
&__textarea {
width: 100%;
padding: 0.5rem;
border: 1px solid #e5e7eb;
border-radius: 0.25rem;
font-size: 0.875rem;
font-family: inherit;
color: #111827;
background-color: #ffffff;
resize: vertical;
transition: all 0.2s;
&:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}
&::placeholder {
color: #9ca3af;
}
&:disabled {
background-color: #f3f4f6;
cursor: not-allowed;
}
}
&__actions {
display: flex;
justify-content: flex-end;
gap: 0.75rem;
}
// Стили для DropDownList внутри модального окна
.dropdown {
width: 100%;
}
}
// Адаптация для мобильных устройств
@media (max-width: 768px) {
.tariff-edit-modal {
min-width: 90vw;
padding: 1rem;
&__title {
font-size: 1.25rem;
margin-bottom: 1rem;
}
&__info-section {
padding-bottom: 0.5rem;
}
&__actions {
flex-direction: column-reverse;
button {
width: 100%;
}
}
}
}
// Стили для скроллбара (опционально)
.tariff-edit-modal {
scrollbar-width: thin;
scrollbar-color: #cbd5e1 #f1f5f9;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: #f1f5f9;
border-radius: 3px;
}
&::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 3px;
&:hover {
background: #94a3b8;
}
}
}
.tariff-edit-modal__row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
@media (max-width: 768px) {
grid-template-columns: 1fr;
gap: 0.75rem;
}
}
.tariff-edit-modal__info-section--half {
@extend .tariff-edit-modal__info-section;
@media (min-width: 769px) {
&:first-child {
padding-right: 0.5rem;
}
&:last-child {
padding-left: 0.5rem;
}
}
}
@@ -0,0 +1,223 @@
import { useEffect, useState } from 'react';
import { useMutation } from '@tanstack/react-query';
import { updateTariffs } from '@/app/actions/tariffActions';
import { toast } from 'sonner';
import DropDownList from '@/app/components/dropDownList';
import { convertBytes } from '@/app/lib/convertBytes';
export interface EditingTariff {
id: number;
name: string;
type: string;
price: number;
tokens: number;
maxFilesCount: number;
diskSize: number;
maxUsers: number;
description: string;
tariffTerm: string;
}
export function TariffEditModal({ tariff, onClose, onSuccess }: {
tariff: EditingTariff;
onClose: () => void;
onSuccess: () => void;
}) {
const [formData, setFormData] = useState({
price: tariff.price,
name: tariff.name,
tokens: tariff.tokens,
maxFilesCount: tariff.maxFilesCount,
diskSize: tariff.diskSize,
maxUsers: tariff.maxUsers,
description: tariff.description,
tariffTerm: tariff.tariffTerm === 'YEAR' ? 'YEAR' : 'MONTHLY' as 'MONTHLY' | 'YEAR',
accountType: tariff.type.includes('TOKEN') ? 'token' : tariff.type.includes('STUDIO') ? 'b2b' : 'b2c' as 'b2c' | 'b2b' | 'token'
});
const updateTariffMutation = useMutation({
mutationFn: async () => {
return await updateTariffs(
tariff.id,
formData.price,
formData.name,
tariff.type,
formData.tokens,
formData.maxFilesCount,
formData.diskSize,
formData.maxUsers,
formData.description,
formData.tariffTerm,
formData.accountType
);
},
onSuccess: (data) => {
if (data !== null && data !== undefined) {
toast.success('Тариф успешно обновлен');
onSuccess();
} else {
toast.error('Не удалось обновить тариф');
}
},
onError: () => {
toast.error('Произошла ошибка при обновлении тарифа');
},
});
const handleSubmit = () => {
updateTariffMutation.mutate();
};
const handleChange = (field: string, value: any) => {
setFormData(prev => ({ ...prev, [field]: value }));
};
return (
<div className="tariff-edit-modal">
<h2 className="tariff-edit-modal__title">Редактирование тарифа</h2>
<div className="tariff-edit-modal__content">
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">ID тарифа</label>
<p className="tariff-edit-modal__value">{tariff.id}</p>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Тип тарифа</label>
<p className="tariff-edit-modal__value">{tariff.type}</p>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Название</label>
<input
type="text"
className="tariff-edit-modal__input"
value={formData.name}
onChange={(e) => handleChange('name', e.target.value)}
placeholder="Введите название тарифа"
/>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Цена ()</label>
<input
type="number"
className="tariff-edit-modal__input"
value={formData.price}
onChange={(e) => handleChange('price', Number(e.target.value))}
placeholder="Введите цену"
min="0"
/>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Количество токенов</label>
<input
type="number"
className="tariff-edit-modal__input"
value={formData.tokens}
onChange={(e) => handleChange('tokens', Number(e.target.value))}
placeholder="Введите количество токенов"
min="0"
/>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Максимальное количество файлов</label>
<input
type="number"
className="tariff-edit-modal__input"
value={formData.maxFilesCount}
onChange={(e) => handleChange('maxFilesCount', Number(e.target.value))}
placeholder="Введите максимальное количество файлов"
min="0"
/>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Размер диска</label>
<input
type="number"
className="tariff-edit-modal__input"
value={formData.diskSize}
onChange={(e) => handleChange('diskSize', Number(e.target.value))}
placeholder="Введите размер диска в ГБ"
min="0"
step="1"
/>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Максимальное количество пользователей</label>
<input
type="number"
className="tariff-edit-modal__input"
value={formData.maxUsers}
onChange={(e) => handleChange('maxUsers', Number(e.target.value))}
placeholder="Введите максимальное количество пользователей"
min="0"
/>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Срок тарифа</label>
<DropDownList
value={formData.tariffTerm === 'YEAR' ? 'Год' : 'Месяц'}
callBack={(value: string) => {
handleChange('tariffTerm', value);
}}
>
<li value="MONTHLY">Месяц</li>
<li value="YEAR">Год</li>
</DropDownList>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Тип аккаунта</label>
<DropDownList
value={
formData.accountType === 'b2c' ? 'B2C' :
formData.accountType === 'b2b' ? 'B2B' : 'Token'
}
callBack={(value: string) => {
handleChange('accountType', value);
}}
>
<li value="b2c">B2C</li>
<li value="b2b">B2B</li>
<li value="token">Token</li>
</DropDownList>
</div>
<div className="tariff-edit-modal__info-section">
<label className="tariff-edit-modal__label">Описание</label>
<textarea
className="tariff-edit-modal__textarea"
value={formData.description}
onChange={(e) => handleChange('description', e.target.value)}
placeholder="Введите описание тарифа"
rows={4}
/>
</div>
<div className="tariff-edit-modal__actions">
<button
onClick={onClose}
className="btn btn-secondary"
disabled={updateTariffMutation.isPending}
>
Отмена
</button>
<button
onClick={handleSubmit}
className="btn btn-primary"
disabled={updateTariffMutation.isPending}
>
{updateTariffMutation.isPending ? 'Сохранение...' : 'Сохранить'}
</button>
</div>
</div>
</div>
);
}
@@ -0,0 +1,229 @@
'use client'
import { useTariffsData } from '@/app/hooks/react-query/useTariffsData';
import { useEffect, useState } from 'react';
import { convertBytes } from '@/app/lib/convertBytes';
import { IconDoubleArrowRight, IconArrowRight, IconDoubleArrowLeft, IconArrowLeft } from '@/app/ui/icons/icons';
import ModalWindow from '@/app/components/modalWindow';
import { useQueryClient } from '@tanstack/react-query';
import { EditingTariff, TariffEditModal } from './TariffEditModal'
export default function TariffManagment() {
const [currentPage, setCurrentPage] = useState(0);
const [isModalOpen, setIsModalOpen] = useState(false);
const [editingTariff, setEditingTariff] = useState<EditingTariff | null>(null);
const { data: tariffData, isLoading, isError, isFetching, error } = useTariffsData(currentPage);
const queryClient = useQueryClient();
useEffect(() => {
console.log(tariffData);
}, [tariffData])
useEffect(() => {
if (tariffData && tariffData.page !== currentPage) {
setCurrentPage(tariffData.page);
}
}, [tariffData, currentPage]);
const handlePageChange = (newPage: number) => {
if (tariffData && newPage >= 0 && newPage < tariffData.total_pages) {
setCurrentPage(newPage);
}
};
const handleEditClick = (tariff: any) => {
setEditingTariff({
id: tariff.id,
name: tariff.name,
type: tariff.type,
price: tariff.price,
tokens: tariff.tokens,
maxFilesCount: tariff.maxFilesCount,
diskSize: tariff.diskSize,
maxUsers: tariff.maxUsers,
description: tariff.description,
tariffTerm: tariff.tariffTerm
});
setIsModalOpen(true);
};
const formatPrice = (price: number) => {
return new Intl.NumberFormat('ru-RU').format(price);
};
const getDisplayName = (tariff: any) => {
if (tariff.name) {
return tariff.name.toUpperCase().replace(/_/g, ' ');
}
return tariff.type.replace(/_/g, ' ');
};
if (isLoading) {
return (
<div className="admin-content">
<div className="content-header">
<h3>Управление тарифными планами</h3>
</div>
<div className="content-body">
<div className="loading-spinner">Загрузка тарифов...</div>
</div>
</div>
);
}
if (isError) {
return (
<div className="admin-content">
<div className="content-header">
<h3>Управление тарифными планами</h3>
</div>
<div className="content-body">
<div className="error-message">
Ошибка загрузки тарифов: {error?.message || 'Неизвестная ошибка'}
</div>
</div>
</div>
);
}
return (
<div className="admin-content">
<div className="content-header">
<h3>Управление тарифными планами</h3>
<div className="content-header-actions">
<button className="btn btn-primary">
<span></span>
<span>Создать тариф</span>
</button>
</div>
</div>
<div className="content-body" id="plans-container">
<div className="stats-grid">
{tariffData?.tariffs?.map((tariff) => (
<div key={tariff.id} className="stat-card">
<div className="stat-card-header">
<span className="stat-card-title">{getDisplayName(tariff)}</span>
{tariff.tariffTerm && (
<span className="tariff-term-badge">{tariff.tariffTerm}</span>
)}
</div>
<div className="stat-card-value">{formatPrice(tariff.price)}</div>
<div className="stat-card-label">
{tariff.tokens > 0 && `${tariff.tokens.toLocaleString()} токенов`}
{tariff.diskSize > 0 && `${convertBytes(tariff.diskSize)}`}
{tariff.maxFilesCount > 0 && `${tariff.maxFilesCount} файлов`}
</div>
{tariff.description && (
<div className="stat-card-description">{tariff.description}</div>
)}
<div className="stat-card-footer">
<button
className="btn btn-outline btn-sm"
onClick={() => handleEditClick(tariff)}
>
Редактировать
</button>
</div>
</div>
))}
</div>
{/* Пагинация */}
{tariffData && tariffData.total_pages > 0 && (
<div className="tanstak-table-pagination">
<div className="pagination-info">
<span className="pagination-info-pages">
Страница{' '}
<strong>
{currentPage + 1} из {tariffData.total_pages}
</strong>
</span>
<span className="pagination-info-files">
| Показано {tariffData.tariffs?.length || 0} из {tariffData.total_elements}
</span>
</div>
<div className="pagination-controls">
<button
className="arrow"
onClick={() => handlePageChange(0)}
disabled={currentPage === 0 || isFetching}
>
<IconDoubleArrowLeft />
</button>
<button
className="arrow"
onClick={() => handlePageChange(currentPage - 1)}
disabled={currentPage === 0 || isFetching}
>
<IconArrowLeft />
</button>
<div className="pagination-controls-pages">
{(() => {
const totalPages = tariffData.total_pages;
if (!totalPages || totalPages === 0) return null;
const maxVisiblePages = 5;
const visiblePagesCount = Math.min(maxVisiblePages, totalPages);
let startPage = currentPage - Math.floor(maxVisiblePages / 2);
startPage = Math.max(0, Math.min(startPage, totalPages - visiblePagesCount));
return Array.from({ length: visiblePagesCount }, (_, i) => {
const pageIndex = startPage + i;
return (
<button
key={pageIndex}
className={currentPage === pageIndex ? 'current' : 'other'}
onClick={() => handlePageChange(pageIndex)}
disabled={isFetching}
>
{pageIndex + 1}
</button>
);
});
})()}
</div>
<button
className="arrow"
onClick={() => handlePageChange(currentPage + 1)}
disabled={currentPage === tariffData.total_pages - 1 || isFetching}
>
<IconArrowRight />
</button>
<button
className="arrow"
onClick={() => handlePageChange(tariffData.total_pages - 1)}
disabled={currentPage === tariffData.total_pages - 1 || isFetching}
>
<IconDoubleArrowRight />
</button>
</div>
</div>
)}
{isFetching && !isLoading && (
<div className="refetching-indicator">Обновление...</div>
)}
</div>
{/* Модальное окно редактирования тарифа */}
<ModalWindow state={isModalOpen} callBack={setIsModalOpen}>
{editingTariff && (
<TariffEditModal
tariff={editingTariff}
onClose={() => setIsModalOpen(false)}
onSuccess={() => {
queryClient.invalidateQueries({ queryKey: ['tariffsData'] });
setIsModalOpen(false);
}}
/>
)}
</ModalWindow>
</div>
)
}