2025-12-16 15:03:32 +07:00
|
|
|
'use client'
|
|
|
|
|
|
|
|
|
|
import { useTranslations } from 'next-intl';
|
2025-12-29 16:08:38 +07:00
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
|
|
import { getUserFilesData } from '@/app/actions/fileEntity';
|
|
|
|
|
|
|
|
|
|
type FilesInfo = {
|
|
|
|
|
totalSize: string;
|
|
|
|
|
totalCount: number;
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-16 15:03:32 +07:00
|
|
|
|
2025-12-05 16:19:13 +07:00
|
|
|
export default function ProtectionSummary() {
|
2025-12-16 15:03:32 +07:00
|
|
|
const t = useTranslations('Global');
|
|
|
|
|
|
2025-12-29 16:08:38 +07:00
|
|
|
const {
|
|
|
|
|
data: filesInfo,
|
|
|
|
|
isLoading,
|
|
|
|
|
isError,
|
|
|
|
|
error,
|
|
|
|
|
} = useQuery<{
|
|
|
|
|
formattedTotalSize: string,
|
|
|
|
|
totalCount: number
|
|
|
|
|
}, Error, FilesInfo>({
|
|
|
|
|
queryKey: ['userFilesData'],
|
|
|
|
|
queryFn: getUserFilesData,
|
|
|
|
|
select: (data): FilesInfo => {
|
|
|
|
|
if (!data) {
|
|
|
|
|
return {
|
|
|
|
|
totalSize: '0',
|
|
|
|
|
totalCount: 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
totalSize: data.formattedTotalSize,
|
|
|
|
|
totalCount: (data.totalCount)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2025-12-05 16:19:13 +07:00
|
|
|
return (
|
2025-12-28 11:34:22 +07:00
|
|
|
<div className="protection-overview grow">
|
2025-12-16 15:03:32 +07:00
|
|
|
<h3>{t('protecting-your-content')}</h3>
|
|
|
|
|
<p>{t('current-status-of')}</p>
|
2025-12-28 11:34:22 +07:00
|
|
|
<div className="protection-stats">
|
2025-12-16 15:03:32 +07:00
|
|
|
<div className="protection-stat total-files">
|
2025-12-29 16:08:38 +07:00
|
|
|
<div className="protection-stat-value">{filesInfo?.totalCount ? filesInfo?.totalCount : 0}</div>
|
2025-12-16 15:03:32 +07:00
|
|
|
<div className="protection-stat-label">{t('total-files')}</div>
|
2025-12-05 16:19:13 +07:00
|
|
|
</div>
|
2025-12-16 15:03:32 +07:00
|
|
|
<div className="protection-stat total-checks">
|
2025-12-28 11:34:22 +07:00
|
|
|
<div className="protection-stat-value">0</div>
|
|
|
|
|
<div className="protection-stat-label">{t('check')}</div>
|
|
|
|
|
<div className="protection-stat-value">0</div>
|
|
|
|
|
<div className="protection-stat-label">{t('violations')}</div>
|
2025-12-05 16:19:13 +07:00
|
|
|
</div>
|
2025-12-28 11:34:22 +07:00
|
|
|
<div className="protection-stat total-usage">
|
2025-12-29 16:08:38 +07:00
|
|
|
<div className="protection-stat-value">{filesInfo?.totalSize ? filesInfo?.totalSize : 0} / 0</div>
|
2025-12-28 11:34:22 +07:00
|
|
|
<div className="protection-stat-label">
|
|
|
|
|
{t('disk-space-used')}
|
2025-12-16 15:03:32 +07:00
|
|
|
</div>
|
2025-12-28 11:34:22 +07:00
|
|
|
</div>
|
2025-12-05 16:19:13 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|