generated from posva/vite-tailwind-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(product detail): new basic Product detail page (#55)
* New api getProductById * New page Product detail * Improve PriceCard to work as ProductCard * On PriceCard product click, go to ProductDetail page
- Loading branch information
Showing
5 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<template> | ||
<h1 class="mb-1"> | ||
{{ product ? product.product_name : '' }} | ||
<v-progress-circular v-if="loading" indeterminate :size="30"></v-progress-circular> | ||
</h1> | ||
|
||
<PriceCard v-if="product" :product="product" elevation="1"></PriceCard> | ||
|
||
<br /> | ||
|
||
<h2 class="mb-1">Last prices</h2> | ||
|
||
<v-row> | ||
<v-col cols="12" sm="6" md="4" v-for="price in productPriceList" :key="price"> | ||
<PriceCard :price="price" elevation="1" height="100%"></PriceCard> | ||
</v-col> | ||
</v-row> | ||
</template> | ||
|
||
<script> | ||
import api from '../services/api' | ||
import PriceCard from '../components/PriceCard.vue' | ||
export default { | ||
components: { | ||
PriceCard, | ||
}, | ||
data() { | ||
return { | ||
product: null, | ||
productPriceList: [], | ||
productPriceCount: null, | ||
loading: false, | ||
} | ||
}, | ||
mounted() { | ||
this.getProduct(), | ||
this.getProductPrices() | ||
}, | ||
methods: { | ||
getProduct() { | ||
this.loading = true | ||
return api.getProductById(this.$route.params.id) | ||
.then((data) => { | ||
this.product = data | ||
this.loading = false | ||
}) | ||
}, | ||
getProductPrices() { | ||
this.loading = true | ||
return api.getPrices({ product_id: this.$route.params.id, order_by: '-created' }) | ||
.then((data) => { | ||
this.productPriceList = data.items | ||
this.productPriceCount = data.total | ||
this.loading = false | ||
}) | ||
} | ||
} | ||
} | ||
</script> |