import { Alert } from "react-native";
import { errorRecord } from "../../common/libEventLog/libCrashlytics/libCrashlyticsEvent";
import { SELF_SURVEY_SERVICES_ACTIVITYID } from "../../Api/ApiUrls";
var UserExperior = require("react-native-userexperior");

// instructions
export const getActivityid = async ({ body }) => {
  const url = `${SELF_SURVEY_SERVICES_ACTIVITYID}customer/preInspection`;
  UserExperior.startTimer(url);
  try {
    console.log("URL >>  ", url);
    const res = await fetch(url, {
      headers: {
        "Content-Type": "application/json",
      },
      method: "POST",
      body: JSON.stringify(body),
    });

    let data = await res.json();
    if (res.status !== 200) {
      throw new Error(data?.error);
    }
    UserExperior.endTimer(url);
    return data;
  } catch (err) {
    errorRecord(err);
    console.log(err);
    throw new Error(err?.message);
  }
};
