All files / react-app/src/api useCreateUserProfile.ts

80% Statements 8/10
100% Branches 0/0
33.33% Functions 1/3
80% Lines 8/10

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                          5x 7x 7x   4x   3x     3x 3x       5x        
import { useMutation } from "@tanstack/react-query";
import { API } from "aws-amplify";
import { UserRole } from "shared-types/events/legacy-user";
 
import { sendGAEvent } from "@/utils/ReactGA/SendGAEvent";
export type UserDetails = {
  id: string;
  eventType: string;
  email: string;
  fullName: string;
  role: UserRole;
};
 
export const createUserProfile = async (): Promise<unknown> => {
  try {
    const userDetails = await API.get("os", "/createUserProfile", {});
 
    return userDetails as UserDetails;
  } catch (e) {
    sendGAEvent("api_error", {
      message: "failure /createUserProfile",
    });
    console.log({ e });
    return null;
  }
};
 
export const useCreateUserProfile = () =>
  useMutation({
    mutationFn: () => createUserProfile(),
  });