Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import { useIsMutating } from '@tanstack/react-query'; import { useIntl } from 'react-intl'; import { useMutation } from '@amalia/ext/react-query'; import { toError } from '@amalia/ext/typescript'; import { UserProfileApiClient } from './api-client/user-profile.api-client'; import { userProfileMutationKeys, userProfileQueryKeys } from './queries.keys'; export const useRandomizeAvatar = () => { const { formatMessage } = useIntl(); return useMutation({ mutationKey: userProfileMutationKeys.avatar.randomize(), mutationFn: UserProfileApiClient.randomizeUserAvatar, meta: { successMessage: () => formatMessage({ defaultMessage: 'Your avatar has been successfully edited', }), invalidateQueries: [userProfileQueryKeys.all()], errorMessage: (e) => toError(e).message, }, }); }; export const useUploadAvatar = () => { const { formatMessage } = useIntl(); return useMutation({ mutationKey: userProfileMutationKeys.avatar.upload(), mutationFn: UserProfileApiClient.uploadAvatar, meta: { successMessage: () => formatMessage({ defaultMessage: 'Your avatar has been successfully edited', }), invalidateQueries: [userProfileQueryKeys.all()], errorMessage: (e) => toError(e).message, }, }); }; export const useIsUpdatingAvatar = () => useIsMutating({ mutationKey: userProfileMutationKeys.avatar.all(), }) > 0; |