add protected info

This commit is contained in:
smanylov
2026-01-26 16:09:39 +07:00
parent 2be8f81a5b
commit 6ef23862e1
9 changed files with 73 additions and 30 deletions
+5 -2
View File
@@ -31,6 +31,7 @@ type FileItem = {
size?: number | undefined;
uploadDate?: number;
status?: string;
protectStatus: string;
_original?: ApiFile;
};
@@ -42,6 +43,7 @@ type ApiFile = {
fileSize: number;
updatedAt: string;
status: string;
protectStatus: string;
};
type ApiResponse = {
@@ -143,6 +145,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
size: item.fileSize,
uploadDate: newDate,
status: item.status,
protectStatus: item.protectStatus,
_original: item
};
});
@@ -207,7 +210,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
{cutFileName(row.original.fileName)}
</span>
<br />
<span className="table-item-extension">{cutFileExtension(row.original.fileName)}</span> <span className="table-item-protected">{row.original?.status}</span>
<span className="table-item-extension">{cutFileExtension(row.original.fileName)}</span> <span className="table-item-protected">{t(row.original?.protectStatus)}</span>
</div>
</div>
</div>
@@ -364,7 +367,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
return (
<div className="text-center font-semibold table-item">
<span className="table-item-status">
{t('status')}
{row.original.status}
</span>
</div>
)
+2 -1
View File
@@ -727,7 +727,8 @@
.table-item-status {
padding: 2px 10px;
border-radius: 15px;
background-color: v.$b-color-2;
background-color: #dcfce7;
color: #166534;
}
.actions {
@@ -32,8 +32,8 @@ export default function DashboardFilesInfo() {
<span className="type-card-stat-value">{filesInfo?.images_size ? convertBytes(filesInfo?.images_size) : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('checks')}</span>
<span className="type-card-stat-value">{filesInfo?.images_check ? filesInfo?.images_check : 0}</span>
<span className="type-card-stat-label">{t('PROTECTED')}</span>
<span className="type-card-stat-value">{filesInfo?.protected_image_files_count ? filesInfo?.protected_image_files_count : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('violations')}</span>
@@ -54,8 +54,8 @@ export default function DashboardFilesInfo() {
<span className="type-card-stat-value">{filesInfo?.videos_size ? convertBytes(filesInfo?.videos_size) : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('checks')}</span>
<span className="type-card-stat-value">{filesInfo?.videos_check ? filesInfo?.videos_check : 0}</span>
<span className="type-card-stat-label">{t('PROTECTED')}</span>
<span className="type-card-stat-value">{filesInfo?.protected_video_files_count ? filesInfo?.protected_video_files_count : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('violations')}</span>
@@ -76,8 +76,8 @@ export default function DashboardFilesInfo() {
<span className="type-card-stat-value">{filesInfo?.audios_size ? convertBytes(filesInfo?.audios_size) : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('checks')}</span>
<span className="type-card-stat-value">{filesInfo?.audios_check ? filesInfo?.audios_check : 0}</span>
<span className="type-card-stat-label">{t('PROTECTED')}</span>
<span className="type-card-stat-value">{filesInfo?.protected_audio_files_count ? filesInfo?.protected_audio_files_count : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('violations')}</span>
@@ -98,7 +98,7 @@ export default function DashboardFilesInfo() {
<span className="type-card-stat-value">{filesInfo?.documents_check ? convertBytes(filesInfo?.documents_check) : 0}</span>
</div>
<div className="type-card-stat-row">
<span className="type-card-stat-label">{t('checks')}</span>
<span className="type-card-stat-label">{t('PROTECTED')}</span>
<span className="type-card-stat-value">{filesInfo?.documents_check ? filesInfo?.documents_check : 0}</span>
</div>
<div className="type-card-stat-row">
@@ -23,7 +23,7 @@ export default function DashboardUserStats() {
<div className="stat-card projects">
<div className="stat-type">ЗАЩИЩЁННЫЕ ФАЙЛЫ</div>
<div className="stat-value">0</div>
<div className="stat-value">{filesInfo?.protected_files_count ? filesInfo?.protected_files_count : 0}</div>
<div className="stat-label">Файлов под защитой</div>
<div className="stat-icon">🛡</div>
</div>
@@ -1,4 +1,24 @@
'use client'
import { useQuery } from '@tanstack/react-query';
import { getUserFilesInfo } from '@/app/actions/action';
import { convertBytes } from '@/app/lib/convertBytes';
export default function DahboardLimitsSection() {
const {
data: filesInfo,
isLoading,
isError,
error,
} = useQuery({
queryKey: ['userFilesInfo'],
queryFn: getUserFilesInfo,
});
function getProcents(currentNumber: number, totalNumber: number) {
return Math.round(currentNumber / (totalNumber / 100));
}
return (
<div className="dashboard-limits-section">
<h3 className="section-title">💰 Использование лимитов</h3>
@@ -9,10 +29,10 @@ export default function DahboardLimitsSection() {
<span>🔍</span>
<span>Проверки</span>
</div>
<div className="limit-value">520 / 10,000</div>
<div className="limit-value">{filesInfo?.all_files_check ? filesInfo?.all_files_check : 0} / 10,000</div>
</div>
<div className="progress-bar-container">
<div className="progress-bar low" style={{width: '44%'}}></div>
<div className="progress-bar low" style={{ width: '0%' }}></div>
</div>
<div className="progress-bar-value">
5%
@@ -25,13 +45,13 @@ export default function DahboardLimitsSection() {
<span>💾</span>
<span>Хранилище</span>
</div>
<div className="limit-value">790.2 / 1,024 МБ</div>
<div className="limit-value">{filesInfo?.all_files_size ? convertBytes(filesInfo?.all_files_size) : 0} / 1,024 МБ</div>
</div>
<div className="progress-bar-container">
<div className="progress-bar medium" style={{width: '77%'}}></div>
<div className="progress-bar medium" style={{ width: `${getProcents(filesInfo?.all_files_size, 1000000000 )}%` }}></div>
</div>
<div className="progress-bar-value">
77%
{getProcents(filesInfo?.all_files_size, 1000000000)}%
</div>
</div>
<div className="limit-item">
@@ -40,13 +60,13 @@ export default function DahboardLimitsSection() {
<span>📁</span>
<span>Файлы</span>
</div>
<div className="limit-value">386 / 500</div>
<div className="limit-value">{filesInfo?.all_files_quantity ? filesInfo?.all_files_quantity : 0} / 500</div>
</div>
<div className="progress-bar-container">
<div className="progress-bar medium" style={{width: '77%'}}></div>
<div className="progress-bar medium" style={{ width: `${getProcents(filesInfo?.all_files_quantity, 500)}%` }}></div>
</div>
<div className="progress-bar-value">
77%
{getProcents(filesInfo?.all_files_quantity, 500)}%
</div>
</div>
</div>
@@ -8,32 +8,37 @@ import { convertBytes } from '@/app/lib/convertBytes';
type FilesInfo = {
totalSize: number;
totalCount: number;
totalProtected: number;
};
export default function ProtectionStatistic({ fileType }: { fileType: string }) {
const t = useTranslations('Global');
const getFileTypeFields = (fileType: string): { totalSize: string, totalCount: string } => {
const getFileTypeFields = (fileType: string): { totalSize: string, totalCount: string, totalProtected: string } => {
switch (fileType) {
case 'image':
return {
totalSize: 'images_size',
totalCount: 'images_quantity'
totalCount: 'images_quantity',
totalProtected: 'protected_image_files_count'
};
case 'video':
return {
totalSize: 'videos_size',
totalCount: 'videos_quantity'
totalCount: 'videos_quantity',
totalProtected: 'protected_video_files_count'
};
case 'audio':
return {
totalSize: 'audios_size',
totalCount: 'audios_quantity'
totalCount: 'audios_quantity',
totalProtected: 'protected_audio_files_count'
};
default:
return {
totalSize: 'all_files_size',
totalCount: 'all_files_quantity'
totalCount: 'all_files_quantity',
totalProtected: 'protected_files_count'
};
}
};
@@ -53,7 +58,8 @@ export default function ProtectionStatistic({ fileType }: { fileType: string })
if (!data) {
return {
totalSize: 0,
totalCount: 0
totalCount: 0,
totalProtected: 0
}
}
@@ -61,7 +67,8 @@ export default function ProtectionStatistic({ fileType }: { fileType: string })
return {
totalSize: data[fields.totalSize as keyof typeof data],
totalCount: data[fields.totalCount as keyof typeof data]
totalCount: data[fields.totalCount as keyof typeof data],
totalProtected: data[fields.totalProtected as keyof typeof data]
}
}
});
@@ -69,7 +76,9 @@ export default function ProtectionStatistic({ fileType }: { fileType: string })
return (
<div className="protection-statistic">
<div className="protection-statistic-stat-card">
<div className="protection-statistic-stat-number">0</div>
<div className="protection-statistic-stat-number">
{filesInfo?.totalProtected ? filesInfo.totalProtected : 0}
</div>
<div className="protection-statistic-stat-label">{t(`${fileType}-protected`)}</div>
</div>
<div className="protection-statistic-stat-card">
@@ -33,7 +33,7 @@ export default function MyContentStatsOverview() {
<div className="stat-icon">🛡</div>
<div className="stat-trend">+0%</div>
</div>
<div className="stat-value">0</div>
<div className="stat-value">{filesInfo?.protected_files_count}</div>
<div className="stat-label">Защищено файлов</div>
</div>
+6 -1
View File
@@ -195,7 +195,12 @@
"new": "new",
"in-progress": "In progress",
"it-decided": "It's decided",
"API": "API"
"API": "API",
"NOT_PROTECTED": "Not protected",
"PROCESSING": "Processing",
"PROTECTED": "Protected",
"FAILED": "Failed",
"FAILED_SAVE": "Failed save"
},
"Login-register-form": {
"and": "and",
+6 -1
View File
@@ -195,7 +195,12 @@
"new": "Новые",
"in-progress": "В работе",
"it-decided": "Решено",
"API": "API"
"API": "API",
"NOT_PROTECTED": "Не защищено",
"PROCESSING": "Обработка",
"PROTECTED": "Защищено",
"FAILED": "Ошибка",
"FAILED_SAVE": "Сохранение не удалось"
},
"Login-register-form": {
"and": "и",