import { ARCHIVE_STUDENT_CARD, UPDATE_STUDENT_CARD_RATE } from '../constants/student-card';

export function archiveStudentCard() {
  return function (dispatch, getState) {
    const studentCardId = getState().review.data.studentCard.id;
    return dispatch({
      type: ARCHIVE_STUDENT_CARD,
      api: true,
      auth: true,
      payload: {
        method: 'PATCH',
        url: `/students/student-cards/${studentCardId}/archive`
      }
    });
  };
}

export function updateStudentCardRate(studentCardId, rate) {
  return {
    type: UPDATE_STUDENT_CARD_RATE,
    api: true,
    auth: true,
    payload: {
      method: 'PATCH',
      url: `/students/student-cards/${studentCardId}`,
      data: { rate }
    }
  };
}
