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; size?: number | undefined;
uploadDate?: number; uploadDate?: number;
status?: string; status?: string;
protectStatus: string;
_original?: ApiFile; _original?: ApiFile;
}; };
@@ -42,6 +43,7 @@ type ApiFile = {
fileSize: number; fileSize: number;
updatedAt: string; updatedAt: string;
status: string; status: string;
protectStatus: string;
}; };
type ApiResponse = { type ApiResponse = {
@@ -143,6 +145,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
size: item.fileSize, size: item.fileSize,
uploadDate: newDate, uploadDate: newDate,
status: item.status, status: item.status,
protectStatus: item.protectStatus,
_original: item _original: item
}; };
}); });
@@ -207,7 +210,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
{cutFileName(row.original.fileName)} {cutFileName(row.original.fileName)}
</span> </span>
<br /> <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> </div>
</div> </div>
@@ -364,7 +367,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) {
return ( return (
<div className="text-center font-semibold table-item"> <div className="text-center font-semibold table-item">
<span className="table-item-status"> <span className="table-item-status">
{t('status')} {row.original.status}
</span> </span>
</div> </div>
) )
+2 -1
View File
@@ -727,7 +727,8 @@
.table-item-status { .table-item-status {
padding: 2px 10px; padding: 2px 10px;
border-radius: 15px; border-radius: 15px;
background-color: v.$b-color-2; background-color: #dcfce7;
color: #166534;
} }
.actions { .actions {
@@ -32,8 +32,8 @@ export default function DashboardFilesInfo() {
<span className="type-card-stat-value">{filesInfo?.images_size ? convertBytes(filesInfo?.images_size) : 0}</span> <span className="type-card-stat-value">{filesInfo?.images_size ? convertBytes(filesInfo?.images_size) : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <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?.images_check ? filesInfo?.images_check : 0}</span> <span className="type-card-stat-value">{filesInfo?.protected_image_files_count ? filesInfo?.protected_image_files_count : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <div className="type-card-stat-row">
<span className="type-card-stat-label">{t('violations')}</span> <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> <span className="type-card-stat-value">{filesInfo?.videos_size ? convertBytes(filesInfo?.videos_size) : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <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?.videos_check ? filesInfo?.videos_check : 0}</span> <span className="type-card-stat-value">{filesInfo?.protected_video_files_count ? filesInfo?.protected_video_files_count : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <div className="type-card-stat-row">
<span className="type-card-stat-label">{t('violations')}</span> <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> <span className="type-card-stat-value">{filesInfo?.audios_size ? convertBytes(filesInfo?.audios_size) : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <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?.audios_check ? filesInfo?.audios_check : 0}</span> <span className="type-card-stat-value">{filesInfo?.protected_audio_files_count ? filesInfo?.protected_audio_files_count : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <div className="type-card-stat-row">
<span className="type-card-stat-label">{t('violations')}</span> <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> <span className="type-card-stat-value">{filesInfo?.documents_check ? convertBytes(filesInfo?.documents_check) : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <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> <span className="type-card-stat-value">{filesInfo?.documents_check ? filesInfo?.documents_check : 0}</span>
</div> </div>
<div className="type-card-stat-row"> <div className="type-card-stat-row">
@@ -23,7 +23,7 @@ export default function DashboardUserStats() {
<div className="stat-card projects"> <div className="stat-card projects">
<div className="stat-type">ЗАЩИЩЁННЫЕ ФАЙЛЫ</div> <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-label">Файлов под защитой</div>
<div className="stat-icon">🛡</div> <div className="stat-icon">🛡</div>
</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() { 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 ( return (
<div className="dashboard-limits-section"> <div className="dashboard-limits-section">
<h3 className="section-title">💰 Использование лимитов</h3> <h3 className="section-title">💰 Использование лимитов</h3>
@@ -9,10 +29,10 @@ export default function DahboardLimitsSection() {
<span>🔍</span> <span>🔍</span>
<span>Проверки</span> <span>Проверки</span>
</div> </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>
<div className="progress-bar-container"> <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>
<div className="progress-bar-value"> <div className="progress-bar-value">
5% 5%
@@ -25,13 +45,13 @@ export default function DahboardLimitsSection() {
<span>💾</span> <span>💾</span>
<span>Хранилище</span> <span>Хранилище</span>
</div> </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>
<div className="progress-bar-container"> <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>
<div className="progress-bar-value"> <div className="progress-bar-value">
77% {getProcents(filesInfo?.all_files_size, 1000000000)}%
</div> </div>
</div> </div>
<div className="limit-item"> <div className="limit-item">
@@ -40,13 +60,13 @@ export default function DahboardLimitsSection() {
<span>📁</span> <span>📁</span>
<span>Файлы</span> <span>Файлы</span>
</div> </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>
<div className="progress-bar-container"> <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>
<div className="progress-bar-value"> <div className="progress-bar-value">
77% {getProcents(filesInfo?.all_files_quantity, 500)}%
</div> </div>
</div> </div>
</div> </div>
@@ -8,32 +8,37 @@ import { convertBytes } from '@/app/lib/convertBytes';
type FilesInfo = { type FilesInfo = {
totalSize: number; totalSize: number;
totalCount: number; totalCount: number;
totalProtected: number;
}; };
export default function ProtectionStatistic({ fileType }: { fileType: string }) { export default function ProtectionStatistic({ fileType }: { fileType: string }) {
const t = useTranslations('Global'); const t = useTranslations('Global');
const getFileTypeFields = (fileType: string): { totalSize: string, totalCount: string } => { const getFileTypeFields = (fileType: string): { totalSize: string, totalCount: string, totalProtected: string } => {
switch (fileType) { switch (fileType) {
case 'image': case 'image':
return { return {
totalSize: 'images_size', totalSize: 'images_size',
totalCount: 'images_quantity' totalCount: 'images_quantity',
totalProtected: 'protected_image_files_count'
}; };
case 'video': case 'video':
return { return {
totalSize: 'videos_size', totalSize: 'videos_size',
totalCount: 'videos_quantity' totalCount: 'videos_quantity',
totalProtected: 'protected_video_files_count'
}; };
case 'audio': case 'audio':
return { return {
totalSize: 'audios_size', totalSize: 'audios_size',
totalCount: 'audios_quantity' totalCount: 'audios_quantity',
totalProtected: 'protected_audio_files_count'
}; };
default: default:
return { return {
totalSize: 'all_files_size', 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) { if (!data) {
return { return {
totalSize: 0, totalSize: 0,
totalCount: 0 totalCount: 0,
totalProtected: 0
} }
} }
@@ -61,7 +67,8 @@ export default function ProtectionStatistic({ fileType }: { fileType: string })
return { return {
totalSize: data[fields.totalSize as keyof typeof data], 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 ( return (
<div className="protection-statistic"> <div className="protection-statistic">
<div className="protection-statistic-stat-card"> <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 className="protection-statistic-stat-label">{t(`${fileType}-protected`)}</div>
</div> </div>
<div className="protection-statistic-stat-card"> <div className="protection-statistic-stat-card">
@@ -33,7 +33,7 @@ export default function MyContentStatsOverview() {
<div className="stat-icon">🛡</div> <div className="stat-icon">🛡</div>
<div className="stat-trend">+0%</div> <div className="stat-trend">+0%</div>
</div> </div>
<div className="stat-value">0</div> <div className="stat-value">{filesInfo?.protected_files_count}</div>
<div className="stat-label">Защищено файлов</div> <div className="stat-label">Защищено файлов</div>
</div> </div>
+6 -1
View File
@@ -195,7 +195,12 @@
"new": "new", "new": "new",
"in-progress": "In progress", "in-progress": "In progress",
"it-decided": "It's decided", "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": { "Login-register-form": {
"and": "and", "and": "and",
+6 -1
View File
@@ -195,7 +195,12 @@
"new": "Новые", "new": "Новые",
"in-progress": "В работе", "in-progress": "В работе",
"it-decided": "Решено", "it-decided": "Решено",
"API": "API" "API": "API",
"NOT_PROTECTED": "Не защищено",
"PROCESSING": "Обработка",
"PROTECTED": "Защищено",
"FAILED": "Ошибка",
"FAILED_SAVE": "Сохранение не удалось"
}, },
"Login-register-form": { "Login-register-form": {
"and": "и", "and": "и",