diff --git a/src/app/lib/prefetch-queries.ts b/src/app/lib/prefetch-queries.ts
index 20dfc66..97636f3 100644
--- a/src/app/lib/prefetch-queries.ts
+++ b/src/app/lib/prefetch-queries.ts
@@ -10,7 +10,10 @@ export async function prefetchLayoutQueries(queryClient: QueryClient) {
}),
queryClient.prefetchQuery({
queryKey: ['userFilesData'],
- queryFn: () => getUserFilesData(),
+ queryFn: () => {
+ console.log('make prefetch userFilesData');
+ return getUserFilesData();
+ },
staleTime: 30 * 1000
}),
]);
diff --git a/src/app/styles/pages-styles.scss b/src/app/styles/pages-styles.scss
index 7c2c351..fc07a76 100644
--- a/src/app/styles/pages-styles.scss
+++ b/src/app/styles/pages-styles.scss
@@ -95,6 +95,15 @@
}
}
+ &.total-files.add-content {
+ display: flex;
+ justify-content: center;
+
+ .protection-stat-value {
+ margin-bottom: 0;
+ }
+ }
+
&-row {
display: flex;
align-items: center;
@@ -110,6 +119,13 @@
&.btn {
user-select: none;
+ transition: all 0.3s ease-in;
+ padding: 5px;
+ margin-top: 10px;
+
+ &:hover {
+ background: v.$shadow-1;
+ }
}
}
diff --git a/src/app/ui/dashboard/files-table.tsx b/src/app/ui/dashboard/files-table.tsx
index e0b6de3..c1c82f6 100644
--- a/src/app/ui/dashboard/files-table.tsx
+++ b/src/app/ui/dashboard/files-table.tsx
@@ -1,8 +1,13 @@
import TanstakFilesTable from '@/app/components/tanstakTable';
-export default function FilesTable() {
+
+type FilesTable = {
+ fileType: string
+}
+
+export default function FilesTable({ fileType }: FilesTable) {
return (
-
+
)
}
\ No newline at end of file
diff --git a/src/app/ui/dashboard/protection-overview.tsx b/src/app/ui/dashboard/protection-overview.tsx
index 2fdc001..1e428b6 100644
--- a/src/app/ui/dashboard/protection-overview.tsx
+++ b/src/app/ui/dashboard/protection-overview.tsx
@@ -5,6 +5,8 @@ import { PieChartComponent } from '@/app/components/PieChartComponent';
import { useTranslations } from 'next-intl';
import Link from 'next/link';
import { useClickOutside } from '@/app/hooks/useClickOutside';
+import { useQuery } from '@tanstack/react-query';
+import { getUserFilesData } from '@/app/actions/fileEntity';
const data = [
@@ -13,8 +15,12 @@ const data = [
{ name: 'audios', value: 25, color: '#1971c2' },
];
-/* нужно что бы включать выключать кнопки добавления маркировок */
-const totalFiles = 1;
+
+type FilesInfo = {
+ totalSize: string;
+ totalCount: number;
+};
+
export default function ProtectionOverview() {
const [isOpen, setIsOpen] = useState(false);
@@ -25,6 +31,32 @@ export default function ProtectionOverview() {
setOpenDropDownList(false)
});
+ 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 (
{t('protecting-your-content')}
@@ -32,33 +64,24 @@ export default function ProtectionOverview() {
- {totalFiles ? (
+ {filesInfo?.totalCount ? (
<>
-
0
+
+ {filesInfo?.totalCount ? filesInfo?.totalCount : 0}
+
{t('total-files')}
-
- {/*
-
-
-
0
-
{t('violations')}
-
-
*/}
0
{t('check')}
0
{t('violations')}
-
+
>
) : (
-
+
{t('there-are-no-files-yet')}
@@ -96,14 +119,14 @@ export default function ProtectionOverview() {
) : (
-
0 / 0
+
{filesInfo?.totalSize ? filesInfo?.totalSize : 0} / 0
{t('disk-space-used')}
)}
- {!!totalFiles && (
+ {!!filesInfo?.totalCount && (