Item images

This commit is contained in:
joycitta-siqueira 2022-04-04 18:20:24 -03:00
parent ad4311d052
commit 87fca8dff2
2 changed files with 17 additions and 3 deletions

View File

@ -9,7 +9,9 @@
<ion-card v-for="item of collectionsStore.items" :key="item.id">
<ion-card-title v-if="item.title"> {{ item.title }} </ion-card-title>
<ion-card-title v-else>Item não possui título</ion-card-title>
<ion-card-content></ion-card-content>
<ion-card-content>
<ion-img :src="item.thumbnail.medium[0]" :alt="item.title"></ion-img>
</ion-card-content>
</ion-card>
</base-layout>
</template>

View File

@ -1,5 +1,5 @@
import { defineStore } from 'pinia';
import axios from 'axios'; //substitui o fetch
import axios from 'axios';
const useCollectionsStore = defineStore('collections', {
state () {
@ -7,6 +7,8 @@ const useCollectionsStore = defineStore('collections', {
collections: [],
items: [],
urlMuseum: '',
userLogin: '',
userPassword: '',
}
},
@ -21,11 +23,21 @@ const useCollectionsStore = defineStore('collections', {
return err;
}
},
async fetchFullCollections() {
try {
const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collections`);
this.collections = response.data;
} catch (err) {
this.collections = [];
console.error('Erro no carregamento das coleções:', err);
return err;
}
},
async fetchItems(collectionId :string) {
try {
this.items = [];
const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collection/${collectionId}/items?perpage=12&orderby=modified`);
const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collection/${collectionId}/items?perpage=12&orderby=modified&fetch_only=id,title,thumbnail`);
this.items = response.data.items;
} catch (err) {
this.items = [];