import { getOrGenerateMicroLearning, regenerateMicroLearning } from '../lib/microLearningService';

export function useMicroLearnings() {
  /**
   * Get or generate a micro learning for the given topic and type.
   * Returns a PocketBase record with .content ready to render.
   */
  const getOrGenerate = async (topicId, type) => {
    return getOrGenerateMicroLearning(topicId, type);
  };

  /**
   * Force regeneration of a micro learning (deletes cached version first).
   */
  const regenerate = async (topicId, type) => {
    return regenerateMicroLearning(topicId, type);
  };

  return { getOrGenerate, regenerate };
}
