export default {
data() {
return {
breedSearch: {
query: '',
results: []
}
}
},
methods: {
runBreedSearch() {
this.$axios
.get(this.breedEndpoint, {
params: {
limit: 8,
q: this.breedSearch.query
}
})
.then(res => {
this.breedSearch.results = res.data.filter(breed => breed.description)
})
}
},
}
export default {
data() {
return {
...
resultSorting: {
options: [
['energy_level', 'desc'],
['affection_level', 'desc'],
['dog_friendly', 'desc']
],
selectedOptionIndex: 0
}
}
},
computed: {
sortedResults() {
const selectedOption = this.resultSorting.options[
this.resultSorting.selectedOptionIndex
]
return orderBy(this.productSearch.results, ...selectedOption)
}
},
}
data() {
return {
breedSearch: {
query: '',
results: []
},
resultSorting: {
options: [
['energy_level', 'desc'],
['affection_level', 'desc'],
['dog_friendly', 'desc']
],
selectedOptionIndex: 0
}
}
},
computed: {
sortedResults() {
const selectedOption = this.resultSorting.options[
this.resultSorting.selectedOptionIndex
]
return orderBy(this.breedSearch.results, ...selectedOption)
}
},
methods: {
runBreedSearch() {
this.$axios
.get(this.breedEndpoint, {
params: {
limit: 8,
q: this.breedSearch.query
}
})
.then(res => {
this.breedSearch.results = res.data.filter(breed => breed.description)
})
}
},
const breedSearchMixin = {
data() {
return {
breedSearch: {
query: '',
results: []
}
}
},
methods: {
runBreedSearch() {
this.$axios
.get(this.breedEndpoint, {
params: {
limit: 8,
q: this.breedSearch.query
}
})
.then(res => {
this.breedSearch.results = res.data.filter(breed => breed.description)
})
}
}
}
const breedSortingMixin = {
data() {
return {
resultSorting: {
options: [
['energy_level', 'desc'],
['affection_level', 'desc'],
['dog_friendly', 'desc']
],
selectedOptionIndex: 0
}
}
},
computed: {
sortedResults() {
const selectedOption = this.resultSorting.options[
this.resultSorting.selectedOptionIndex
]
return orderBy(this.breedSearch.results, ...selectedOption)
}
}
}
const breedSearchMixin = {
data() {
return {
breedSearch: {
query: '',
results: []
}
}
},
methods: {
runBreedSearch() {
this.$axios
.get(this.breedEndpoint, {
params: {
limit: 8,
q: this.breedSearch.query
}
})
.then(res => {
this.breedSearch.results = res.data.filter(breed => breed.description)
})
}
}
}
const breedSortingMixin = {
data() {
return {
resultSorting: {
options: [
['energy_level', 'desc'],
['affection_level', 'desc'],
['dog_friendly', 'desc']
],
selectedOptionIndex: 0
}
}
},
computed: {
sortedResults() {
const selectedOption = this.resultSorting.options[
this.resultSorting.selectedOptionIndex
]
return orderBy(this.breedSearch.results, ...selectedOption)
}
}
}
export default {
mixins: [productSearchMixin, resultSortingMixin]
}
<template>
<GenericSearch :get-results="runBreedSearch" v-slot="breedSearch">
<input
:value="breedSearch.query"
@input="breedSearch.set($event.target.value)"
@keyup.enter="breedSearch.run"
/>
<BreedCard
v-for="breed in breedSearch.results"
:key="breed.id"
:breed="breed"
/>
</GenericSearch>
</template>