From c7fcd5199092e8417dd8c55ab4ca99e933cf2578 Mon Sep 17 00:00:00 2001 From: padreug Date: Fri, 5 Sep 2025 06:08:16 +0200 Subject: [PATCH] Enhance CheckoutPage with Nostr integration for order placement - Import and utilize the Nostr store to retrieve the user's public key for order placement. - Implement debug logging to track authentication state and public key availability. - Ensure that the order placement process checks for a valid Nostr public key, improving user feedback and error handling during the checkout process. --- src/modules/market/views/CheckoutPage.vue | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/modules/market/views/CheckoutPage.vue b/src/modules/market/views/CheckoutPage.vue index e96f898..84940b8 100644 --- a/src/modules/market/views/CheckoutPage.vue +++ b/src/modules/market/views/CheckoutPage.vue @@ -272,6 +272,7 @@ import { ref, computed, onMounted } from 'vue' import { useRoute } from 'vue-router' import { useMarketStore } from '@/stores/market' +import { useNostrStore } from '@/stores/nostr' import { injectService, SERVICE_TOKENS } from '@/core/di-container' import { Card, @@ -291,6 +292,7 @@ import { const route = useRoute() const marketStore = useMarketStore() +const nostrStore = useNostrStore() const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any // State @@ -410,14 +412,29 @@ const placeOrder = async () => { if (!currentStall.value) { throw new Error('Stall information not available') } - if (!authService.isAuthenticated.value || !authService.user.value?.pubkey) { + // Debug logging to understand auth state + console.log('Auth check:', { + isAuthenticated: authService.isAuthenticated.value, + user: authService.user.value, + hasPubkey: !!authService.user.value?.pubkey, + nostrPubkey: nostrStore.account?.pubkey + }) + + // Get pubkey from auth service or fallback to nostr store + const userPubkey = authService.user.value?.pubkey || nostrStore.account?.pubkey + + if (!authService.isAuthenticated.value) { throw new Error('You must be logged in to place an order') } + + if (!userPubkey) { + throw new Error('No Nostr public key found. Please ensure your Nostr identity is configured.') + } // Create the order using the market store's order placement functionality const orderData = { stallId: stallId.value, - buyerPubkey: authService.user.value?.pubkey || '', + buyerPubkey: userPubkey, sellerPubkey: currentStall.value.pubkey, status: 'pending' as const, items: checkoutCart.value.products.map(item => ({