rework recipes and random generation pt. 2
This commit is contained in:
@@ -35,9 +35,7 @@
|
|||||||
<!-- input field -->
|
<!-- input field -->
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<v-app>
|
|
||||||
|
|
||||||
</v-app>
|
|
||||||
<v-container
|
<v-container
|
||||||
fluid
|
fluid
|
||||||
dark
|
dark
|
||||||
@@ -137,6 +135,11 @@ const Recipes = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.populateRecipes()
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
populateFromFridge() {
|
||||||
api.getRecipesForFridge()
|
api.getRecipesForFridge()
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$log.debug("Data loaded: ", response.data)
|
this.$log.debug("Data loaded: ", response.data)
|
||||||
@@ -149,16 +152,43 @@ const Recipes = {
|
|||||||
.finally(() => this.loading = false)
|
.finally(() => this.loading = false)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
populateRandom() {
|
||||||
|
api.getRandom()
|
||||||
|
.then(response => {
|
||||||
|
this.$log.debug("Data loaded: ", response.data)
|
||||||
|
this.recipes = response.data
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.$log.debug(error)
|
||||||
|
this.error = "Failed to load recipes"
|
||||||
|
})
|
||||||
|
.finally(() => this.loading = false)
|
||||||
|
},
|
||||||
|
|
||||||
|
populateRecipes() {
|
||||||
|
api.getAll()
|
||||||
|
.then(response => {
|
||||||
|
this.$log.debug("Data loaded: ", response.data)
|
||||||
|
this.items = response.data
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.$log.debug(error)
|
||||||
|
this.error = "Failed to load items"
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
if (this.items.length > 3) {
|
||||||
|
this.populateFromFridge()
|
||||||
|
} else {
|
||||||
|
this.populateRandom()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
export default Recipes
|
export default Recipes
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200&display=swap');
|
||||||
|
|||||||
Reference in New Issue
Block a user