Compare commits

..

2 Commits

Author SHA1 Message Date
e0dcfa6964 Finish bar utility 2025-11-22 17:43:25 +01:00
Janis Hutz
69d2db8c37 Update BarView.vue
Fix bar config caching
2025-11-22 12:40:11 +00:00
2 changed files with 18 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
{
"ages": {
"below": "red",
"16-18": "",
"18+": ""
"below": "Orange",
"16-18": "Yellow",
"18+": "Turquoise"
},
"offering": {
"big-bar": {

View File

@@ -50,7 +50,9 @@
let cashinInDepot = false;
fetch( '/bar-config.json' ).then( res => {
fetch( '/bar-config.json', {
'cache': 'no-store'
} ).then( res => {
if ( res.status === 200 ) {
res.json().then( json => {
const data: FullConfig = json;
@@ -83,18 +85,22 @@
const keys = Object.keys( selection.value );
let totalPrice = 0;
let totalDepot = 0;
for ( let i = 0; i < keys.length; i++ ) {
const o = selection.value[ keys[ i ] ];
totalPrice += o * offering.value[ selectedBar.value ].offering[ keys[ i ] ].price;
totalPrice += o * ( offering.value[ selectedBar.value ].offering[ keys[ i ] ].depot ?? 0 );
if ( ( offering.value[ selectedBar.value ].offering[ keys[ i ] ].depot ?? 0 ) > 0 && o > 0 )
cashinInDepot = true;
totalDepot += o * ( offering.value[ selectedBar.value ].offering[ keys[ i ] ].depot ?? 0 );
}
return totalPrice / 100;
if ( totalDepot > 0 ) {
cashinInDepot = true;
}
totalPrice += totalDepot;
return ( totalPrice / 100 ) + ( totalDepot ? ` (Depot = ${ totalDepot })` : '' );
} );
const changeValue = ( id: string, amount: number ) => {
@@ -157,6 +163,9 @@
</tr>
</tbody>
</table>
<p v-if="Object.keys( offering ).includes( selectedBar )">
Total: CHF {{ total }}
</p>
</div>
</template>