add protected info
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user