add error message for unsupported file
This commit is contained in:
@@ -17,14 +17,23 @@ export async function searchUserFiles(fileId: string) {
|
|||||||
if (parsed.message_code === 0) {
|
if (parsed.message_code === 0) {
|
||||||
return parsed.message_body;
|
return parsed.message_body;
|
||||||
} else {
|
} else {
|
||||||
throw parsed;
|
throw parsed.message_desc;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw (`${response.status}`);
|
throw (`${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error
|
|
||||||
|
if (error === 'File for search unsupported') {
|
||||||
|
return {
|
||||||
|
errorMessage: 'file-for-search-unsupported'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
errorMessage: 'error'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,11 @@ export function FileSearchPanel(
|
|||||||
try {
|
try {
|
||||||
let result = await searchUserFiles(fileId);
|
let result = await searchUserFiles(fileId);
|
||||||
|
|
||||||
if (result.content.length) {
|
if (result.errorMessage) {
|
||||||
|
throw result.errorMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result?.content?.length) {
|
||||||
setSearchedUserFiles(result.content);
|
setSearchedUserFiles(result.content);
|
||||||
if (fileType === 'image') {
|
if (fileType === 'image') {
|
||||||
setShowGlobalSearch(true);
|
setShowGlobalSearch(true);
|
||||||
@@ -80,7 +84,12 @@ export function FileSearchPanel(
|
|||||||
setSearchedUserFilesShowNull(true);
|
setSearchedUserFilesShowNull(true);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setErrorMessage('error');
|
|
||||||
|
if (error === 'file-for-search-unsupported') {
|
||||||
|
setErrorMessage(error);
|
||||||
|
} else {
|
||||||
|
setErrorMessage('search-error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [fileId])
|
}, [fileId])
|
||||||
@@ -138,7 +147,7 @@ export function FileSearchPanel(
|
|||||||
|
|
||||||
{errorMessage && (
|
{errorMessage && (
|
||||||
<div className='mt-2 text-red-600 text-sm'>
|
<div className='mt-2 text-red-600 text-sm'>
|
||||||
{t('search-error')}
|
{t(errorMessage)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -286,7 +286,8 @@
|
|||||||
"DIFFERENT": "DIFFERENT",
|
"DIFFERENT": "DIFFERENT",
|
||||||
"file-information": "File information",
|
"file-information": "File information",
|
||||||
"id-in-the-system": "ID in the system",
|
"id-in-the-system": "ID in the system",
|
||||||
"protection-status": "Protection status"
|
"protection-status": "Protection status",
|
||||||
|
"file-for-search-unsupported": "File for search unsupported"
|
||||||
},
|
},
|
||||||
"Login-register-form": {
|
"Login-register-form": {
|
||||||
"and": "and",
|
"and": "and",
|
||||||
|
|||||||
@@ -286,7 +286,8 @@
|
|||||||
"DIFFERENT": "ДРУГОЙ",
|
"DIFFERENT": "ДРУГОЙ",
|
||||||
"file-information": "Информация о файле",
|
"file-information": "Информация о файле",
|
||||||
"id-in-the-system": "ID в системе",
|
"id-in-the-system": "ID в системе",
|
||||||
"protection-status": "Статус защиты"
|
"protection-status": "Статус защиты",
|
||||||
|
"file-for-search-unsupported": "Файл для поиска не поддерживается"
|
||||||
},
|
},
|
||||||
"Login-register-form": {
|
"Login-register-form": {
|
||||||
"and": "и",
|
"and": "и",
|
||||||
|
|||||||
Reference in New Issue
Block a user