NCBACK-168 #7

Merged
frontdev merged 4 commits from NCBACK-168 into main 2026-06-03 13:23:47 +08:00
11 changed files with 105 additions and 127 deletions
Showing only changes of commit 743db57bb3 - Show all commits
+3 -1
View File
@@ -23,6 +23,8 @@ export async function getUserData() {
}
});
console.log(response);
if (response.ok) {
return await response.json();
} else {
@@ -165,7 +167,7 @@ export async function getBuildData() {
export async function fetchINN(inn: string) {
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
const response = await fetch(`${API_BASE_URL}/api/auth`, {
method: 'POST',
body: JSON.stringify({
version: 1,
+7 -10
View File
@@ -72,7 +72,7 @@ export async function authorization(
try {
const { email, password } = validatedFields.data;
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
const response = await fetch(`${API_BASE_URL}/api/auth`, {
method: 'POST',
body: JSON.stringify({
version: 1,
@@ -234,7 +234,7 @@ export async function registration(
try {
const { fullName, email, password, phone } = validatedFields.data;
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
const response = await fetch(`${API_BASE_URL}/api/auth`, {
method: 'POST',
body: JSON.stringify({
version: 1,
@@ -400,13 +400,11 @@ export async function tokenLifeExtension() {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`,
},
body: JSON.stringify({
version: 1,
msg_id: 20008,
message_body: {
token: token
}
msg_id: 20008
}),
});
@@ -431,14 +429,14 @@ export async function confirmEmail(userId: number, verifyToken: string) {
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
'Authorization': `Bearer ${verifyToken}`,
},
body: JSON.stringify({
version: 1,
msg_id: 20009,
message_body: {
resend: 0,
user_id: userId,
verify_token: verifyToken
user_id: userId
}
}),
});
@@ -474,7 +472,6 @@ export async function confirmEmail(userId: number, verifyToken: string) {
export async function resendConfirmEmail(userId: number) {
console.log('resendConfirmEmail');
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
method: 'POST',
@@ -611,6 +608,7 @@ export async function confirmPassword(
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${verifyToken}`
},
body: JSON.stringify({
version: 1,
@@ -618,7 +616,6 @@ export async function confirmPassword(
message_body: {
email: email,
password: password,
verifyToken: verifyToken,
action: "confirmVerification"
}
}),
+2 -10
View File
@@ -95,7 +95,6 @@ export async function companyUserRegistration(
phone: phone,
password,
accountType: 'b2b',
authToken: token,
mail_verified: false,
ip: ip,
user_agent: userAgent,
@@ -103,7 +102,8 @@ export async function companyUserRegistration(
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -113,14 +113,6 @@ export async function companyUserRegistration(
message_body: { token: string },
message_code: number
};
console.log({
fullName: fullName,
email,
phone: phone,
password,
accountType: 'b2b',
authToken: token
});
if (parsed.message_code === 0) {
console.log(`registration - ${email}`);
+9 -9
View File
@@ -31,7 +31,6 @@ export async function getUserFilesData({
msg_id: 20005,
message_body: {
action: 'search_files',
token: token,
page: page,
page_size: pageSize,
query: query,
@@ -43,7 +42,8 @@ export async function getUserFilesData({
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -77,12 +77,12 @@ export async function removeUserFile(fileId: string, fullDelete: number) {
action: 'delete_file',
file_id: fileId,
full_delete: fullDelete,
token: token
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -114,13 +114,13 @@ export async function viewFileInfo(fileId: string) {
msg_id: 20005,
message_body: {
action: 'file_info',
file_id: fileId,
token: token
file_id: fileId
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -176,14 +176,14 @@ export async function FileAnAppeal(fileId: string, appealReason: string, additio
message_body: {
action: 'submit_appeal',
file_id: fileId,
token: token,
appeal_reason: appealReason,
additional_info: additionalInfo
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
+12 -13
View File
@@ -2,8 +2,6 @@
import { API_BASE_URL } from '@/app/actions/definitions';
import { getSessionData } from '@/app/actions/session';
import { FormState } from '@/app/actions/auth';
import { unknown } from 'zod';
interface initMessageBody {
file_name: string,
@@ -22,7 +20,6 @@ export async function fileUpload(messageBody: initMessageBody, convertTo?: strin
}
const message = messageBody;
message.action = 'init';
message.token = token;
if (convertTo && convertTo !== 'reject') {
message.convertTo = convertTo;
@@ -38,7 +35,8 @@ export async function fileUpload(messageBody: initMessageBody, convertTo?: strin
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -114,7 +112,6 @@ export type ChunkResponse = {
};
export async function chunkUpload(formData: FormData, itPrivate?: boolean): Promise<ChunkResponse> {
console.log('chunkUpload');
const token = await getSessionData('token');
try {
@@ -123,19 +120,21 @@ export async function chunkUpload(formData: FormData, itPrivate?: boolean): Prom
: `${API_BASE_URL}/api/v1/files/chunk`;
if (token && itPrivate) {
formData.append('token', token);
}
/* if (token && itPrivate) {
formData.append('token', token);
} */
const response = await fetch(url, {
method: 'POST',
body: formData
body: formData,
headers: {
'Authorization': `Bearer ${token}`
}
});
/* ...(token && itPrivate && { 'Authorization': `Bearer ${token}` }) возможно нужно будет условно отправлять токен*/
if (response.ok) {
let parsed = await response.json();
console.log(formData);
console.log(parsed);
if (parsed.message_code === 0) {
return {
@@ -250,7 +249,6 @@ export async function checkOperationPrice(action: string, filesCount: number, fi
version: 1,
msg_id: 30008,
message_body: {
auth_token: token,
action: action,
file_type: fileType,
count_files: filesCount
@@ -258,7 +256,8 @@ export async function checkOperationPrice(action: string, filesCount: number, fi
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
+11 -15
View File
@@ -14,13 +14,13 @@ export async function setMonitoring(fileId: string, monitoringType: string) {
msg_id: 30007,
message_body: {
monitoring_type: monitoringType,
file_id: fileId,
auth_token: token
file_id: fileId
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -65,14 +65,12 @@ export async function fetchMonitoringStats(): Promise<MonitoringStats | null> {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 30011,
message_body: {
token: token
}
msg_id: 30011
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -99,13 +97,13 @@ export async function fetchLastMonitoringCheck() {
version: 1,
msg_id: 30011,
message_body: {
token: token,
limit: 1
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -131,14 +129,12 @@ export async function fetchMonitoringInfo() {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 30027,
message_body: {
authToken: token
}
msg_id: 30027
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
+9 -10
View File
@@ -22,13 +22,13 @@ export async function fetchActiveNotifications() {
version: 1,
msg_id: 30015,
message_body: {
action: 'active',
authToken: token,
action: 'active'
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -59,7 +59,6 @@ export async function fetchAllNotifications(page: number = 0, size: number = 10)
msg_id: 30015,
message_body: {
action: 'list',
authToken: token,
page: page,
size: size,
sortBy: "createdAt",
@@ -70,7 +69,8 @@ export async function fetchAllNotifications(page: number = 0, size: number = 10)
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -101,13 +101,13 @@ export async function notificationsMarkAsRead(ids: number[]) {
msg_id: 30015,
message_body: {
action: 'markRead',
authToken: token,
notificationIds: ids
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -132,7 +132,6 @@ export async function notificationsMarkAsRead(ids: number[]) {
export async function notificationsDelete(ids: number[]) {
const token = await getSessionData('token');
console.log('notificationsDelete');
try {
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
@@ -142,13 +141,13 @@ export async function notificationsDelete(ids: number[]) {
msg_id: 30015,
message_body: {
action: 'delete',
authToken: token,
notificationIds: ids
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
+8 -15
View File
@@ -14,12 +14,12 @@ export async function fetchReferralsLevels() {
msg_id: 30003,
message_body: {
action: 'levels',
token: token,
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -57,12 +57,12 @@ export async function fetchReferralUserStats() {
msg_id: 30003,
message_body: {
action: 'userStats',
token: token,
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -96,14 +96,14 @@ export async function fetchReferralInvitees() {
msg_id: 30003,
message_body: {
action: 'invitees',
token: token,
pageSize: 100,
pageNumber: 0
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -137,25 +137,18 @@ export async function referralRefill() {
msg_id: 30003,
message_body: {
action: 'refill',
token: token,
amount: 2000,
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
if (response.ok) {
console.log('referralRefill');
console.log({
action: 'refill',
token: token,
amount: 2000,
})
let parsed = await response.json();
console.log(parsed);
if (parsed.message_code === 0) {
return parsed.message_body;
+5 -2
View File
@@ -7,8 +7,11 @@ export async function searchUserFiles(fileId: string) {
const token = await getSessionData('token');
try {
const response = await fetch(`${API_BASE_URL}/api/v1/files/${fileId}/similar?similarityLevels=DUPLICATE,SIMILARITY&auth_token=${token}`, {
method: 'GET'
const response = await fetch(`${API_BASE_URL}/api/v1/files/${fileId}/similar?similarityLevels=DUPLICATE,SIMILARITY`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`
}
});
if (response.ok) {
+12 -12
View File
@@ -17,12 +17,12 @@ export async function requestFileWithTracking(fileId: string) {
method: 'POST',
body: JSON.stringify({
file_id: fileId,
token: token,
ip: ip,
user_agent: userAgent
}),
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -57,12 +57,12 @@ export async function requestFileAsBuffer(fileId: string): Promise<ArrayBuffer |
method: 'POST',
body: JSON.stringify({
file_id: fileId,
token: token,
ip: ip,
user_agent: userAgent
}),
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -100,12 +100,12 @@ export async function fetchDocumentInfo(fileId: string) {
msg_id: 20005,
message_body: {
file_id: fileId,
token: token,
action: 'file_info'
}
}),
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -137,7 +137,6 @@ export async function filePermisionChange(fileId: string, permissions: boolean)
msg_id: 20005,
message_body: {
file_id: fileId,
token: token,
action: 'change_permission',
permissions: {
DOWNLOAD: permissions
@@ -145,7 +144,8 @@ export async function filePermisionChange(fileId: string, permissions: boolean)
}
}),
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -182,7 +182,6 @@ export async function fetchHistoryView(
version: 1,
msg_id: 30028,
message_body: {
token: token,
action: 'history_view',
page: page,
size: size,
@@ -192,7 +191,8 @@ export async function fetchHistoryView(
}
}),
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -223,12 +223,12 @@ export async function fetchTrackingStats() {
version: 1,
msg_id: 30028,
message_body: {
token: token,
action: 'view_stats'
}
}),
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
}
});
+27 -30
View File
@@ -91,9 +91,7 @@ export async function getViolationFilesArray(props: {
const { page, size, start_date, end_date, file_name } = props;
try {
const body: Record<string, any> = {
token: token
};
const body: Record<string, any> = {};
if (page !== undefined) body.page = page;
if (size !== undefined) body.size = size;
@@ -106,6 +104,7 @@ export async function getViolationFilesArray(props: {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(body),
});
@@ -141,7 +140,6 @@ export async function getFileMatches(fileId: string, page: number, status?: stri
page: (page > 0 ? page - 1 : 0),
size: 5,
sort_direction: 'desc',
token: token,
status: status,
...(violationId && { action: 'getByViolationId' }),
...(violationId && { violation_id: violationId }),
@@ -150,7 +148,8 @@ export async function getFileMatches(fileId: string, page: number, status?: stri
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -183,13 +182,13 @@ export async function fetchViolationAnalyticStatistic(group: 'domain' | 'tld') {
message_body: {
group_by: group,
action: "group",
token: token,
sort_direction: 'desc'
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -219,13 +218,13 @@ export async function fetchViolationStatistic(id?: string) {
version: 1,
msg_id: 30010,
message_body: {
token: token,
...(id && { file_id: id })
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -253,14 +252,12 @@ export async function fetchViolationFinalSummaryStatistic() {
method: 'POST',
body: JSON.stringify({
version: 1,
msg_id: 30023,
message_body: {
token: token,
}
msg_id: 30023
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -328,7 +325,6 @@ export async function createComplaint(
version: 1,
msg_id: 30013,
message_body: {
token: token,
action: 'create',
violation_id: violationId,
text: textArea,
@@ -337,7 +333,8 @@ export async function createComplaint(
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -394,13 +391,13 @@ export async function fetchComplainInfo(id: number) {
msg_id: 30013,
message_body: {
action: 'get_by_violation',
violation_id: id,
token
violation_id: id
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -438,13 +435,13 @@ export async function updateMatchStatus(id: number, status: MatchStatus) {
message_body: {
action: 'updateStatus',
violation_id: id,
status: status,
token: token
status: status
}
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -475,7 +472,6 @@ export async function fetchClaimInfo(id: number) {
msg_id: 30017,
message_body: {
action: 'get_all',
token: token,
pageSize: 1,
pageNumber: 0,
sortBy: "createdAt",
@@ -485,7 +481,8 @@ export async function fetchClaimInfo(id: number) {
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -572,7 +569,6 @@ export async function createClaim(
violation_id: violationId,
description: textArea,
email: email,
token: token,
name: caseTitle,
priority: 'HIGH',
amount: Number(amount)
@@ -580,7 +576,8 @@ export async function createClaim(
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -651,7 +648,6 @@ export async function fetchLastClaims(params: ComplaintsCaseQueryParams) {
msg_id: 30017,
message_body: {
action: "get_all",
token: token,
pageNumber: page,
size,
sort_by,
@@ -660,7 +656,8 @@ export async function fetchLastClaims(params: ComplaintsCaseQueryParams) {
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});
@@ -692,7 +689,6 @@ export async function fetchLastComplaint(params: ComplaintsCaseQueryParams) {
msg_id: 30013,
message_body: {
action: "get_all",
token: token,
page,
size,
sort_by,
@@ -701,7 +697,8 @@ export async function fetchLastComplaint(params: ComplaintsCaseQueryParams) {
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});