import { FETCH_STUDENT_DECK, FETCH_STUDENT_DECKS } from '../constants/student-deck';
import { getPeriorityNum } from '../utils/priority';

export function fetchStudentDecks(priority = null, minRate = 0) {
  return {
    type: FETCH_STUDENT_DECKS,
    api: true,
    auth: true,
    payload: {
      method: 'GET',
      url: '/students/student-decks',
      params: { minRate, ...(priority ? { priority: getPeriorityNum(priority) } : {}) }
    }
  };
}

export function fetchStudentDeck(studentDeckId, priority = null, minRate = 0) {
  return {
    type: FETCH_STUDENT_DECK,
    api: true,
    auth: true,
    cache: 15,
    payload: {
      method: 'GET',
      url: `/students/student-decks/${studentDeckId}`,
      params: { minRate, ...(priority ? { priority: getPeriorityNum(priority) } : {}) }
    }
  };
}
