remove date, block global search for audio, video and documents
This commit is contained in:
@@ -6,6 +6,7 @@ import { useQueryClient } from '@tanstack/react-query';
|
||||
import { Pagination } from '@/app/components/Pagination';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { AllowedExtensions } from '@/app/ui/search/section-search-file';
|
||||
import { getFileType } from '@/app/lib/getFileType';
|
||||
|
||||
export interface SearchItem {
|
||||
url: string,
|
||||
@@ -29,7 +30,11 @@ export interface FileInfo {
|
||||
url: string
|
||||
}
|
||||
|
||||
export function FileSearchPanel({ fileId, ref, allowedExtensions }: { fileId: string | null, ref: any, allowedExtensions: AllowedExtensions }) {
|
||||
export function FileSearchPanel(
|
||||
{ fileId, ref, allowedExtensions, fileType }
|
||||
:
|
||||
{ fileId: string | null, ref: any, allowedExtensions: AllowedExtensions, fileType: string | null }
|
||||
) {
|
||||
const [searchedUserFiles, setSearchedUserFiles] = useState<FileInfo[]>([]);
|
||||
const [searchedUserFilesShowNull, setSearchedUserFilesShowNull] = useState<boolean>(false);
|
||||
const [searchedGlobalFiles, setSearchedGlobalFiles] = useState<SearchItem[]>([]);
|
||||
@@ -63,7 +68,7 @@ export function FileSearchPanel({ fileId, ref, allowedExtensions }: { fileId: st
|
||||
try {
|
||||
let result = await searchUserFiles(fileId);
|
||||
|
||||
if (result.content.length) {
|
||||
if (result.content.length && fileType === 'image') {
|
||||
setSearchedUserFiles(result.content);
|
||||
setShowGlobalSearch(true);
|
||||
handlerSearchGlobalFile(fileId, page);
|
||||
|
||||
@@ -16,9 +16,9 @@ export function RecentSearches() {
|
||||
<IconDocument /> document</span>
|
||||
<div>
|
||||
<div>{userSearchData?.document?.count ? userSearchData?.document?.count : 0} поисков</div>
|
||||
<div className="recent-date">
|
||||
{/* <div className="recent-date">
|
||||
date
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="recent-item">
|
||||
@@ -26,9 +26,6 @@ export function RecentSearches() {
|
||||
<IconImageFile /> image</span>
|
||||
<div>
|
||||
<div>{userSearchData?.image?.count ? userSearchData?.image?.count : 0} поисков</div>
|
||||
<div className="recent-date">
|
||||
date
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="recent-item">
|
||||
@@ -36,9 +33,6 @@ export function RecentSearches() {
|
||||
<IconAudioFile /> audio</span>
|
||||
<div>
|
||||
<div>{userSearchData?.audio?.count ? userSearchData?.audio?.count : 0} поисков</div>
|
||||
<div className="recent-date">
|
||||
date
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="recent-item">
|
||||
@@ -46,9 +40,6 @@ export function RecentSearches() {
|
||||
<IconVideoFile /> video</span>
|
||||
<div>
|
||||
<div>{userSearchData?.video?.count ? userSearchData?.video?.count : 0} поисков</div>
|
||||
<div className="recent-date">
|
||||
date
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
|
||||
import { useUserSearchData } from '@/app/hooks/react-query/useUserSearchData';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export function SearchStats() {
|
||||
const { data: userSearchData, isLoading, isError, error, } = useUserSearchData();
|
||||
const t = useTranslations('Global');
|
||||
|
||||
useEffect(() => {
|
||||
console.log(userSearchData);
|
||||
}, [userSearchData])
|
||||
|
||||
return (
|
||||
<div className="stats-search">
|
||||
<div className="stats-title">
|
||||
|
||||
@@ -45,6 +45,7 @@ export default function SectionSearchFile({ allowedExtensions, maxFileSize }: Se
|
||||
const [isFileUploaded, setIsFileUploaded] = useState<boolean>(false);
|
||||
const [uploadProgress, setUploadProgress] = useState<number>(0);
|
||||
const [fileId, setFileId] = useState<string | null>(null);
|
||||
const [fileType, setFileType] = useState<string | null>(null);
|
||||
const queryClient = useQueryClient();
|
||||
const isCancelledRef = useRef(false);
|
||||
|
||||
@@ -93,6 +94,7 @@ export default function SectionSearchFile({ allowedExtensions, maxFileSize }: Se
|
||||
if (fileId) {
|
||||
await removeUserFile(fileId, 1);
|
||||
setFileId(null);
|
||||
setFileType(null);
|
||||
}
|
||||
|
||||
setError(null);
|
||||
@@ -214,6 +216,7 @@ export default function SectionSearchFile({ allowedExtensions, maxFileSize }: Se
|
||||
|
||||
if (isLastChunk && chunkResponse.fileId) {
|
||||
setFileId(chunkResponse.fileId);
|
||||
setFileType(fileType);
|
||||
document.cookie = `searchedFileId=${chunkResponse.fileId}`
|
||||
}
|
||||
}
|
||||
@@ -348,7 +351,7 @@ export default function SectionSearchFile({ allowedExtensions, maxFileSize }: Se
|
||||
</div>
|
||||
|
||||
{isFileUploaded && (
|
||||
<FileSearchPanel fileId={fileId} ref={childRef} allowedExtensions={allowedExtensions} />
|
||||
<FileSearchPanel fileId={fileId} ref={childRef} allowedExtensions={allowedExtensions} fileType={fileType} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user