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.
This commit is contained in:
parent
7c439361b7
commit
c7fcd51990
1 changed files with 19 additions and 2 deletions
|
|
@ -272,6 +272,7 @@
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useMarketStore } from '@/stores/market'
|
import { useMarketStore } from '@/stores/market'
|
||||||
|
import { useNostrStore } from '@/stores/nostr'
|
||||||
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
|
|
@ -291,6 +292,7 @@ import {
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const marketStore = useMarketStore()
|
const marketStore = useMarketStore()
|
||||||
|
const nostrStore = useNostrStore()
|
||||||
const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any
|
const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any
|
||||||
|
|
||||||
// State
|
// State
|
||||||
|
|
@ -410,14 +412,29 @@ const placeOrder = async () => {
|
||||||
if (!currentStall.value) {
|
if (!currentStall.value) {
|
||||||
throw new Error('Stall information not available')
|
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')
|
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
|
// Create the order using the market store's order placement functionality
|
||||||
const orderData = {
|
const orderData = {
|
||||||
stallId: stallId.value,
|
stallId: stallId.value,
|
||||||
buyerPubkey: authService.user.value?.pubkey || '',
|
buyerPubkey: userPubkey,
|
||||||
sellerPubkey: currentStall.value.pubkey,
|
sellerPubkey: currentStall.value.pubkey,
|
||||||
status: 'pending' as const,
|
status: 'pending' as const,
|
||||||
items: checkoutCart.value.products.map(item => ({
|
items: checkoutCart.value.products.map(item => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue