"use client";
import { useState } from "react";
const useSubgraphSort = (defaultOrderBy, defaultOrderDirection) => {
  const [orderBy, setOrderBy] = useState(defaultOrderBy);
  const [orderDirection, setOrderDirection] = useState(defaultOrderDirection);
  const handleSort = (dataIndex) => {
    if (dataIndex !== orderBy) {
      setOrderBy(dataIndex);
      setOrderDirection(defaultOrderDirection);
    } else {
      if (orderDirection === "asc") {
        setOrderDirection("desc");
      } else {
        setOrderDirection("asc");
      }
    }
  };
  return {
    orderBy,
    orderDirection,
    handleSort
  };
};
export {
  useSubgraphSort
};
