sajjad 3 years ago
parent d4e46975c5
commit f6a9728bb0

@ -2,7 +2,13 @@ import axios from "axios";
import url from "@/router/url"; import url from "@/router/url";
import { getArray, getJson } from "../resources/sportCategoryResource"; import { getArray, getJson } from "../resources/sportCategoryResource";
export default class SportCategoryRepository { export default class SportCategoryRepository {
async index() { async index(data) {
let response = await axios.get(url("indexSportCategories"), { params: data });
if (response.status === 200) {
return getArray(response.data);
}
}
async trainerIndex() {
let response = await axios.get(url("indexClientSportCategories")); let response = await axios.get(url("indexClientSportCategories"));
if (response.status === 200) { if (response.status === 200) {
return getArray(response.data); return getArray(response.data);

@ -7,7 +7,7 @@ export const getJson = (data) => ({
trainer_id: data.trainer_id, trainer_id: data.trainer_id,
sport_category: data.trainer ? getJsonSportCategory(data.trainer) : {}, sport_category: data.trainer ? getJsonSportCategory(data.trainer) : {},
sport_category_id: data.sport_category_id, sport_category_id: data.sport_category_id,
workout_category_id: data.workout_category?.id, program_category_id: data.sport_category?.parent?.id,
thumbnail: data.thumbnail, thumbnail: data.thumbnail,
verified: data.verified, verified: data.verified,
status: data.status, status: data.status,
@ -22,7 +22,6 @@ export const getJson = (data) => ({
}); });
export const setData = (data) => ({ export const setData = (data) => ({
sport_category_id: data.sport_category_id, sport_category_id: data.sport_category_id,
workout_category_id: data.workout_category_id,
title: data.title, title: data.title,
description: data.description, description: data.description,
tags: data.tags, tags: data.tags,

@ -9,4 +9,3 @@ export const getArray = ({ data }) => {
data = data.map((category) => getJson(category)); data = data.map((category) => getJson(category));
return { data }; return { data };
}; };

@ -11,7 +11,7 @@
<v-row> <v-row>
<v-col cols="3"> <v-col cols="3">
<div> <div>
<div class="series__name"> <div class="series__name" :title="series.name">
series {{ seriesNumber }}: {{ series.name }} series {{ seriesNumber }}: {{ series.name }}
</div> </div>
</div> </div>
@ -49,6 +49,7 @@
width="48" width="48"
class="ml-1 custom-btn" class="ml-1 custom-btn"
icon="WMi-pencil" icon="WMi-pencil"
@click.native.prevent="$_openModal('add_series', { data: series })"
/> />
<RectangleButton <RectangleButton
v-if="role === 'admin'" v-if="role === 'admin'"

@ -35,7 +35,7 @@
item-value="id" item-value="id"
label="program category" label="program category"
:items="getSportCategories" :items="getSportCategories"
v-model="form.sport_category_id" v-model="form.program_category_id"
@change="changeSportCategories" @change="changeSportCategories"
></v-autocomplete> ></v-autocomplete>
</v-col> </v-col>
@ -46,8 +46,8 @@
item-text="name" item-text="name"
item-value="id" item-value="id"
label="workout subcategory" label="workout subcategory"
:items="getWorkoutCategories" :items="getSubSportCategories"
v-model="form.workout_category_id" v-model="form.sport_category_id"
></v-autocomplete> ></v-autocomplete>
</v-col> </v-col>
<v-col cols="3" <v-col cols="3"
@ -170,8 +170,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapGetters("sportCategories", ["getSportCategories"]), ...mapGetters("sportCategories", ["getSportCategories", "getSubSportCategories"]),
...mapGetters("workoutCategories", ["getWorkoutCategories"]),
...mapGetters("programs", ["getProgram"]), ...mapGetters("programs", ["getProgram"]),
programId() { programId() {
return this.$route.params.id; return this.$route.params.id;
@ -185,7 +184,6 @@ export default {
}, },
methods: { methods: {
...mapActions("sportCategories", ["loadSportCategories"]), ...mapActions("sportCategories", ["loadSportCategories"]),
...mapActions("workoutCategories", ["loadWorkoutCategories"]),
...mapActions("programs", ["addProgram", "updateProgram", "loadProgram"]), ...mapActions("programs", ["addProgram", "updateProgram", "loadProgram"]),
async submit() { async submit() {
try { try {
@ -215,10 +213,10 @@ export default {
this.form = this.getProgram; this.form = this.getProgram;
this.form["batch_id"] = RANDOM_TOKEN; this.form["batch_id"] = RANDOM_TOKEN;
// this.perviousCropData = this.fileForm.crop_data; // this.perviousCropData = this.fileForm.crop_data;
await this.loadWorkoutCategories(this.form.sport_category_id); await this.loadSportCategories(this.form.program_category_id);
}, },
async changeSportCategories() { async changeSportCategories() {
await this.loadWorkoutCategories(this.form.sport_category_id); await this.loadSportCategories(this.form.program_category_id);
}, },
removeTags(item) { removeTags(item) {
this.form.tags.splice(this.form.tags.indexOf(item), 1); this.form.tags.splice(this.form.tags.indexOf(item), 1);

@ -1,9 +1,11 @@
import SportCategoryRepository from "@/abstraction/repository/sportCategoryRepository"; import SportCategoryRepository from "@/abstraction/repository/sportCategoryRepository";
import { UserStorage } from "@/utils/storage";
let role = UserStorage.getRole() ? UserStorage.getRole() : null;
export default { export default {
async loadSportCategories({ commit }) { async loadSportCategories({ commit }, parentId) {
let repository = new SportCategoryRepository(); let repository = new SportCategoryRepository();
const resource = await repository.index(); const resource = role === 'admin' ? await repository.index({ parent_id: parentId }) : await repository.trainerIndex({ parent_id: parentId });
commit("SET_SPORT_CATEGORIES", resource.data); parentId ? commit("SET_SUB_SPORT_CATEGORIES", resource.data) : commit("SET_SPORT_CATEGORIES", resource.data);
}, },
async loadSportCategory({ commit }, sportCategoryId) { async loadSportCategory({ commit }, sportCategoryId) {
let repository = new SportCategoryRepository(); let repository = new SportCategoryRepository();

@ -1,4 +1,5 @@
export default { export default {
getSportCategories: state => state.sportCategories, getSportCategories: state => state.sportCategories,
getSubSportCategories: state => state.subSportCategories,
getSportCategory: state => state.sportCategory, getSportCategory: state => state.sportCategory,
} }

@ -3,6 +3,9 @@ export default {
SET_SPORT_CATEGORIES(state, payload) { SET_SPORT_CATEGORIES(state, payload) {
Vue.set(state, "sportCategories", payload); Vue.set(state, "sportCategories", payload);
}, },
SET_SUB_SPORT_CATEGORIES(state, payload) {
Vue.set(state, "subSportCategories", payload);
},
SET_SPORT_CATEGORY(state, payload) { SET_SPORT_CATEGORY(state, payload) {
Vue.set(state, "sportCategory", payload); Vue.set(state, "sportCategory", payload);
}, },

@ -1,4 +1,5 @@
export default { export default {
sportCategories: [], sportCategories: [],
sportCategory: [] subSportCategories: [],
sportCategory: [],
}; };

Loading…
Cancel
Save