25
25
< div class ="row justify-center full-width ">
26
26
< div class ="col-12 col-sm-8 col-md-6 col-lg-4 text-center ">
27
27
< h3 class ="q-mb-md "> ${ amountFormatted }</ h3 >
28
- < h5 class ="q-mt-none q-mb-sm "> ${ fsat }< small > sat</ small > </ h5 >
28
+ < h5 v-show ="!denomIsSats " class ="q-mt-none q-mb-sm ">
29
+ ${ fsat }< small > sat</ small >
30
+ </ h5 >
29
31
< div v-if ="total > 0.0 ">
30
32
< h5 >
31
- < i > Total: ${totalFormatted}< br /> ${totalfsat} sat</ i >
33
+ < i
34
+ > Total: ${totalFormatted}< span v-if ="!denomIsSats "
35
+ > < br /> ${totalfsat} sat</ span
36
+ > </ i
37
+ >
32
38
</ h5 >
33
39
</ div >
34
40
</ div >
220
226
< div class ="row full-width q-pa-md ">
221
227
< div class ="col-12 text-center ">
222
228
< h3 class ="q-mb-md "> ${totalFormatted}</ h3 >
223
- < h5 class ="q-mt-none q-mb-sm "> ${totalfsat}< small > sat</ small > </ h5 >
229
+ < h5 v-show ="!denomIsSats " class ="q-mt-none q-mb-sm ">
230
+ ${totalfsat}< small > sat</ small >
231
+ </ h5 >
224
232
</ div >
225
233
< div class ="col-12 ">
226
234
< table class ="table full-width ">
@@ -755,28 +763,26 @@ <h5 class="q-mt-none q-mb-sm">
755
763
cartDrawer : this . $q . screen . width > 1200 ,
756
764
searchTerm : '' ,
757
765
categoryFilter : '' ,
758
- cart : new Map ( )
766
+ cart : new Map ( ) ,
767
+ denomIsSats : '{{ tpos.currency }}' == 'sats'
759
768
}
760
769
} ,
761
770
computed : {
762
771
amount : function ( ) {
763
772
if ( ! this . stack . length ) return 0.0
764
- return this . stack . reduce ( ( acc , dig ) => acc * 10 + dig , 0 ) * 0.01
773
+ return (
774
+ this . stack . reduce ( ( acc , dig ) => acc * 10 + dig , 0 ) *
775
+ ( this . currency == 'sats' ? 1 : 0.01 )
776
+ )
765
777
} ,
766
778
amountFormatted : function ( ) {
767
- return LNbits . utils . formatCurrency (
768
- this . amount . toFixed ( 2 ) ,
769
- this . currency
770
- )
779
+ return this . formatAmount ( this . amount , this . currency )
771
780
} ,
772
781
totalFormatted ( ) {
773
- return LNbits . utils . formatCurrency ( this . total . toFixed ( 2 ) , this . currency )
782
+ return this . formatAmount ( this . total , this . currency )
774
783
} ,
775
784
amountWithTipFormatted : function ( ) {
776
- return LNbits . utils . formatCurrency (
777
- ( this . amount + this . tipAmount ) . toFixed ( 2 ) ,
778
- this . currency
779
- )
785
+ return this . formatAmount ( this . amount + this . tipAmount , this . currency )
780
786
} ,
781
787
sat : function ( ) {
782
788
if ( ! this . exchangeRate ) return 0
@@ -1000,7 +1006,11 @@ <h5 class="q-mt-none q-mb-sm">
1000
1006
} ,
1001
1007
submitForm : function ( ) {
1002
1008
if ( this . total != 0.0 ) {
1003
- this . stack = Array . from ( String ( Math . ceil ( this . total * 100 ) ) , Number )
1009
+ if ( this . currency == 'sats' ) {
1010
+ this . stack = Array . from ( String ( Math . ceil ( this . total ) , Number ) )
1011
+ } else {
1012
+ this . stack = Array . from ( String ( Math . ceil ( this . total * 100 ) ) , Number )
1013
+ }
1004
1014
}
1005
1015
if ( ! this . exchangeRate || this . exchangeRate == 0 || this . sat == 0 ) {
1006
1016
this . $q . notify ( {
@@ -1224,12 +1234,16 @@ <h5 class="q-mt-none q-mb-sm">
1224
1234
} )
1225
1235
} ,
1226
1236
getRates ( ) {
1227
- LNbits . api
1228
- . request ( 'GET' , `/tpos/api/v1/rate/${ this . currency } ` )
1229
- . then ( response => {
1230
- this . exchangeRate = response . data . rate
1231
- } )
1232
- . catch ( e => console . error ( e ) )
1237
+ if ( this . currency == 'sats' ) {
1238
+ this . exchangeRate = 1
1239
+ } else {
1240
+ LNbits . api
1241
+ . request ( 'GET' , `/tpos/api/v1/rate/${ this . currency } ` )
1242
+ . then ( response => {
1243
+ this . exchangeRate = response . data . rate
1244
+ } )
1245
+ . catch ( e => console . error ( e ) )
1246
+ }
1233
1247
} ,
1234
1248
getLastPayments ( ) {
1235
1249
return axios
@@ -1285,6 +1299,16 @@ <h5 class="q-mt-none q-mb-sm">
1285
1299
} else {
1286
1300
this . categoryFilter = category == 'All' ? '' : category
1287
1301
}
1302
+ } ,
1303
+ formatAmount : function ( amount , currency ) {
1304
+ if ( currency == 'sats' ) {
1305
+ return LNbits . utils . formatSat ( amount ) + ' sat'
1306
+ } else {
1307
+ return LNbits . utils . formatCurrency (
1308
+ Number ( amount ) . toFixed ( 2 ) ,
1309
+ currency
1310
+ )
1311
+ }
1288
1312
}
1289
1313
} ,
1290
1314
created : function ( ) {
@@ -1301,10 +1325,7 @@ <h5 class="q-mt-none q-mb-sm">
1301
1325
1302
1326
this . items = JSON . parse ( `{{ tpos.items | safe }}` )
1303
1327
this . items . forEach ( ( item , id ) => {
1304
- item . formattedPrice = LNbits . utils . formatCurrency (
1305
- item . price ,
1306
- this . currency
1307
- )
1328
+ item . formattedPrice = this . formatAmount ( item . price , this . currency )
1308
1329
item . id = id
1309
1330
return item
1310
1331
} )
0 commit comments