diff --git a/package.json b/package.json index 8f03780..f1e863d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "no-copy-frontend", - "version": "0.24.0", + "version": "0.25.0", "private": true, "scripts": { "dev": "next dev -p 2999", diff --git a/src/app/actions/action.ts b/src/app/actions/action.ts index 360af1a..fbe5e68 100644 --- a/src/app/actions/action.ts +++ b/src/app/actions/action.ts @@ -9,7 +9,7 @@ export async function getUserData() { const token = await getSessionData('token'); /* для теста */ - if (userEmail === "test" && token === "1111") { + if (userEmail === 'test' && token === '1111') { return testUserData; } /* для теста */ @@ -18,9 +18,9 @@ export async function getUserData() { const response = await fetch(`${API_BASE_URL}/v1/api/user?email=${userEmail}`, { method: 'GET', headers: { - "Content-Type": "application/json", - "Accept": "application/json", - "Authorization": `Bearer ${token}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': `Bearer ${token}`, } }); @@ -42,13 +42,13 @@ export async function getUserFilesInfo() { version: 1, msg_id: 20005, message_body: { - action: "user_files_info", + action: 'user_files_info', token: token } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); diff --git a/src/app/actions/auth.ts b/src/app/actions/auth.ts index 15b4213..6d9c697 100644 --- a/src/app/actions/auth.ts +++ b/src/app/actions/auth.ts @@ -11,9 +11,9 @@ export async function logout() { await fetch(`${API_BASE_URL}/v1/api/auth/logout`, { method: 'POST', headers: { - "Content-Type": "application/json", - "Accept": "application/json", - "Authorization": `Bearer ${token}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Authorization': `Bearer ${token}`, } }); } catch (error) { @@ -36,8 +36,8 @@ export async function authorization( const password = formData.get('password'); /* для теста */ - if (email === "test" && password === "test") { - await createSession("1111", "test"); + if (email === 'test' && password === 'test') { + await createSession('1111', 'test'); redirect('/pages/dashboard'); } /* для теста */ @@ -81,8 +81,8 @@ export async function authorization( } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); if (response.ok) { @@ -211,8 +211,8 @@ export async function registration( } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -302,8 +302,8 @@ export async function tokenLifeExtension() { const response = await fetch(`${API_BASE_URL}/api/v1/data`, { method: 'POST', headers: { - "Content-Type": "application/json", - "Accept": "application/json", + 'Content-Type': 'application/json', + 'Accept': 'application/json', }, body: JSON.stringify({ version: 1, diff --git a/src/app/actions/definitions.ts b/src/app/actions/definitions.ts index cbd260d..c06b06a 100644 --- a/src/app/actions/definitions.ts +++ b/src/app/actions/definitions.ts @@ -1,5 +1,5 @@ import * as z from 'zod' -import { createValidationSchema } from "@/app/lib/validation-config-parser"; +import { createValidationSchema } from '@/app/lib/validation-config-parser'; import validationConfig from '@/app/lib/validation-config.json'; export type FormState = diff --git a/src/app/actions/fileEntity.ts b/src/app/actions/fileEntity.ts index e9607f9..7df3af3 100644 --- a/src/app/actions/fileEntity.ts +++ b/src/app/actions/fileEntity.ts @@ -21,8 +21,8 @@ export async function getUserFilesData(page: number, pageSize: number) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -59,8 +59,8 @@ export async function removeUserFile(fileId: string, fullDelete: number) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -120,8 +120,46 @@ export async function searchGlobalFiles(fileId: string) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }); + + if (response.ok) { + let parsed = await response.json(); + + if (parsed.message_code === 0) { + return parsed.message_body; + } else { + throw parsed; + } + } else { + throw (`${response.status}`); + } + + } catch (error) { + return error + } +} + +export async function viewFileInfo(fileId: string) { + const token = await getSessionData('token'); + + try { + const response = await fetch(`${API_BASE_URL}/api/v1/data`, { + method: 'POST', + body: JSON.stringify({ + version: 1, + msg_id: 20005, + message_body: { + action: 'file_info', + file_id: fileId, + token: token + } + }), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); diff --git a/src/app/actions/fileUpload.ts b/src/app/actions/fileUpload.ts index cc304d0..c3fb85b 100644 --- a/src/app/actions/fileUpload.ts +++ b/src/app/actions/fileUpload.ts @@ -18,7 +18,7 @@ export async function fileUpload(messageBody: initMessageBody) { return; } const message = messageBody; - message.action = "init"; + message.action = 'init'; message.token = token; try { @@ -30,8 +30,8 @@ export async function fileUpload(messageBody: initMessageBody) { message_body: message }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -68,13 +68,13 @@ export async function cancelUpload(udloadId: string) { version: 1, msg_id: 20004, message_body: { - action: "cancel", + action: 'cancel', upload_id: udloadId, } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -138,8 +138,8 @@ export async function checkChunkStatus(upload_id: string) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); @@ -173,8 +173,8 @@ export async function getAllowedFilesExtensions(type: string) { } }), headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); diff --git a/src/app/actions/vkAuth.ts b/src/app/actions/vkAuth.ts index dd88ae4..78b4738 100644 --- a/src/app/actions/vkAuth.ts +++ b/src/app/actions/vkAuth.ts @@ -15,8 +15,8 @@ export async function vkAuthorization(data : any, codeVerifier: string) { const response = await fetch(`${API_BASE_URL}/api/v1/vk/authorization/${code}/${state}/${codeVerifier}/${device_id}`, { method: 'GET', headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); if (response.ok) { diff --git a/src/app/actions/yandexAuth.ts b/src/app/actions/yandexAuth.ts index f39588f..0623101 100644 --- a/src/app/actions/yandexAuth.ts +++ b/src/app/actions/yandexAuth.ts @@ -15,8 +15,8 @@ export async function YandexAuthorization(data: any, codeVerifier: string) { const response = await fetch(`${API_BASE_URL}/api/v1/yandex/authorization/${code}/${state}/${codeVerifier}/${device_id}`, { method: 'GET', headers: { - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + 'Accept': 'application/json' } }); if (response.ok) { diff --git a/src/app/components/tanstakTable.tsx b/src/app/components/tanstakTable.tsx index 8045053..4ca918f 100644 --- a/src/app/components/tanstakTable.tsx +++ b/src/app/components/tanstakTable.tsx @@ -15,11 +15,12 @@ import { IconImageFile, IconVideoFile, IconAudioFile, IconEye, IconDoubleArrowRi import { useTranslations, useLocale } from 'next-intl'; import DropDownList from '@/app/components/dropDownList'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { getUserFilesData, removeUserFile } from '@/app/actions/fileEntity'; +import { getUserFilesData, removeUserFile, viewFileInfo } from '@/app/actions/fileEntity'; import ModalWindow from '@/app/components/modalWindow'; import { toast } from 'sonner'; import { pluralize } from '@/app/lib/pluralize'; import { convertBytes } from '@/app/lib/convertBytes'; +import { FileInfoModalWindow } from '@/app/ui/modal-windows/file-info-modal-window'; type FileType = 'image' | 'video' | 'audio'; @@ -423,30 +424,12 @@ export default function TanstakFilesTable({ fileType }: { fileType: string }) { cell: ({ row }) => (