purchase viewing

This commit is contained in:
Artyom Ashirov
2024-11-20 17:43:51 +03:00
parent a35bbbf3d9
commit 1cb0467f6c
2 changed files with 206 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ import ErrorHandler from './utils/errorHandler.js';
import User from './models/User.js';
import AdminUserLocationHandler from "./handlers/adminUserLocationHandler.js";
import AdminDumpHandler from "./handlers/adminDumpHandler.js";
import UserPurchaseHandler from "./handlers/userPurchaseHandler.js";
// Debug logging function
const logDebug = (action, functionName) => {
@@ -41,6 +42,7 @@ const adminLocationHandler = new AdminLocationHandler(bot);
const adminUserLocationHandler = new AdminUserLocationHandler(bot);
const adminProductHandler = new AdminProductHandler(bot);
const adminDumpHandler = new AdminDumpHandler(bot);
const userPurchaseHandler = new UserPurchaseHandler(bot);
// Start command - Create user profile
bot.onText(/\/start/, async (msg) => {
@@ -125,7 +127,7 @@ bot.on('message', async (msg) => {
await userWalletsHandler.showBalance(msg);
break;
case '🛍 Purchases':
await userProductHandler.showPurchases(msg);
await userPurchaseHandler.showPurchases(msg);
break;
case '📦 Manage Products':
if (adminHandler.isAdmin(msg.from.id)) {
@@ -242,6 +244,12 @@ bot.on('callback_query', async (callbackQuery) => {
} else if (action.startsWith('pay_with_')) {
logDebug(action, 'handlePay');
await userProductHandler.handlePay(callbackQuery);
} else if (action.startsWith('list_purchases_')) {
logDebug(action, 'handlePurchaseListPage');
await userPurchaseHandler.handlePurchaseListPage(callbackQuery);
} else if (action.startsWith('view_purchase_')) {
logDebug(action, 'viewPurchase');
await userPurchaseHandler.viewPurchase(callbackQuery);
}
// Admin location management
else if (action === 'add_location') {