let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
export const setFloorItemApi = async (
  organization: string,
  modelUuid?: string,
  modelName?: string,
  projectId?: string,
  assetId?: string,
  position?: Object,
  rotation?: Object,
  isLocked?: boolean,
  isVisible?: boolean,
) => {
  try {
    const body: any = {
      organization,
      modelUuid,
      modelName,
      position,
      rotation,
      assetId,
      isLocked,
      isVisible,
      projectId,
    };
    const response = await fetch(`${url_Backend_dwinzo}/api/V1/setAsset`, {
      method: "POST",
      headers: {
        Authorization: "Bearer <access_token>",
        "Content-Type": "application/json",
        token: localStorage.getItem("token") || "",
        refresh_token: localStorage.getItem("refreshToken") || "",
      },
      body: JSON.stringify(body),
    });

    if (!response.ok) {
      throw new Error("Failed to set or update Floor Item");
    }

    const result = await response.json();
    return result;
  } catch (error) {
    echo.error("Failed to set floor items");
    if (error instanceof Error) {
      throw new Error(error.message);
    } else {
      throw new Error("An unknown error occurred");
    }
  }
};
