charts fetch data + cards
This commit is contained in:
parent
9f0c6a8ad4
commit
7b1214e42f
3 changed files with 71 additions and 2 deletions
|
|
@ -1,9 +1,41 @@
|
|||
<script setup lang="ts">
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useChartsApi } from '@/api/charts.js'
|
||||
import ChartsCard from '@/views/ChartsView/ChartsCard.vue'
|
||||
|
||||
const { getChartsPrices } = useChartsApi()
|
||||
|
||||
const pricesList = ref(null)
|
||||
const loading = ref(true)
|
||||
const error = ref(null)
|
||||
|
||||
const fetchPrices = async () => {
|
||||
try {
|
||||
const response = await getChartsPrices(7)
|
||||
pricesList.value = response.data
|
||||
if (!response.status === 400) {
|
||||
router.push({ name: 'collection' })
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchPrices()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
Charts view
|
||||
<n-grid responsive="screen" cols="1 s:1 m:2 l:2 xl:2 2xl:2" class="grid-main">
|
||||
<n-gi class="grid-item" v-for="item in pricesList" :key="item.merch_uuid">
|
||||
<router-link :to="`/details/${item.merch_uuid}`" class="card-link">
|
||||
<ChartsCard :chartsData="item" />
|
||||
</router-link>
|
||||
</n-gi>
|
||||
</n-grid>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue