Защита подтверждена
- Документ {documentTitle} зарегистрирован и защищён платформой NoCopy.
+ Документ {response?.fileName ? response?.fileName : '#'} зарегистрирован и защищён платформой NoCopy.
-
+
Правообладатель
-
Н
+
+ {response?.fileName ? response?.fileName[0] : ''}
+
-
{ownerName}
- {/*
{companyName}
*/}
-
Зарегистрирован в NoCopy
+ {response?.ownerName && (
+
{response?.ownerName}
+ )}
+ {response?.ownerCompany && (
+
{response?.ownerCompany}
+ )}
+ {response?.ownerName && (
+
Зарегистрирован в NoCopy
+ )}
- {/*
-
Скачать документ
-
-
-
- Вы вошли как {ownerName}.
-
- Скачивание будет зарегистрировано.
-
-
-
*/}
-
-
+ {response?.permissions?.DOWNLOAD && (
+
+ )}
- О NoCopy
@@ -81,8 +140,8 @@ export default async function Page({ searchParams }: PageProps) {
NoCopy
- Условия
- Конфиденциальность
+ Условия
+ Конфиденциальность
diff --git a/src/app/actions/trackingActions.ts b/src/app/actions/trackingActions.ts
index 7a82055..920ad33 100644
--- a/src/app/actions/trackingActions.ts
+++ b/src/app/actions/trackingActions.ts
@@ -5,86 +5,123 @@ import { API_BASE_URL } from '@/app/actions/definitions';
import { headers } from 'next/headers';
export async function requestFileWithTracking(fileId: string) {
- const token = await getSessionData('token');
- const headersList = await headers();
- const forwardedFor = headersList.get('x-forwarded-for');
- const realIp = headersList.get('x-real-ip');
- const ip = forwardedFor?.split(',')[0] || realIp || 'unknown';
- const userAgent = headersList.get('user-agent') || 'unknown';
+ const token = await getSessionData('token');
+ const headersList = await headers();
+ const forwardedFor = headersList.get('x-forwarded-for');
+ const realIp = headersList.get('x-real-ip');
+ const ip = forwardedFor?.split(',')[0] || realIp || 'unknown';
+ const userAgent = headersList.get('user-agent') || 'unknown';
- try {
- const response = await fetch(`${API_BASE_URL}/api/file/link`, {
- method: 'POST',
- body: JSON.stringify({
- file_id: fileId,
- token: token,
- ip: ip,
- user_agent: userAgent
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- });
+ try {
+ const response = await fetch(`${API_BASE_URL}/api/file/link`, {
+ method: 'POST',
+ body: JSON.stringify({
+ file_id: fileId,
+ token: token,
+ ip: ip,
+ user_agent: userAgent
+ }),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
- if (response.ok) {
- const contentType = response.headers.get('content-type');
+ if (response.ok) {
+ const contentType = response.headers.get('content-type');
- if (contentType?.includes('application/json')) {
- const data = await response.json();
- return data.message_body;
- } else {
- const blob = await response.blob();
- return URL.createObjectURL(blob);
- }
- } else {
- throw new Error(`${response.status}`);
- }
- } catch (error) {
- return null;
- }
+ if (contentType?.includes('application/json')) {
+ const data = await response.json();
+ return data.message_body;
+ } else {
+ const blob = await response.blob();
+ return URL.createObjectURL(blob);
+ }
+ } else {
+ throw new Error(`${response.status}`);
+ }
+ } catch (error) {
+ return null;
+ }
}
export async function requestFileAsBuffer(fileId: string): Promise
{
- const token = await getSessionData('token');
- const headersList = await headers();
- const forwardedFor = headersList.get('x-forwarded-for');
- const realIp = headersList.get('x-real-ip');
- const ip = forwardedFor?.split(',')[0] || realIp || 'unknown';
- const userAgent = headersList.get('user-agent') || 'unknown';
+ const token = await getSessionData('token');
+ const headersList = await headers();
+ const forwardedFor = headersList.get('x-forwarded-for');
+ const realIp = headersList.get('x-real-ip');
+ const ip = forwardedFor?.split(',')[0] || realIp || 'unknown';
+ const userAgent = headersList.get('user-agent') || 'unknown';
- try {
- const response = await fetch(`${API_BASE_URL}/api/file/link`, {
- method: 'POST',
- body: JSON.stringify({
- file_id: fileId,
- token: token,
- ip: ip,
- user_agent: userAgent
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- });
+ try {
+ const response = await fetch(`${API_BASE_URL}/api/file/link`, {
+ method: 'POST',
+ body: JSON.stringify({
+ file_id: fileId,
+ token: token,
+ ip: ip,
+ user_agent: userAgent
+ }),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
- if (!response.ok) {
- throw new Error(`${response.status}`);
- }
+ if (!response.ok) {
+ throw new Error(`${response.status}`);
+ }
- const contentType = response.headers.get('content-type');
- if (contentType?.includes('application/json')) {
- const data = await response.json();
- const fileUrl = data.message_body;
- const fileResponse = await fetch(fileUrl);
- if (!fileResponse.ok) {
- throw new Error(`Failed to fetch file: ${fileResponse.status}`);
- }
-
- return await fileResponse.arrayBuffer();
- }
- else {
- return await response.arrayBuffer();
- }
- } catch (error) {
- return null;
- }
+ const contentType = response.headers.get('content-type');
+ if (contentType?.includes('application/json')) {
+ const data = await response.json();
+ const fileUrl = data.message_body;
+ const fileResponse = await fetch(fileUrl);
+ if (!fileResponse.ok) {
+ throw new Error(`Failed to fetch file: ${fileResponse.status}`);
+ }
+
+ return await fileResponse.arrayBuffer();
+ }
+ else {
+ return await response.arrayBuffer();
+ }
+ } catch (error) {
+ return null;
+ }
+}
+
+export async function fetchDocumentInfo(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: {
+ file_id: fileId,
+ token: token,
+ action: 'file_info'
+ }
+ }),
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ });
+
+ if (response.ok) {
+ const parsed = await response.json();
+
+ if (parsed.message_code === 0) {
+ return parsed.message_body;
+ } else {
+ return null;
+ }
+
+ } else {
+ throw new Error(`${response.status}`);
+ }
+ } catch (error) {
+ return null;
+ }
}
\ No newline at end of file
diff --git a/src/app/components/document-viewer/LoginUserBage.tsx b/src/app/components/document-viewer/LoginUserBage.tsx
new file mode 100644
index 0000000..03d161f
--- /dev/null
+++ b/src/app/components/document-viewer/LoginUserBage.tsx
@@ -0,0 +1,18 @@
+'use client';
+
+import Link from 'next/link';
+import { useUserProfile } from '@/app/hooks/react-query/useUserDataInfo';
+
+export function LoginUserBage() {
+ const { data: userData, isLoading, isError, error } = useUserProfile();
+
+ if (!userData?.fullName) {
+ return null;
+ }
+
+ return (
+
+ {userData?.fullName}
+
+ );
+}
\ No newline at end of file
diff --git a/src/app/styles/watch-doc.scss b/src/app/styles/watch-doc.scss
index a83f253..f9cd133 100644
--- a/src/app/styles/watch-doc.scss
+++ b/src/app/styles/watch-doc.scss
@@ -164,6 +164,10 @@
justify-content: center;
}
}
+
+ .error-container {
+ text-align: center;
+ }
}
&-page {
@@ -247,7 +251,7 @@
background: var(--card);
border: 1px solid var(--border);
border-radius: 14px;
- margin-bottom: 14px;
+ /* margin-bottom: 14px; */
overflow: hidden;
box-shadow: var(--shadow);