mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Typescript conversion.
This commit is contained in:
parent
366ef35d3d
commit
8775d696b8
29 changed files with 74 additions and 57 deletions
20
src/components/hooks/useShareToken.ts
Normal file
20
src/components/hooks/useShareToken.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import useStore, { setShareToken } from 'store/app';
|
||||
import useApi from './useApi';
|
||||
|
||||
const selector = (state: { shareToken: string }) => state.shareToken;
|
||||
|
||||
export function useShareToken(shareId: string) {
|
||||
const shareToken = useStore(selector);
|
||||
const { get, useQuery } = useApi();
|
||||
const { isLoading, error } = useQuery(['share', shareId], async () => {
|
||||
const data = await get(`/share/${shareId}`);
|
||||
|
||||
setShareToken(data);
|
||||
|
||||
return data;
|
||||
});
|
||||
|
||||
return { shareToken, isLoading, error };
|
||||
}
|
||||
|
||||
export default useShareToken;
|
||||
Loading…
Add table
Add a link
Reference in a new issue