[READ-ONLY] Mirror of https://github.com/hacknug/trovado. A safer way to shop during quarantine trovado.now.sh/
0

Configure Feed

Select the types of activity you want to include in your feed.

Update card stock using remote info

Nestor Vera (May 9, 2020, 1:44 AM +0200) ba767cfb e6b55954

+13 -6
+13 -6
src/components/ShopCard.vue
··· 29 29 <dd class="font-medium"> 30 30 <button 31 31 class="owl:ml-1 inline-flex items-center px-2.5 py-0.5 rounded-md font-medium leading-5 focus:outline-none focus:shadow-outline-blue" 32 - :class="classNames[averageLabels[average]]" 32 + :class="classNames[averageStock]" 33 33 aria-label="See Details" 34 - ><span>{{ averageLabels[average] }}</span> 34 + ><span>{{ averageStock }}</span> 35 35 <ChevronDownIcon class="w-5 h-5" :class="[open && 'transform rotate-180']" /> 36 36 </button> 37 37 </dd> ··· 132 132 edit: false, 133 133 place: null, 134 134 newStock: null, 135 - average: 0, 136 135 sum: null, 137 136 138 137 recipe: { ··· 154 153 return [...this.recipe.stocks].pop() 155 154 }, 156 155 156 + averageStock () { 157 + const labels = ['None', 'Low', 'Medium', 'High'] 158 + const stocks = [ 'sold out', '1-10 qty', '10-30 qty', '+30 qty' ] 159 + const remoteAverage = Object.entries(this.remoteStock) 160 + .filter(([, { availability }]) => availability !== 'no info') 161 + const labelIndex = Math.ceil(remoteAverage.map(([, { availability }]) => availability) 162 + .map((availability) => stocks.indexOf(availability)) 163 + .reduce((acc, val) => acc + val, 0) / remoteAverage.length) 164 + 165 + return labels[labelIndex] || 'Unknown' 166 + }, 157 167 remoteStock () { 158 168 return Object.fromEntries(Object.entries(this.place ? this.place.stock : {}) 159 169 .sort((a, b) => this.recipe.items.indexOf(a[1].product) - this.recipe.items.indexOf(b[1].product))) ··· 166 176 return this.userData && this.userData.favourites && this.userData.favourites[this.shop.id] 167 177 }, 168 178 169 - averageLabels () { 170 - return [ 'Unknown', 'None', 'Low', 'Medium', 'High' ] 171 - }, 172 179 className () { 173 180 return { 174 181 label: [