update files date between modules

This commit is contained in:
smanylov
2025-12-29 16:08:38 +07:00
parent 198a01d026
commit bd0169bd61
10 changed files with 153 additions and 64 deletions
+37 -2
View File
@@ -1,17 +1,52 @@
'use client'
import { useTranslations } from 'next-intl';
import { useQuery } from '@tanstack/react-query';
import { getUserFilesData } from '@/app/actions/fileEntity';
type FilesInfo = {
totalSize: string;
totalCount: number;
};
export default function ProtectionSummary() {
const t = useTranslations('Global');
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)
}
},
});
return (
<div className="protection-overview grow">
<h3>{t('protecting-your-content')}</h3>
<p>{t('current-status-of')}</p>
<div className="protection-stats">
<div className="protection-stat total-files">
<div className="protection-stat-value">0</div>
<div className="protection-stat-value">{filesInfo?.totalCount ? filesInfo?.totalCount : 0}</div>
<div className="protection-stat-label">{t('total-files')}</div>
</div>
<div className="protection-stat total-checks">
@@ -21,7 +56,7 @@ export default function ProtectionSummary() {
<div className="protection-stat-label">{t('violations')}</div>
</div>
<div className="protection-stat total-usage">
<div className="protection-stat-value">0 / 0</div>
<div className="protection-stat-value">{filesInfo?.totalSize ? filesInfo?.totalSize : 0} / 0</div>
<div className="protection-stat-label">
{t('disk-space-used')}
</div>