UNPKG

@azuro-org/sdk

Version:

One-stop solution for building betting dApps on the Azuro Protocol.

42 lines (41 loc) 1.73 kB
import { type Address } from 'viem'; import { type ChainId, type DeleteUserFavoriteResult } from '@azuro-org/toolkit'; export type UseDeleteUserFavoriteProps = { affiliate: Address; chainId?: ChainId; onSuccess?: (data: DeleteUserFavoriteResult) => void; onError?: (err: Error) => void; }; export type DeleteUserFavoriteVariables = { favoritesId: string; }; /** * Remove a user favorite by its server-assigned ID. Reads the current SIWE token from * localStorage via `readAuth`. If the wallet is not connected the mutation throws * `AuthError('NoWallet')`; if no valid token is cached it throws * `AuthError('NotAuthenticated')` — call `useAuth().signIn()` and retry. * * After a successful deletion the `user/favorites` query is automatically invalidated * so dependent `useUserFavorites` hooks refetch. * * - Docs: https://gem.azuro.org/hub/apps/sdk/user/useDeleteUserFavorite * * @example * import { useAuth, useDeleteUserFavorite } from '@azuro-org/sdk' * * const { signIn, isAuthenticated } = useAuth({ affiliate: '0x...' }) * const { remove, isPending, error } = useDeleteUserFavorite({ affiliate: '0x...' }) * * const handleRemove = async (favoritesId: string) => { * if (!isAuthenticated) { * await signIn() * } * remove({ favoritesId }) * } * */ export declare const useDeleteUserFavorite: (props: UseDeleteUserFavoriteProps) => { remove: import("@tanstack/react-query").UseMutateFunction<DeleteUserFavoriteResult, Error, DeleteUserFavoriteVariables, unknown>; removeAsync: import("@tanstack/react-query").UseMutateAsyncFunction<DeleteUserFavoriteResult, Error, DeleteUserFavoriteVariables, unknown>; isPending: boolean; error: Error | null; };