feat: mfa reset - wip

This commit is contained in:
Philipinho
2025-07-24 16:11:22 -07:00
parent d789ba3ffa
commit f5246d544d
5 changed files with 82 additions and 6 deletions
@@ -18,6 +18,7 @@ import {
getAppVersion,
deleteWorkspaceMember,
} from "@/features/workspace/services/workspace-service";
import { resetUserMfa } from "@/ee/mfa";
import { IPagination, QueryParams } from "@/lib/types.ts";
import { notifications } from "@mantine/notifications";
import {
@@ -192,3 +193,29 @@ export function useAppVersion(
refetchOnMount: true,
});
}
export function useResetUserMfaMutation() {
const { t } = useTranslation();
const queryClient = useQueryClient();
return useMutation<
{ success: boolean },
Error,
{ userId: string }
>({
mutationFn: ({ userId }) => resetUserMfa(userId),
onSuccess: () => {
notifications.show({
message: t("MFA has been reset successfully"),
color: "green"
});
queryClient.invalidateQueries({
queryKey: ["workspaceMembers"],
});
},
onError: (error) => {
const errorMessage = error["response"]?.data?.message || t("Failed to reset MFA");
notifications.show({ message: errorMessage, color: "red" });
},
});
}