CategoryContainer.js 750 Bytes
import React from "react";
import CategoryPresenter from "./CategoryPresenter";
import { withRouter } from "react-router-dom";
import { useMutation, useQuery } from "@apollo/react-hooks";
import {
  GET_CATEGORIRES,
  ADD_CATEGORY,
  EDIT_CATEGORY,
  DELETE_CATEGORY,
} from "./CategoryQueries";

export default withRouter(({ location }) => {
  const { data } = useQuery(GET_CATEGORIRES);
  const [addCategory] = useMutation(ADD_CATEGORY);
  const [editCategory] = useMutation(EDIT_CATEGORY);
  const [deleteCategory] = useMutation(DELETE_CATEGORY);

  let categories;
  if (data !== undefined) {
    const { getCategories } = data;
    categories = getCategories;
  }

  return <CategoryPresenter location={location} categories={categories} />;
});