import { ElectedCouncilOrderByInput, GetElectedCouncilsQueryVariables, useGetElectedCouncilsQuery } from '@/queries';
import { asElectedCouncil } from '@/graphtypes';

export const useElectedCouncils = ({
  orderBy = ElectedCouncilOrderByInput.CreatedAtDesc,
  ...rest
}: GetElectedCouncilsQueryVariables) => {
  const { data, error, loading } = useGetElectedCouncilsQuery({ variables: { orderBy, ...rest } });

  return { error, loading, data: data?.electedCouncils.map(asElectedCouncil) };
};
