mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
node deletion (lock)
This commit is contained in:
parent
b1279e8d4d
commit
8f0625f734
12 changed files with 113 additions and 58 deletions
|
@ -1,17 +1,12 @@
|
|||
import {
|
||||
api,
|
||||
configWithToken,
|
||||
resultMiddleware,
|
||||
errorMiddleware
|
||||
} from "~/utils/api";
|
||||
import { INode, IResultWithStatus, IComment } from "../types";
|
||||
import { API } from "~/constants/api";
|
||||
import { nodeUpdateTags, nodeLike, nodeStar } from "./actions";
|
||||
import { INodeState } from "./reducer";
|
||||
import { api, configWithToken, resultMiddleware, errorMiddleware } from '~/utils/api';
|
||||
import { INode, IResultWithStatus, IComment } from '../types';
|
||||
import { API } from '~/constants/api';
|
||||
import { nodeUpdateTags, nodeLike, nodeStar, nodeLock } from './actions';
|
||||
import { INodeState } from './reducer';
|
||||
|
||||
export const postNode = ({
|
||||
access,
|
||||
node
|
||||
node,
|
||||
}: {
|
||||
access: string;
|
||||
node: INode;
|
||||
|
@ -24,7 +19,7 @@ export const postNode = ({
|
|||
|
||||
export const getNodes = ({
|
||||
from = null,
|
||||
access
|
||||
access,
|
||||
}: {
|
||||
from?: string;
|
||||
access: string;
|
||||
|
@ -42,7 +37,7 @@ export const getNodeDiff = ({
|
|||
with_updated,
|
||||
with_recent,
|
||||
with_valid,
|
||||
access
|
||||
access,
|
||||
}: {
|
||||
start?: string;
|
||||
end?: string;
|
||||
|
@ -64,8 +59,8 @@ export const getNodeDiff = ({
|
|||
with_heroes,
|
||||
with_updated,
|
||||
with_recent,
|
||||
with_valid
|
||||
}
|
||||
with_valid,
|
||||
},
|
||||
})
|
||||
)
|
||||
.then(resultMiddleware)
|
||||
|
@ -73,7 +68,7 @@ export const getNodeDiff = ({
|
|||
|
||||
export const getNode = ({
|
||||
id,
|
||||
access
|
||||
access,
|
||||
}: {
|
||||
id: string | number;
|
||||
access: string;
|
||||
|
@ -86,7 +81,7 @@ export const getNode = ({
|
|||
export const postNodeComment = ({
|
||||
id,
|
||||
data,
|
||||
access
|
||||
access,
|
||||
}: {
|
||||
access: string;
|
||||
id: number;
|
||||
|
@ -100,11 +95,11 @@ export const postNodeComment = ({
|
|||
export const getNodeComments = ({
|
||||
id,
|
||||
access,
|
||||
order = "ASC"
|
||||
order = 'ASC',
|
||||
}: {
|
||||
id: number;
|
||||
access: string;
|
||||
order: "ASC" | "DESC";
|
||||
order: 'ASC' | 'DESC';
|
||||
}): Promise<IResultWithStatus<{ comments: Comment[] }>> =>
|
||||
api
|
||||
.get(API.NODE.COMMENT(id), configWithToken(access, { params: { order } }))
|
||||
|
@ -113,11 +108,11 @@ export const getNodeComments = ({
|
|||
|
||||
export const getNodeRelated = ({
|
||||
id,
|
||||
access
|
||||
access,
|
||||
}: {
|
||||
id: number;
|
||||
access: string;
|
||||
}): Promise<IResultWithStatus<{ related: INodeState["related"] }>> =>
|
||||
}): Promise<IResultWithStatus<{ related: INodeState['related'] }>> =>
|
||||
api
|
||||
.get(API.NODE.RELATED(id), configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
|
@ -126,7 +121,7 @@ export const getNodeRelated = ({
|
|||
export const updateNodeTags = ({
|
||||
id,
|
||||
tags,
|
||||
access
|
||||
access,
|
||||
}: ReturnType<typeof nodeUpdateTags> & { access: string }): Promise<
|
||||
IResultWithStatus<{ node: INode }>
|
||||
> =>
|
||||
|
@ -137,9 +132,9 @@ export const updateNodeTags = ({
|
|||
|
||||
export const postNodeLike = ({
|
||||
id,
|
||||
access
|
||||
access,
|
||||
}: ReturnType<typeof nodeLike> & { access: string }): Promise<
|
||||
IResultWithStatus<{ is_liked: INode["is_liked"] }>
|
||||
IResultWithStatus<{ is_liked: INode['is_liked'] }>
|
||||
> =>
|
||||
api
|
||||
.post(API.NODE.POST_LIKE(id), {}, configWithToken(access))
|
||||
|
@ -148,11 +143,23 @@ export const postNodeLike = ({
|
|||
|
||||
export const postNodeStar = ({
|
||||
id,
|
||||
access
|
||||
access,
|
||||
}: ReturnType<typeof nodeStar> & { access: string }): Promise<
|
||||
IResultWithStatus<{ is_liked: INode["is_liked"] }>
|
||||
IResultWithStatus<{ is_liked: INode['is_liked'] }>
|
||||
> =>
|
||||
api
|
||||
.post(API.NODE.POST_STAR(id), {}, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
||||
export const postNodeLock = ({
|
||||
id,
|
||||
is_locked,
|
||||
access,
|
||||
}: ReturnType<typeof nodeLock> & { access: string }): Promise<
|
||||
IResultWithStatus<{ deleted_at: INode['deleted_at'] }>
|
||||
> =>
|
||||
api
|
||||
.post(API.NODE.POST_LOCK(id), { is_locked }, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue