import { CREATE_STUDENT, FETCH_STUDENT, UPDATE_STUDENT } from '../constants/student';
import { CREATE_STUDENT_URL, FETCH_STUDENT_URL, UPDATE_STUDENT_URL } from '../urls/student';

export function createStudent(data) {
  return {
    type: CREATE_STUDENT,
    api: true,
    auth: true,
    payload: {
      method: 'POST',
      url: CREATE_STUDENT_URL,
      data
    }
  };
}

export function fetchStudent() {
  return {
    type: FETCH_STUDENT,
    api: true,
    auth: true,
    cache: 5 * 60,
    payload: {
      method: 'GET',
      url: FETCH_STUDENT_URL
    }
  };
}

export function updateStudentNickName(nickName) {
  return {
    type: UPDATE_STUDENT,
    api: true,
    auth: true,
    payload: {
      method: 'PATCH',
      url: UPDATE_STUDENT_URL,
      data: { nickName }
    }
  };
}

export function updateStudentNotify(notify) {
  return {
    type: UPDATE_STUDENT,
    api: true,
    auth: true,
    payload: {
      method: 'PATCH',
      url: UPDATE_STUDENT_URL,
      data: { notify }
    }
  };
}
