From e82d96a44ca7d3d75d2a71fb803ff8155e82feb1 Mon Sep 17 00:00:00 2001 From: smanylov Date: Thu, 25 Dec 2025 15:31:24 +0700 Subject: [PATCH] edit get files extensions query --- src/app/[locale]/pages/marking-audio/page.tsx | 11 +++++------ src/app/[locale]/pages/marking-photo/page.tsx | 13 ++++--------- src/app/[locale]/pages/marking-video/page.tsx | 12 +++++------- src/app/actions/file-upload.ts | 3 +-- src/app/components/upload-section-file.tsx | 12 ++++++------ src/app/providers/getQueryServer.tsx | 6 ++++-- 6 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/app/[locale]/pages/marking-audio/page.tsx b/src/app/[locale]/pages/marking-audio/page.tsx index 3683a77..f6b07a7 100644 --- a/src/app/[locale]/pages/marking-audio/page.tsx +++ b/src/app/[locale]/pages/marking-audio/page.tsx @@ -2,18 +2,17 @@ import ProtectionSummary from '@/app/ui/marking-page/protection-summary'; import FilesTable from '@/app/ui/dashboard/files-table'; import PageTitle from '@/app/ui/page-title'; import UploadSectionFile from '@/app/components/upload-section-file'; +import { getAllowedFilesExtensions } from '@/app/actions/file-upload'; -const ALLOWED_EXTENSIONS: string[] = ['jpg', 'jpeg', 'png', 'gif', 'bmp']; -const FILE_TYPE = "AUDIO" -const MAX_SIZE = 1048576000; - -export default function Page() { +export default async function Page() { + const FILE_TYPE = "audio"; + const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE); return (
- + {/* */}
diff --git a/src/app/[locale]/pages/marking-photo/page.tsx b/src/app/[locale]/pages/marking-photo/page.tsx index 39f5b3c..565df92 100644 --- a/src/app/[locale]/pages/marking-photo/page.tsx +++ b/src/app/[locale]/pages/marking-photo/page.tsx @@ -1,23 +1,18 @@ import ProtectionSummary from '@/app/ui/marking-page/protection-summary'; +import FilesTable from '@/app/ui/dashboard/files-table'; import PageTitle from '@/app/ui/page-title'; import UploadSectionFile from '@/app/components/upload-section-file'; -import FilesTable from '@/app/ui/dashboard/files-table'; import { getAllowedFilesExtensions } from '@/app/actions/file-upload'; -const ALLOWED_EXTENSIONS: string[] = ['jpg', 'jpeg', 'png', 'gif', 'bmp']; -const FILE_TYPE = "IMAGE" -const MAX_SIZE = 1048576000; - export default async function Page() { - /* const allowedFilesExtensions = await getAllowedFilesExtensions(FILE_TYPE); - console.log(allowedFilesExtensions); - console.log(allowedFilesExtensions); */ + const FILE_TYPE = "image"; + const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE); return (
- + {/* */} {/* */} diff --git a/src/app/[locale]/pages/marking-video/page.tsx b/src/app/[locale]/pages/marking-video/page.tsx index c78b7ad..48bb4fd 100644 --- a/src/app/[locale]/pages/marking-video/page.tsx +++ b/src/app/[locale]/pages/marking-video/page.tsx @@ -1,20 +1,18 @@ import ProtectionSummary from '@/app/ui/marking-page/protection-summary'; -import UploadSectionVideo from '@/app/ui/marking-page/upload-section-video'; import FilesTable from '@/app/ui/dashboard/files-table'; import PageTitle from '@/app/ui/page-title'; import UploadSectionFile from '@/app/components/upload-section-file'; +import { getAllowedFilesExtensions } from '@/app/actions/file-upload'; -const ALLOWED_EXTENSIONS: string[] = ['mp4', 'avi', 'webm', 'mkv', 'flv', 'wmv', 'mov']; -const FILE_TYPE = "VIDEO" -const MAX_SIZE = 1048576000; - -export default function Page() { +export default async function Page() { + const FILE_TYPE = "video"; + const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE); return (
- + {/* */}
diff --git a/src/app/actions/file-upload.ts b/src/app/actions/file-upload.ts index 6f4985d..4ac7d6a 100644 --- a/src/app/actions/file-upload.ts +++ b/src/app/actions/file-upload.ts @@ -187,10 +187,9 @@ export async function getAllowedFilesExtensions(type: string) { if (response.ok) { let parsed = await response.json(); - console.log(parsed); if (parsed.message_desc === 'Operation successful') { - return parsed.message_body.file_extension; + return parsed.message_body; } else { console.log('error cancel getAllowedFilesExtensions'); throw parsed; diff --git a/src/app/components/upload-section-file.tsx b/src/app/components/upload-section-file.tsx index 2ce6b26..2c4ab4f 100644 --- a/src/app/components/upload-section-file.tsx +++ b/src/app/components/upload-section-file.tsx @@ -43,7 +43,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile let SUPPORTED_FORMATS: string[] = []; switch (fileType) { - case 'IMAGE': + case 'image': SUPPORTED_FORMATS = [ 'image/jpeg', 'image/jpg', @@ -56,7 +56,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile 'image/x-icon' ]; break; - case 'VIDEO': + case 'video': SUPPORTED_FORMATS = [ 'video/mp4', 'video/mpeg', @@ -70,7 +70,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile 'video/3gpp2' ]; break; - case 'AUDIO': + case 'audio': SUPPORTED_FORMATS = [ 'audio/mpeg', 'audio/wav', @@ -159,7 +159,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile try { let dimensions = undefined; - if (fileType === "IMAGE") { + if (fileType === "image") { dimensions = await getImageDimensions(file) as { width: number, height: number }; if (dimensions.width < 150 || dimensions.height < 150 || dimensions.width > 10000 || dimensions.height > 10000) { @@ -389,7 +389,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile {t('select-files-to-protect')} - {fileType === "IMAGE" && ( + {fileType === "image" && (

Разрешение изображение: 100x100 - 10000x10000

@@ -439,7 +439,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
- {fileType === 'IMAGE' && ( + {fileType === 'image' && (