mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
23 lines
741 B
TypeScript
23 lines
741 B
TypeScript
![]() |
import { ApiKeyApiCreateKeyRequest } from '@jellyfin/sdk/lib/generated-client/api/api-key-api';
|
||
|
import { getApiKeyApi } from '@jellyfin/sdk/lib/utils/api/api-key-api';
|
||
|
import { useMutation } from '@tanstack/react-query';
|
||
|
import { useApi } from 'hooks/useApi';
|
||
|
import { queryClient } from 'utils/query/queryClient';
|
||
|
import { QUERY_KEY } from './useApiKeys';
|
||
|
|
||
|
export const useCreateKey = () => {
|
||
|
const { api } = useApi();
|
||
|
|
||
|
return useMutation({
|
||
|
mutationFn: (params: ApiKeyApiCreateKeyRequest) => (
|
||
|
getApiKeyApi(api!)
|
||
|
.createKey(params)
|
||
|
),
|
||
|
onSuccess: () => {
|
||
|
void queryClient.invalidateQueries({
|
||
|
queryKey: [ QUERY_KEY ]
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
};
|