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