course.module.js 608 B

1234567891011121314151617181920212223242526
  1. import * as ACTIONS from "@/store/type/actions.type";
  2. import * as MUTATIONS from "@/store/type/mutations.type.js";
  3. import { getCourseDetail } from "@/api/course";
  4. const courseState = {
  5. currentCourse: {}
  6. };
  7. const actions = {
  8. async [ACTIONS.FETCH_CURRENT_COURSE](context, courseId) {
  9. const { data } = await getCourseDetail(courseId);
  10. context.commit(MUTATIONS.SET_CURRENT_COURSE, data);
  11. }
  12. };
  13. const mutations = {
  14. [MUTATIONS.SET_CURRENT_COURSE](state, courseSerializer = {}) {
  15. state.currentCourse = courseSerializer;
  16. }
  17. };
  18. export default {
  19. state: courseState,
  20. actions,
  21. mutations
  22. };