1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

getting node results for search

This commit is contained in:
Fedor Katurov 2020-04-18 16:06:10 +07:00
parent 41a35f1490
commit 94ac596b92
15 changed files with 308 additions and 164 deletions

View file

@ -1,16 +1,11 @@
import {
api,
configWithToken,
resultMiddleware,
errorMiddleware
} from "~/utils/api";
import { INode, IResultWithStatus } from "../types";
import { API } from "~/constants/api";
import { flowSetCellView } from "~/redux/flow/actions";
import { api, configWithToken, resultMiddleware, errorMiddleware } from '~/utils/api';
import { INode, IResultWithStatus } from '../types';
import { API } from '~/constants/api';
import { flowSetCellView } from '~/redux/flow/actions';
export const postNode = ({
access,
node
node,
}: {
access: string;
node: INode;
@ -20,24 +15,26 @@ export const postNode = ({
.then(resultMiddleware)
.catch(errorMiddleware);
// export const getNodes = ({
// from = null
// }: {
// from: string;
// }): Promise<IResultWithStatus<{ nodes: INode[] }>> =>
// api
// .get(API.NODE.GET, { params: { from } })
// .then(resultMiddleware)
// .catch(errorMiddleware);
export const postCellView = ({
id,
flow,
access
}: ReturnType<typeof flowSetCellView> & { access: string }): Promise<
IResultWithStatus<{ is_liked: INode["is_liked"] }>
> =>
access,
}: ReturnType<typeof flowSetCellView> & { access: string }): Promise<IResultWithStatus<{
is_liked: INode['is_liked'];
}>> =>
api
.post(API.NODE.SET_CELL_VIEW(id), { flow }, configWithToken(access))
.then(resultMiddleware)
.catch(errorMiddleware);
export const getSearchResults = ({
access,
text,
}: {
access: string;
text: string;
}): Promise<IResultWithStatus<{ nodes: INode[]; total: number }>> =>
api
.get(API.SEARCH, configWithToken(access, { params: { text } }))
.then(resultMiddleware)
.catch(errorMiddleware);