support all the currencies.

This commit is contained in:
fiatjaf 2021-03-14 20:58:49 -03:00
parent adc3e62573
commit 0bc66ea150
2 changed files with 17 additions and 2 deletions

View File

@ -24,7 +24,7 @@ new Vue({
itemDialog: {
show: false,
data: {...defaultItemData},
units: ['sat', 'USD']
units: ['sat']
}
}
},
@ -207,5 +207,14 @@ new Vue({
created() {
this.selectedWallet = this.g.user.wallets[0]
this.loadShop()
LNbits.api
.request('GET', '/offlineshop/api/v1/currencies')
.then(response => {
this.itemDialog = {...this.itemDialog, units: ['sat', ...response.data]}
})
.catch(err => {
LNbits.utils.notifyApiError(err)
})
}
})

View File

@ -3,6 +3,7 @@ from http import HTTPStatus
from lnurl.exceptions import InvalidUrl as LnurlInvalidUrl # type: ignore
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
from lnbits.utils.exchange_rates import currencies
from . import offlineshop_ext
from .crud import (
@ -16,6 +17,11 @@ from .crud import (
from .models import ShopCounter
@offlineshop_ext.route("/api/v1/currencies", methods=["GET"])
async def api_list_currencies_available():
return jsonify(list(currencies.keys()))
@offlineshop_ext.route("/api/v1/offlineshop", methods=["GET"])
@api_check_wallet_key("invoice")
async def api_shop_from_wallet():
@ -51,7 +57,7 @@ async def api_shop_from_wallet():
"description": {"type": "string", "empty": False, "required": True},
"image": {"type": "string", "required": False, "nullable": True},
"price": {"type": "number", "required": True},
"unit": {"type": "string", "allowed": ["sat", "USD"], "required": True},
"unit": {"type": "string", "required": True},
}
)
async def api_add_or_update_item(item_id=None):