-
Notifications
You must be signed in to change notification settings - Fork 4
/
IndexPage.vue
45 lines (42 loc) · 1.12 KB
/
IndexPage.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<template>
<div class="q-pa-md">
<q-list separator v-if="recipes.length > 0">
<q-item
clickable
v-ripple
v-for="recipe of recipes"
:key="recipe.id"
:to="`/recipe/${recipe.id}`"
>
<q-item-section>
<q-item-label overline>{{ recipe.name }}</q-item-label>
<q-item-label caption>{{
recipe.nutritionInformation?.slice(0, 20) + '...'
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
<div
class="column flex-center items-center q-pa-md"
style="height: 100vh; width: 100%"
v-else
>
<div class="col-12 self-center" style="height: 100px">
<q-btn
to="/add-recipe"
color="primary"
icon-right="local_dining"
label="Add a recipe"
/>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useDatabaseStore } from 'src/stores/database';
const store = useDatabaseStore();
const { recipes } = storeToRefs(store);
const { fetchAllRecipes } = store;
fetchAllRecipes();
</script>