Skip to content

Commit

Permalink
Product db (#5)
Browse files Browse the repository at this point in the history
* Add db functions

* Add delete and add produkt

* Add edit_product

* Add skip, fix delete, cleanup

* Add explicit return type

* Refactor product to own file

* Rename product file

* Run Prettier

* Remove unnecessary import

* Fix based on review

* Rename files

* Add folding markers

* Run prettier

* Add confirm, abort and admin check

* Refactored to new admin setup

* Clean up
  • Loading branch information
christiansegercrantz authored Apr 6, 2024
1 parent 82b401b commit 43d88ef
Show file tree
Hide file tree
Showing 7 changed files with 570 additions and 83 deletions.
19 changes: 18 additions & 1 deletion backend/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Composer } from 'telegraf'
import { isChatMember } from '../index.js'
import { config } from '../config.js'
import saldoCommands from './saldo.js'
import productCommands from './product.js'

const bot = new Composer()

Expand All @@ -15,4 +16,20 @@ const adminMiddleware = bot.use(async (ctx, next) => {
await next()
})

export default Composer.compose([adminMiddleware, saldoCommands])
bot.command('admin', async (ctx) => {
const admin_message =
'Följande admin kommandon existerar:\n' +
'/add_product För att lägga till en produkt\n' +
'/edit_product För att ändra en produkt\n' +
'/delete_product För att ta bort en produkt\n' +
'/exportera CSV-dump av alla transaktioner\n' +
'/historia_all Se de senaste händelserna för alla användare\n' +
'/saldo_template Exportera template för att manuellt ändra på användares saldo\n'
return ctx.reply(admin_message)
})

export default Composer.compose([
adminMiddleware,
saldoCommands,
productCommands,
])
Loading

0 comments on commit 43d88ef

Please sign in to comment.