@@ -2,6 +2,10 @@ const mapWithdrawLink = function (obj) {
22 obj . _data = _ . clone ( obj )
33 obj . uses_left = obj . uses - obj . used
44 obj . _data . use_custom = Boolean ( obj . custom_url )
5+ if ( obj . currency ) {
6+ obj . min_withdrawable = obj . min_withdrawable / 100
7+ obj . max_withdrawable = obj . max_withdrawable / 100
8+ }
59 return obj
610}
711
@@ -14,6 +18,7 @@ window.app = Vue.createApp({
1418 return {
1519 checker : null ,
1620 withdrawLinks : [ ] ,
21+ currencyOptions : [ ] ,
1722 lnurl : '' ,
1823 withdrawLinksTable : {
1924 columns : [
@@ -46,12 +51,24 @@ window.app = Vue.createApp({
4651 label : 'Uses left' ,
4752 field : 'uses_left'
4853 } ,
54+ {
55+ name : 'currency' ,
56+ align : 'right' ,
57+ label : 'Currency' ,
58+ field : 'currency' ,
59+ format : function ( val ) {
60+ return val ? val . toUpperCase ( ) : 'sat'
61+ }
62+ } ,
4963 {
5064 name : 'max_withdrawable' ,
5165 align : 'right' ,
52- label : ' Max (sat)' ,
66+ label : ` Max` ,
5367 field : 'max_withdrawable' ,
54- format : LNbits . utils . formatSat
68+ format : ( val , row ) =>
69+ row . currency
70+ ? LNbits . utils . formatCurrency ( val , row . currency )
71+ : val
5572 }
5673 ] ,
5774 pagination : {
@@ -94,6 +111,24 @@ window.app = Vue.createApp({
94111 return this . withdrawLinks . sort ( function ( a , b ) {
95112 return b . uses_left - a . uses_left
96113 } )
114+ } ,
115+ assertMinimumWithdrawable ( ) {
116+ const dialog = this . formDialog . show
117+ ? this . formDialog
118+ : this . simpleformDialog
119+ return dialog . data . currency
120+ ? dialog . data . min_withdrawable >= 0.01
121+ : dialog . data . min_withdrawable >= 1
122+ } ,
123+ assertMaximumWithdrawable ( ) {
124+ const dialog = this . formDialog . show
125+ ? this . formDialog
126+ : this . simpleformDialog
127+ return dialog . data . currency
128+ ? dialog . data . max_withdrawable >= 0.01 &&
129+ dialog . data . max_withdrawable >= dialog . data . min_withdrawable
130+ : dialog . data . max_withdrawable >= 1 &&
131+ dialog . data . max_withdrawable >= dialog . data . min_withdrawable
97132 }
98133 } ,
99134 methods : {
@@ -164,6 +199,11 @@ window.app = Vue.createApp({
164199 data . custom_url = CUSTOM_URL
165200 }
166201
202+ if ( data . currency ) {
203+ data . min_withdrawable = data . min_withdrawable * 100
204+ data . max_withdrawable = data . max_withdrawable * 100
205+ }
206+
167207 data . wait_time =
168208 data . wait_time *
169209 {
@@ -197,6 +237,11 @@ window.app = Vue.createApp({
197237 data . custom_url = '/static/images/default_voucher.png'
198238 }
199239
240+ if ( data . currency ) {
241+ data . min_withdrawable = data . min_withdrawable * 100
242+ data . max_withdrawable = data . max_withdrawable * 100
243+ }
244+
200245 if ( data . id ) {
201246 this . updateWithdrawLink ( wallet , data )
202247 } else {
@@ -231,6 +276,7 @@ window.app = Vue.createApp({
231276 } )
232277 } ,
233278 createWithdrawLink ( wallet , data ) {
279+ console . log ( data )
234280 LNbits . api
235281 . request ( 'POST' , '/withdraw/api/v1/links' , wallet . adminkey , data )
236282 . then ( response => {
@@ -314,5 +360,6 @@ window.app = Vue.createApp({
314360 this . getWithdrawLinks ( )
315361 this . checker = setInterval ( this . getWithdrawLinks , 300000 )
316362 }
363+ this . currencyOptions = this . g . allowedCurrencies
317364 }
318365} )
0 commit comments