mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 22:31:10 +10:00
space updates
* space UI * space management * space permissions * other fixes
This commit is contained in:
@ -1,11 +1,30 @@
|
||||
import { useQuery, UseQueryResult } from '@tanstack/react-query';
|
||||
import { searchPage } from '@/features/search/services/search-service';
|
||||
import { IPageSearch } from '@/features/search/types/search.types';
|
||||
import { useQuery, UseQueryResult } from "@tanstack/react-query";
|
||||
import {
|
||||
searchPage,
|
||||
searchSuggestions,
|
||||
} from "@/features/search/services/search-service";
|
||||
import {
|
||||
IPageSearch,
|
||||
ISuggestionResult,
|
||||
SearchSuggestionParams,
|
||||
} from "@/features/search/types/search.types";
|
||||
|
||||
export function usePageSearchQuery(query: string): UseQueryResult<IPageSearch[], Error> {
|
||||
export function usePageSearchQuery(
|
||||
query: string,
|
||||
): UseQueryResult<IPageSearch[], Error> {
|
||||
return useQuery({
|
||||
queryKey: ['page-history', query],
|
||||
queryKey: ["page-search", query],
|
||||
queryFn: () => searchPage(query),
|
||||
enabled: !!query,
|
||||
});
|
||||
}
|
||||
|
||||
export function useSearchSuggestionsQuery(
|
||||
params: SearchSuggestionParams,
|
||||
): UseQueryResult<ISuggestionResult, Error> {
|
||||
return useQuery({
|
||||
queryKey: ["search-suggestion", params],
|
||||
queryFn: () => searchSuggestions(params),
|
||||
enabled: !!params.query,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,7 +1,18 @@
|
||||
import api from '@/lib/api-client';
|
||||
import { IPageSearch } from '@/features/search/types/search.types';
|
||||
import api from "@/lib/api-client";
|
||||
import {
|
||||
IPageSearch,
|
||||
ISuggestionResult,
|
||||
SearchSuggestionParams,
|
||||
} from "@/features/search/types/search.types";
|
||||
|
||||
export async function searchPage(query: string): Promise<IPageSearch[]> {
|
||||
const req = await api.post<IPageSearch[]>('/search', { query });
|
||||
return req.data as any;
|
||||
const req = await api.post<IPageSearch[]>("/search", { query });
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function searchSuggestions(
|
||||
params: SearchSuggestionParams,
|
||||
): Promise<ISuggestionResult> {
|
||||
const req = await api.post<ISuggestionResult>("/search/suggest", params);
|
||||
return req.data;
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { IUser } from "@/features/user/types/user.types.ts";
|
||||
import { IGroup } from "@/features/group/types/group.types.ts";
|
||||
|
||||
export interface IPageSearch {
|
||||
id: string;
|
||||
@ -10,3 +12,14 @@ export interface IPageSearch {
|
||||
rank: string;
|
||||
highlight: string;
|
||||
}
|
||||
|
||||
export interface SearchSuggestionParams {
|
||||
query: string;
|
||||
includeUsers?: boolean;
|
||||
includeGroups?: boolean;
|
||||
}
|
||||
|
||||
export interface ISuggestionResult {
|
||||
users?: Partial<IUser[]>;
|
||||
groups?: Partial<IGroup[]>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user