Skip to content

Commit

Permalink
feat(Date detail): new page with prices for a given date (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn authored Jul 5, 2024
1 parent 50bad61 commit dc275e7
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/DateChip.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-chip label size="small" prepend-icon="mdi-camera" density="comfortable" :color="dateMissingAndShowError ? 'error' : 'default'">
<v-chip label size="small" prepend-icon="mdi-calendar-today" density="comfortable" :color="dateMissingAndShowError ? 'error' : 'default'">
<span v-if="date">{{ getDateFormatted(date) }}</span>
<span v-else-if="dateMissingAndShowError">
<i class="text-lowercase">{{ $t('Common.Date') }}</i>
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
],
PRICE_ORDER_LIST: [
{ key: 'price', value: 'OrderPriceASC', icon: 'mdi-order-numeric-ascending' },
{ key: '-date', value: 'OrderPriceDateDESC', icon: 'mdi-calendar' },
{ key: '-date', value: 'OrderPriceDateDESC', icon: 'mdi-calendar-today' },
{ key: '-created', value: 'OrderPriceCreatedDESC', icon: 'mdi-clock-outline' },
],
OSM_NAME: 'OpenStreetMap',
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
"Currency": "Currency",
"CurrencyMissing": "Currency missing",
"Language": "Languages",
"LatestPrices": "Latest prices",
"LoadMore": "Load more",
"Location": "Location",
"Locations": "Locations",
"LocationMissing": "Location missing",
Expand All @@ -139,6 +141,8 @@
"OrderPriceASC": "Price",
"OrderPriceCreatedDESC": "Addition date",
"OrderPriceDateDESC": "Price date",
"PriceCount": "{count} prices",
"ProductCount": "{count} products",
"SignInOFFAccount": "Sign in with your {url} account",
"Source": "Source",
"Type": "Type",
Expand Down
1 change: 1 addition & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const routes = [
{ path: '/locations', name: 'locations', component: () => import('./views/LocationList.vue'), meta: { title: 'TopLocations', icon: 'mdi-map-marker-star-outline', drawerMenu: true }},
{ path: '/locations/:id', name: 'location-detail', component: () => import('./views/LocationDetail.vue'), meta: { title: 'Location detail' }},
{ path: '/brands/:id', name: 'brand-detail', component: () => import('./views/BrandDetail.vue'), meta: { title: 'Brand detail' }},
{ path: '/dates/:date', name: 'date-detail', component: () => import('./views/DateDetail.vue'), meta: { title: 'Date detail' }},
{ path: '/categories/:id', name: 'category-detail', component: () => import('./views/CategoryDetail.vue'), meta: { title: 'Category detail' }},
{ path: '/proofs/add/single', name: 'proof-add', component: () => import('./views/ProofAddSingle.vue'), meta: { title: 'ProofAddSingle', icon: 'mdi-plus', color: 'primary', requiresAuth: true }},
{ path: '/proofs/:id', name: 'proof-detail', component: () => import('./views/ProofDetail.vue'), meta: { title: 'Proof detail', requiresAuth: true }},
Expand Down
99 changes: 99 additions & 0 deletions src/views/DateDetail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<v-row>
<v-col cols="12" sm="6">
<v-card
:title="date"
prepend-icon="mdi-calendar-today"
>
<v-card-text>
<v-chip label size="small" density="comfortable" class="mr-1">
<v-icon start icon="mdi-food-outline" />
{{ $t('Common.PriceCount', { count: datePriceTotal }) }}
</v-chip>
</v-card-text>
</v-card>
</v-col>
</v-row>

<v-row class="mt-0">
<v-col cols="12">
<ShareButton />
</v-col>
</v-row>

<br>

<v-row>
<v-col>
<h2 class="text-h6 d-inline mr-2">
{{ $t('Common.LatestPrices') }}
</h2>
<v-progress-circular v-if="loading" indeterminate :size="30" />
</v-col>
</v-row>

<v-row class="mt-0">
<v-col v-for="price in datePriceList" :key="price" cols="12" sm="6" md="4">
<PriceCard :price="price" :product="price.product" :hidePriceLocation="true" elevation="1" height="100%" />
</v-col>
</v-row>

<v-row v-if="datePriceList.length < datePriceTotal" class="mb-2">
<v-col align="center">
<v-btn size="small" :loading="loading" @click="getDatePrices">
{{ $t('Common.LoadMore') }}
</v-btn>
</v-col>
</v-row>
</template>

<script>
import { defineAsyncComponent } from 'vue'
import api from '../services/api'
export default {
components: {
PriceCard: defineAsyncComponent(() => import('../components/PriceCard.vue')),
ShareButton: defineAsyncComponent(() => import('../components/ShareButton.vue'))
},
data() {
return {
// data
date: null, // see init
datePriceList: [],
datePriceTotal: null,
datePricePage: 0,
loading: false,
}
},
watch: {
$route (newDate, oldDate) {
if (oldDate && newDate && newDate.name == 'date-detail' && oldDate.fullPath != newDate.fullPath) {
this.initDate()
}
}
},
mounted() {
this.initDate()
},
methods: {
initDate() {
this.date = this.$route.params.date
this.datePriceList = []
this.datePriceTotal = null
this.datePricePage = 0
this.getDatePrices()
},
getDatePrices() {
this.loading = true
this.datePricePage += 1
return api.getPrices({ date: this.date, page: this.datePricePage })
.then((data) => {
this.datePriceList.push(...data.items)
this.datePriceTotal = data.total
this.loading = false
})
},
}
}
</script>

0 comments on commit dc275e7

Please sign in to comment.