- Added single school page

This commit is contained in:
Alexis
2020-06-14 21:20:21 +02:00
parent 5c6eca8e10
commit 9e0fb87d44
10 changed files with 97 additions and 31 deletions

View File

@@ -18,6 +18,7 @@ import AddSpellCard from "./add-spell-card"
// API
import { RepositoryFactory } from "../../../api/repositories"
const Spells = RepositoryFactory.get('spells')
const Schools = RepositoryFactory.get('schools')
export default {
name: 'spellslist',
@@ -26,6 +27,9 @@ export default {
'edit-spell-card': EditSpellCard,
'add-spell-card': AddSpellCard,
},
props: {
school_id: String
},
data() {
return {
loading: false,
@@ -39,8 +43,14 @@ export default {
},
methods: {
async fetchSpells() {
const { data } = await Spells.getSpells()
return data
if (!this.school_id) {
const { data } = await Spells.getSpells()
return data
} else {
const { data } = await Schools.getSpellsFromSchool(this.school_id)
console.log(data.spells)
return data.spells
}
},
async computeSpells() {
this.loading = true