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