diff --git a/src/handlers/userProductHandler.js b/src/handlers/userProductHandler.js index e52272f..2cd8c1c 100644 --- a/src/handlers/userProductHandler.js +++ b/src/handlers/userProductHandler.js @@ -688,68 +688,4 @@ Coordinates: ${product.hidden_coordinates} await this.bot.sendMessage(chatId, 'Error processing purchase. Please try again.'); } } - - async showPurchases(msg) { - const chatId = msg.chat.id; - const userId = msg.from.id; - - try { - const user = await User.getById(userId); - if (!user) { - await this.bot.sendMessage(chatId, 'Profile not found. Please use /start to create one.'); - return; - } - - const purchases = await db.allAsync(` - SELECT p.*, pr.name as product_name, pr.description, - l.country, l.city, l.district - FROM purchases p - JOIN products pr ON p.product_id = pr.id - JOIN locations l ON pr.location_id = l.id - WHERE p.user_id = ? - ORDER BY p.purchase_date DESC - LIMIT 10 - `, [user.id]); - - if (purchases.length === 0) { - await this.bot.sendMessage( - chatId, - 'You haven\'t made any purchases yet.', - { - reply_markup: { - inline_keyboard: [[ - {text: '🛍 Browse Products', callback_data: 'shop_start'} - ]] - } - } - ); - return; - } - - let message = '🛍 *Your Recent Purchases:*\n\n'; - - for (const purchase of purchases) { - const date = new Date(purchase.purchase_date).toLocaleString(); - message += `📦 *${purchase.product_name}*\n`; - message += `├ Quantity: ${purchase.quantity}\n`; - message += `├ Total: $${purchase.total_price}\n`; - message += `├ Location: ${purchase.country}, ${purchase.city}\n`; - message += `├ Payment: ${purchase.wallet_type}\n`; - message += `├ TX: \`${purchase.tx_hash}\`\n`; - message += `└ Date: ${date}\n\n`; - } - - await this.bot.sendMessage(chatId, message, { - parse_mode: 'Markdown', - reply_markup: { - inline_keyboard: [[ - {text: '🛍 Browse Products', callback_data: 'shop_start'} - ]] - } - }); - } catch (error) { - console.error('Error in showPurchases:', error); - await this.bot.sendMessage(chatId, 'Error loading purchase history. Please try again.'); - } - } } \ No newline at end of file