update files date between modules
This commit is contained in:
@@ -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 (
|
||||
<div className="block-wrapper">
|
||||
<TanstakFilesTable/>
|
||||
<TanstakFilesTable fileType={fileType} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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 (
|
||||
<div className="protection-overview grow">
|
||||
<h3>{t('protecting-your-content')}</h3>
|
||||
@@ -32,33 +64,24 @@ export default function ProtectionOverview() {
|
||||
<div className={`protection-stats ${isOpen ? "opened" : ""}`}>
|
||||
|
||||
|
||||
{totalFiles ? (
|
||||
{filesInfo?.totalCount ? (
|
||||
<>
|
||||
<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">
|
||||
<div className="protection-stat-row">
|
||||
<div className="protection-stat-value">0</div>
|
||||
<div className="protection-stat-label">{t('check')}</div>
|
||||
</div>
|
||||
<div className="protection-stat-row">
|
||||
<div className="protection-stat-value">0</div>
|
||||
<div className="protection-stat-label">{t('violations')}</div>
|
||||
</div>
|
||||
</div> */}
|
||||
<div className="protection-stat total-checks">
|
||||
<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>
|
||||
|
||||
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="protection-stat total-files relative">
|
||||
<div className="protection-stat total-files add-content relative">
|
||||
<div className="protection-stat-label">
|
||||
{t('there-are-no-files-yet')}
|
||||
</div>
|
||||
@@ -96,14 +119,14 @@ export default function ProtectionOverview() {
|
||||
</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>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{!!totalFiles && (
|
||||
{!!filesInfo?.totalCount && (
|
||||
<button
|
||||
className="protection-overview-switch cursor-pointer"
|
||||
onClick={() => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user