{"size": 920, "ext": "js", "max_stars_repo_path": "src/pages/Details/js/api.js", "max_stars_repo_name": "matheusmhq/conectando-socios-react-js", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/pages/Details/js/api.js", "max_issues_repo_name": "matheusmhq/conectando-socios-react-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/pages/Details/js/api.js", "max_forks_repo_name": "matheusmhq/conectando-socios-react-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.8648648649, "max_line_length": 74, "alphanum_fraction": 0.5608695652}
import api from "services/api";
import { alertDispatch } from "store/dispatchs/dispatchs";

export const getProject = (id, setProject, user, history, setLoading) => {
  setLoading(true);
  api
    .get(`/project/${id}`, {
      params: {
        idUser: user.data.id,
      },
    })
    .then((response) => {
      if (response.status == 200) {
        setProject(response.data.project);
      }
    })
    .catch((error) => {
      alertDispatch("error", error?.response?.data?.message);
      history.push("/");
    })
    .finally(() => setLoading(false));
};

export const deleteProject = (project, history) => {
  api
    .delete(`/project/${project.id}`)
    .then((response) => {
      if (response.status == 200) {
        alertDispatch("success", response.data.message);
        history.push("/");
      }
    })
    .catch((error) => {
      alertDispatch("error", error?.response?.data?.message);
    });
};
