diff --git a/crud.py b/crud.py index 12e1ce2..7e8ba73 100644 --- a/crud.py +++ b/crud.py @@ -160,10 +160,10 @@ async def get_hits(cards_ids: list[str]) -> list[Hit]: ) -async def get_hits_today(card_id: str) -> list[Hit]: +async def get_spent_hits_today(card_id: str) -> list[Hit]: rows = await db.fetchall( - "SELECT * FROM boltcards.hits WHERE card_id = :id", - {"id": card_id}, + "SELECT * FROM boltcards.hits WHERE card_id = :card_id AND spent = :spent", + {"card_id": card_id, "spent": True}, Hit, ) updatedrow = [] @@ -182,6 +182,14 @@ async def spend_hit(card_id: str, amount: int): return await get_hit(card_id) +async def unspend_hit(hit_id: str): + await db.execute( + "UPDATE boltcards.hits SET spent = ? WHERE id = ?", + {"spent": False, "id": hit_id}, + ) + return await get_hit(hit_id) + + async def create_hit(card_id, ip, useragent, old_ctr, new_ctr) -> Hit: hit_id = urlsafe_short_hash() await db.execute( diff --git a/pyproject.toml b/pyproject.toml index 9b55529..5f86644 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ name = "lnbits-boltcards" version = "0.0.0" description = "LNbits, free and open-source Lightning wallet and accounts system." authors = ["Alan Bits "] +package-mode = false [tool.poetry.dependencies] python = "^3.10 | ^3.9" diff --git a/static/js/index.js b/static/js/index.js index b553347..9e53da8 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -216,6 +216,7 @@ window.app = Vue.createApp({ .then(response => { this.hits = response.data.map(obj => { obj.card_name = this.cards.find(d => d.id == obj.card_id).card_name + obj.amount = obj.spent ? obj.amount : '(' + obj.amount + ')' return mapCards(obj) }) }) @@ -433,10 +434,9 @@ window.app = Vue.createApp({ message: 'NFC is supported on this device. You can now read NFC tags.' }) } catch (error) { - Quasar.Notify.create({ - type: 'negative', - message: error ? error.toString() : 'An unexpected error has occurred.' - }) + console.error( + error ? error.toString() : 'An unexpected error has occurred.' + ) } } }) diff --git a/templates/boltcards/index.html b/templates/boltcards/index.html index cd63021..8faced2 100644 --- a/templates/boltcards/index.html +++ b/templates/boltcards/index.html @@ -279,7 +279,7 @@
>
-
+
v-model="cardDialog.data.uid" type="text" label="Card UID " + :hint="disableNfcButton ? 'NFC reader is not available on this device. Input UID manually.' : ''" >
-
+