import { FETCH_CHAPTER } from '../constants/chapter';
import { getPeriorityNum } from '../utils/priority';

export function fetchChapter(chapterId, priority, minRate) {
  return {
    type: FETCH_CHAPTER,
    api: true,
    auth: true,
    payload: {
      method: 'GET',
      url: `/lessons/chapters/${chapterId}`,
      params: {
        ...(priority ? { priority: getPeriorityNum(priority) } : {}),
        ...(minRate >= 0 ? { minRate } : {})
      }
    }
  };
}
