mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00

* fixed paths to match refactored backend * fixed some paths according to new backend * fixed auth urls for new endpoints * fixed urls * fixed error handling * fixes * fixed error handling on user form * fixed error handling on oauth * using fallback: true on node pages * type button for comment attach buttons * fixed return types of social delete * changed the way we upload user avatars
19 lines
600 B
TypeScript
19 lines
600 B
TypeScript
import { useCallback } from 'react';
|
|
|
|
import useSWR from 'swr';
|
|
|
|
import { apiGetNodeRelated } from '~/api/node';
|
|
import { API } from '~/constants/api';
|
|
import { INode } from '~/types';
|
|
import { ApiGetNodeRelatedResult } from '~/types/node';
|
|
|
|
export const useGetNodeRelated = (id?: INode['id']) => {
|
|
const { data, isValidating, mutate } = useSWR<ApiGetNodeRelatedResult>(
|
|
API.NODES.RELATED(id),
|
|
() => apiGetNodeRelated({ id }),
|
|
);
|
|
|
|
const refresh = useCallback(() => mutate(data, true), [data, mutate]);
|
|
|
|
return { related: data?.related, isLoading: isValidating && !data, refresh };
|
|
};
|