diff --git a/src/app/components/tanstakTable.tsx b/src/app/components/tanstakTable.tsx index a334407..d104cce 100644 --- a/src/app/components/tanstakTable.tsx +++ b/src/app/components/tanstakTable.tsx @@ -31,6 +31,7 @@ type FileItem = { size?: number | undefined; uploadDate?: number; status?: string; + protectStatus: string; _original?: ApiFile; }; @@ -42,6 +43,7 @@ type ApiFile = { fileSize: number; updatedAt: string; status: string; + protectStatus: string; }; type ApiResponse = { @@ -143,6 +145,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) { size: item.fileSize, uploadDate: newDate, status: item.status, + protectStatus: item.protectStatus, _original: item }; }); @@ -207,7 +210,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) { {cutFileName(row.original.fileName)}
- {cutFileExtension(row.original.fileName)} {row.original?.status} + {cutFileExtension(row.original.fileName)} {t(row.original?.protectStatus)} @@ -364,7 +367,7 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) { return (
- {t('status')} + {row.original.status}
) diff --git a/src/app/styles/pages-styles.scss b/src/app/styles/pages-styles.scss index 0f9b21e..f478e23 100644 --- a/src/app/styles/pages-styles.scss +++ b/src/app/styles/pages-styles.scss @@ -727,7 +727,8 @@ .table-item-status { padding: 2px 10px; border-radius: 15px; - background-color: v.$b-color-2; + background-color: #dcfce7; + color: #166534; } .actions { diff --git a/src/app/ui/dashboard/new/dashboard-files-info.tsx b/src/app/ui/dashboard/new/dashboard-files-info.tsx index cdee67a..3bb79ab 100644 --- a/src/app/ui/dashboard/new/dashboard-files-info.tsx +++ b/src/app/ui/dashboard/new/dashboard-files-info.tsx @@ -32,8 +32,8 @@ export default function DashboardFilesInfo() { {filesInfo?.images_size ? convertBytes(filesInfo?.images_size) : 0}
- {t('checks')} - {filesInfo?.images_check ? filesInfo?.images_check : 0} + {t('PROTECTED')} + {filesInfo?.protected_image_files_count ? filesInfo?.protected_image_files_count : 0}
{t('violations')} @@ -54,8 +54,8 @@ export default function DashboardFilesInfo() { {filesInfo?.videos_size ? convertBytes(filesInfo?.videos_size) : 0}
- {t('checks')} - {filesInfo?.videos_check ? filesInfo?.videos_check : 0} + {t('PROTECTED')} + {filesInfo?.protected_video_files_count ? filesInfo?.protected_video_files_count : 0}
{t('violations')} @@ -76,8 +76,8 @@ export default function DashboardFilesInfo() { {filesInfo?.audios_size ? convertBytes(filesInfo?.audios_size) : 0}
- {t('checks')} - {filesInfo?.audios_check ? filesInfo?.audios_check : 0} + {t('PROTECTED')} + {filesInfo?.protected_audio_files_count ? filesInfo?.protected_audio_files_count : 0}
{t('violations')} @@ -98,7 +98,7 @@ export default function DashboardFilesInfo() { {filesInfo?.documents_check ? convertBytes(filesInfo?.documents_check) : 0}
- {t('checks')} + {t('PROTECTED')} {filesInfo?.documents_check ? filesInfo?.documents_check : 0}
diff --git a/src/app/ui/dashboard/new/dashboard-user-stats.tsx b/src/app/ui/dashboard/new/dashboard-user-stats.tsx index f02a15f..cfdae78 100644 --- a/src/app/ui/dashboard/new/dashboard-user-stats.tsx +++ b/src/app/ui/dashboard/new/dashboard-user-stats.tsx @@ -23,7 +23,7 @@ export default function DashboardUserStats() {
ЗАЩИЩЁННЫЕ ФАЙЛЫ
-
0
+
{filesInfo?.protected_files_count ? filesInfo?.protected_files_count : 0}
Файлов под защитой
🛡️
diff --git a/src/app/ui/dashboard/new/dashborad-limits-section.tsx b/src/app/ui/dashboard/new/dashborad-limits-section.tsx index 08465d8..ed7d41d 100644 --- a/src/app/ui/dashboard/new/dashborad-limits-section.tsx +++ b/src/app/ui/dashboard/new/dashborad-limits-section.tsx @@ -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 (

💰 Использование лимитов

@@ -9,10 +29,10 @@ export default function DahboardLimitsSection() { 🔍 Проверки
-
520 / 10,000
+
{filesInfo?.all_files_check ? filesInfo?.all_files_check : 0} / 10,000
-
+
5% @@ -25,13 +45,13 @@ export default function DahboardLimitsSection() { 💾 Хранилище
-
790.2 / 1,024 МБ
+
{filesInfo?.all_files_size ? convertBytes(filesInfo?.all_files_size) : 0} / 1,024 МБ
-
+
- 77% + {getProcents(filesInfo?.all_files_size, 1000000000)}%
@@ -40,13 +60,13 @@ export default function DahboardLimitsSection() { 📁 Файлы
-
386 / 500
+
{filesInfo?.all_files_quantity ? filesInfo?.all_files_quantity : 0} / 500
-
+
- 77% + {getProcents(filesInfo?.all_files_quantity, 500)}%
diff --git a/src/app/ui/marking-page/new/protection-statistic.tsx b/src/app/ui/marking-page/new/protection-statistic.tsx index e00d297..ee8f722 100644 --- a/src/app/ui/marking-page/new/protection-statistic.tsx +++ b/src/app/ui/marking-page/new/protection-statistic.tsx @@ -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 (
-
0
+
+ {filesInfo?.totalProtected ? filesInfo.totalProtected : 0} +
{t(`${fileType}-protected`)}
diff --git a/src/app/ui/my-content/new/my-content-stats-overview.tsx b/src/app/ui/my-content/new/my-content-stats-overview.tsx index 277567a..52bb1eb 100644 --- a/src/app/ui/my-content/new/my-content-stats-overview.tsx +++ b/src/app/ui/my-content/new/my-content-stats-overview.tsx @@ -33,7 +33,7 @@ export default function MyContentStatsOverview() {
🛡
+0%
-
0
+
{filesInfo?.protected_files_count}
Защищено файлов
diff --git a/src/i18n/messages/en.json b/src/i18n/messages/en.json index 9199f79..d5a6b12 100644 --- a/src/i18n/messages/en.json +++ b/src/i18n/messages/en.json @@ -195,7 +195,12 @@ "new": "new", "in-progress": "In progress", "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": { "and": "and", diff --git a/src/i18n/messages/ru.json b/src/i18n/messages/ru.json index 7ce8d55..5b93fbb 100644 --- a/src/i18n/messages/ru.json +++ b/src/i18n/messages/ru.json @@ -195,7 +195,12 @@ "new": "Новые", "in-progress": "В работе", "it-decided": "Решено", - "API": "API" + "API": "API", + "NOT_PROTECTED": "Не защищено", + "PROCESSING": "Обработка", + "PROTECTED": "Защищено", + "FAILED": "Ошибка", + "FAILED_SAVE": "Сохранение не удалось" }, "Login-register-form": { "and": "и",