import { useAuth } from 'src/contexts/JWTContext';
import { type CommunityFeature } from 'src/types/communityFeatures';

const useCommunityFeature = (
  communityFeature?: keyof typeof CommunityFeature,
): boolean => {
  const { communityFeatures } = useAuth();

  if (!communityFeature) {
    return false;
  }

  return (
    communityFeatures?.includes(communityFeature as CommunityFeature) ?? false
  );
};

export default useCommunityFeature;
