mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
made useGetNodeRelated use apiGetNodeRelated
This commit is contained in:
parent
c2d1c2bfc9
commit
5b2bf82d48
1 changed files with 4 additions and 5 deletions
|
@ -1,18 +1,17 @@
|
|||
import { INode } from '~/redux/types';
|
||||
import useSWR from 'swr';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { ApiGetNodeRelatedResult } from '~/redux/node/types';
|
||||
import { API } from '~/constants/api';
|
||||
import { api } from '~/utils/api';
|
||||
import { useCallback } from 'react';
|
||||
import { apiGetNodeRelated } from '~/redux/node/api';
|
||||
|
||||
export const useGetNodeRelated = (id?: INode['id']) => {
|
||||
const { data, isValidating: isLoading, mutate } = useSWR<AxiosResponse<ApiGetNodeRelatedResult>>(
|
||||
const { data, isValidating: isLoading, mutate } = useSWR<ApiGetNodeRelatedResult>(
|
||||
API.NODE.RELATED(id),
|
||||
api.get
|
||||
() => apiGetNodeRelated({ id })
|
||||
);
|
||||
|
||||
const refresh = useCallback(() => mutate(data, true), [data, mutate]);
|
||||
|
||||
return { related: data?.data.related, isLoading, refresh };
|
||||
return { related: data?.related, isLoading, refresh };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue