Most of submit code is OK now, just not yet pushing through API
This commit is contained in:
parent
b600d97e44
commit
a5ed530081
@ -59,8 +59,14 @@ function missingCategories() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateCategories(productId, categories) {
|
||||||
|
// TODO
|
||||||
|
console.log(productId, categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function missingBrands() {
|
function missingBrands() {
|
||||||
return fetch(`${BASEURL}state/brands-to-be-completed.json`)
|
return _fetchFromOFFApi(['state/brands-to-be-completed'])
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(response => response.products.map(product => ({
|
.then(response => response.products.map(product => ({
|
||||||
id: product.id,
|
id: product.id,
|
||||||
@ -72,7 +78,7 @@ function missingBrands() {
|
|||||||
|
|
||||||
|
|
||||||
function missingProductName() {
|
function missingProductName() {
|
||||||
return fetch(`${BASEURL}state/product-name-to-be-completed.json`)
|
return _fetchFromOFFApi(['state/product-name-to-be-completed'])
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(response => response.products.map(product => ({
|
.then(response => response.products.map(product => ({
|
||||||
id: product.id,
|
id: product.id,
|
||||||
@ -83,4 +89,4 @@ function missingProductName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export { missingBrands, missingCategories, missingProductName };
|
export { missingBrands, missingCategories, updateCategories, missingProductName };
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
</v-layout>
|
</v-layout>
|
||||||
<v-layout row>
|
<v-layout row>
|
||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<v-btn>submit</v-btn>
|
<v-btn @click="handleSubmit()">Submit</v-btn>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-container>
|
</v-container>
|
||||||
@ -53,12 +53,24 @@
|
|||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
data: Object,
|
data: Object,
|
||||||
|
onSubmit: Function,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dialog: false,
|
dialog: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
handleSubmit() {
|
||||||
|
const okCategories = [];
|
||||||
|
Object.keys(this.data.predictedCategories).forEach((key) => {
|
||||||
|
if (this.data.predictedCategories[key].isOk) {
|
||||||
|
okCategories.push(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.onSubmit(okCategories);
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { updateCategories } from '../api';
|
||||||
import * as types from './mutations-types';
|
import * as types from './mutations-types';
|
||||||
import quests from './quests';
|
import quests from './quests';
|
||||||
|
|
||||||
@ -17,4 +18,16 @@ export default {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validateQuest({ commit }, { type, id, solution }) {
|
||||||
|
if (type === 'missingCategories') {
|
||||||
|
updateCategories(id, solution).then(() => commit(
|
||||||
|
types.VALIDATE_QUEST,
|
||||||
|
{
|
||||||
|
type,
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -11,8 +11,10 @@ function popQuest(state) {
|
|||||||
if (availableQuests.length === 0) {
|
if (availableQuests.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const randomQuestsList = pickRandomFromArray(availableQuests);
|
const randomQuestsType = pickRandomFromArray(availableQuests);
|
||||||
return pickRandomFromArray(state.questsItems[randomQuestsList]);
|
const randomQuest = pickRandomFromArray(state.questsItems[randomQuestsType]);
|
||||||
|
randomQuest.type = randomQuestsType;
|
||||||
|
return randomQuest;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { popQuest };
|
export default { popQuest };
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export const IS_LOADING_QUESTS = 'IS_LOADING_QUESTS';
|
export const IS_LOADING_QUESTS = 'IS_LOADING_QUESTS';
|
||||||
export const STORE_QUESTS_ITEMS = 'STORE_QUESTS_ITEMS';
|
export const STORE_QUESTS_ITEMS = 'STORE_QUESTS_ITEMS';
|
||||||
|
export const VALIDATE_QUEST = 'VALIDATE_QUEST';
|
||||||
|
@ -14,4 +14,9 @@ export const mutations = {
|
|||||||
[types.STORE_QUESTS_ITEMS](state, { type, items }) {
|
[types.STORE_QUESTS_ITEMS](state, { type, items }) {
|
||||||
Vue.set(state.questsItems, type, items);
|
Vue.set(state.questsItems, type, items);
|
||||||
},
|
},
|
||||||
|
[types.VALIDATE_QUEST](state, { id, type }) {
|
||||||
|
const items = state.questsItems[type];
|
||||||
|
delete items[id];
|
||||||
|
Vue.set(state.questsItems, type, items);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<QuestMissingCategories v-if="questData" :data="questData" />
|
<QuestMissingCategories v-if="questData" :data="questData" :onSubmit="validateQuest" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -18,6 +18,13 @@ export default {
|
|||||||
fetchData() {
|
fetchData() {
|
||||||
this.$store.dispatch('preloadQuests');
|
this.$store.dispatch('preloadQuests');
|
||||||
},
|
},
|
||||||
|
validateQuest(solution) {
|
||||||
|
this.$store.dispatch('validateQuest', {
|
||||||
|
type: this.questData.type,
|
||||||
|
id: this.questData.id,
|
||||||
|
solution,
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
questData() {
|
questData() {
|
||||||
|
Loading…
Reference in New Issue
Block a user