A decentralized music tracking and discovery platform built on AT Protocol 馃幍
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
1import { useMutation, useQuery } from "@tanstack/react-query";
2import {
3 createApiKey,
4 deleteApiKey,
5 getApiKeys,
6 updateApiKey,
7} from "../api/apikeys";
8
9export const useCreateApikeyMutation = () =>
10 useMutation({
11 mutationFn: ({
12 name,
13 description,
14 }: {
15 name: string;
16 description?: string;
17 }) => createApiKey(name, description),
18 });
19
20export const useApikeysQuery = (offset?: number, size?: number) =>
21 useQuery({
22 queryKey: ["apikeys", offset, size],
23 queryFn: () => getApiKeys(offset, size),
24 select: (response) => response.data,
25 });
26
27export const useDeleteApikeyMutation = () =>
28 useMutation({
29 mutationFn: deleteApiKey,
30 });
31
32export const useUpdateApikeyMutation = () =>
33 useMutation({
34 mutationFn: ({
35 id,
36 enabled,
37 name,
38 description,
39 }: {
40 id: string;
41 enabled: boolean;
42 name?: string;
43 description?: string;
44 }) => updateApiKey(id, enabled, name, description),
45 });