Refactor imports and enhance type handling across components
- Update import paths for useTicketPurchase in PurchaseTicketDialog.vue to reflect new module structure. - Adjust type handling in Navbar.vue and various market components to use 'any' for improved compatibility with existing data structures. - Enhance useLightningPayment composable to include shipping zone details, ensuring better order management. - Remove unused pages (events.vue, MyTickets.vue, OrderHistory.vue) to streamline the codebase and improve maintainability.
This commit is contained in:
parent
18f48581cd
commit
861c032300
12 changed files with 37 additions and 1217 deletions
|
|
@ -254,10 +254,11 @@ import { Badge } from '@/components/ui/badge'
|
|||
import { Package, Store, Zap, Copy, QrCode, CheckCircle } from 'lucide-vue-next'
|
||||
import { toast } from 'vue-sonner'
|
||||
import type { OrderStatus } from '@/stores/market'
|
||||
// Order type no longer needed since we use any for readonly compatibility
|
||||
|
||||
const router = useRouter()
|
||||
const marketStore = useMarketStore()
|
||||
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB)
|
||||
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB) as any
|
||||
const { handlePayment, isPayingWithWallet, hasWalletWithBalance } = useLightningPayment()
|
||||
|
||||
// const orderEvents = useOrderEvents() // TODO: Move to market module
|
||||
|
|
@ -305,7 +306,7 @@ const pendingPayments = computed(() => allOrders.value.filter(o => !isOrderPaid(
|
|||
const isDevelopment = computed(() => import.meta.env.DEV)
|
||||
|
||||
// Methods
|
||||
const isOrderPaid = (order: Order) => {
|
||||
const isOrderPaid = (order: any) => {
|
||||
// Prioritize the 'paid' field from Nostr status updates (type 2)
|
||||
if (order.paid !== undefined) {
|
||||
return order.paid
|
||||
|
|
@ -314,7 +315,7 @@ const isOrderPaid = (order: Order) => {
|
|||
return order.paymentStatus === 'paid'
|
||||
}
|
||||
|
||||
const getEffectiveStatus = (order: Order) => {
|
||||
const getEffectiveStatus = (order: any) => {
|
||||
// If paid, return 'paid' regardless of original status
|
||||
if (isOrderPaid(order)) {
|
||||
return order.shipped ? 'shipped' : 'paid'
|
||||
|
|
|
|||
|
|
@ -67,7 +67,11 @@ export function useLightningPayment() {
|
|||
paidAt: Math.floor(Date.now() / 1000),
|
||||
paymentHash: paymentResult.payment_hash,
|
||||
feeMsat: paymentResult.fee_msat,
|
||||
items: [...order.items] // Convert readonly to mutable
|
||||
items: [...order.items], // Convert readonly to mutable
|
||||
shippingZone: order.shippingZone ? {
|
||||
...order.shippingZone,
|
||||
countries: order.shippingZone.countries ? [...order.shippingZone.countries] : undefined
|
||||
} : order.shippingZone
|
||||
}
|
||||
marketStore.updateOrder(orderId, updatedOrder)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,7 +395,6 @@ export function useMarket() {
|
|||
console.log('🔔 Received order-related DM:', event.id, 'from:', event.pubkey.slice(0, 8))
|
||||
|
||||
// TODO: Confirm if this should use nostrStore.account?.pubkey or authService.user.value?.pubkey
|
||||
const userPubkey = nostrStore.account?.pubkey || authService.user.value?.pubkey
|
||||
const userPrivkey = nostrStore.account?.privkey || authService.user.value?.prvkey
|
||||
|
||||
if (!userPrivkey) {
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@ import { useAuth } from '@/composables/useAuth'
|
|||
import { useMarketStore } from '../stores/market'
|
||||
|
||||
// Simplified bolt11 parser to extract payment hash
|
||||
function parseBolt11(bolt11: string): { paymentHash?: string } {
|
||||
function parseBolt11(_bolt11: string): { paymentHash?: string } {
|
||||
try {
|
||||
// Remove lightning: prefix if present
|
||||
const cleanBolt11 = bolt11.replace(/^lightning:/, '')
|
||||
|
||||
// Very basic bolt11 parsing - in a real app you'd use a proper library
|
||||
// For now, we'll return empty since this requires complex bech32 decoding
|
||||
// Note: Remove lightning: prefix if present: bolt11.replace(/^lightning:/, '')
|
||||
return {}
|
||||
} catch (error) {
|
||||
console.error('Failed to parse bolt11:', error)
|
||||
|
|
@ -94,7 +92,11 @@ export function usePaymentStatusChecker() {
|
|||
status: 'paid' as const,
|
||||
paymentStatus: 'paid' as const,
|
||||
paidAt: Math.floor(Date.now() / 1000),
|
||||
items: [...order.items] // Convert readonly to mutable
|
||||
items: [...order.items], // Convert readonly to mutable
|
||||
shippingZone: order.shippingZone ? {
|
||||
...order.shippingZone,
|
||||
countries: order.shippingZone.countries ? [...order.shippingZone.countries] : undefined
|
||||
} : order.shippingZone
|
||||
}
|
||||
|
||||
marketStore.updateOrder(orderId, updatedOrder)
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ export interface NostrmarketOrderStatus {
|
|||
}
|
||||
|
||||
export class NostrmarketService {
|
||||
private get relayHub() {
|
||||
private get relayHub(): any {
|
||||
const hub = injectService(SERVICE_TOKENS.RELAY_HUB)
|
||||
if (!hub) {
|
||||
throw new Error('RelayHub not available. Make sure base module is installed.')
|
||||
}
|
||||
return hub
|
||||
return hub as any
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -299,7 +299,7 @@ export class NostrmarketService {
|
|||
})
|
||||
|
||||
const event = finalizeEvent(eventTemplate, prvkeyBytes)
|
||||
const result = await relayHub.publishEvent(event)
|
||||
const result = await this.relayHub.publishEvent(event)
|
||||
|
||||
console.log('Order published to nostrmarket:', {
|
||||
orderId: order.id,
|
||||
|
|
@ -345,7 +345,11 @@ export class NostrmarketService {
|
|||
paymentStatus: 'pending' as const,
|
||||
status: 'pending' as const, // Ensure status is pending for payment
|
||||
updatedAt: Math.floor(Date.now() / 1000),
|
||||
items: [...order.items] // Convert readonly to mutable
|
||||
items: [...order.items], // Convert readonly to mutable
|
||||
shippingZone: order.shippingZone ? {
|
||||
...order.shippingZone,
|
||||
countries: order.shippingZone.countries ? [...order.shippingZone.countries] : undefined
|
||||
} : order.shippingZone
|
||||
}
|
||||
|
||||
// Generate QR code for the payment request
|
||||
|
|
@ -415,7 +419,11 @@ export class NostrmarketService {
|
|||
const updatedOrder = {
|
||||
...order,
|
||||
updatedAt: Math.floor(Date.now() / 1000),
|
||||
items: [...order.items] // Convert readonly to mutable
|
||||
items: [...order.items], // Convert readonly to mutable
|
||||
shippingZone: order.shippingZone ? {
|
||||
...order.shippingZone,
|
||||
countries: order.shippingZone.countries ? [...order.shippingZone.countries] : undefined
|
||||
} : order.shippingZone
|
||||
}
|
||||
|
||||
// Update payment status
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useMarketStore } from '@/stores/market'
|
||||
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||
import {
|
||||
|
|
@ -290,7 +290,6 @@ import {
|
|||
} from 'lucide-vue-next'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const marketStore = useMarketStore()
|
||||
const authService = injectService(SERVICE_TOKENS.AUTH_SERVICE) as any
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const props = defineProps<{
|
|||
feedType?: 'all' | 'announcements' | 'events' | 'general'
|
||||
}>()
|
||||
|
||||
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB)
|
||||
const relayHub = injectService(SERVICE_TOKENS.RELAY_HUB) as any
|
||||
|
||||
// Reactive state
|
||||
const notes = ref<any[]>([])
|
||||
|
|
@ -97,7 +97,7 @@ async function loadNotes() {
|
|||
const events = await relayHub.queryEvents(filters)
|
||||
|
||||
// Process and filter events
|
||||
let processedNotes = events.map(event => ({
|
||||
let processedNotes = events.map((event: any) => ({
|
||||
id: event.id,
|
||||
pubkey: event.pubkey,
|
||||
content: event.content,
|
||||
|
|
@ -111,11 +111,11 @@ async function loadNotes() {
|
|||
}))
|
||||
|
||||
// Sort by creation time (newest first)
|
||||
processedNotes.sort((a, b) => b.created_at - a.created_at)
|
||||
processedNotes.sort((a: any, b: any) => b.created_at - a.created_at)
|
||||
|
||||
// For general feed, exclude admin posts
|
||||
if (props.feedType === 'general' && hasAdminPubkeys.value) {
|
||||
processedNotes = processedNotes.filter(note => !isAdminPost(note.pubkey))
|
||||
processedNotes = processedNotes.filter((note: any) => !isAdminPost(note.pubkey))
|
||||
}
|
||||
|
||||
notes.value = processedNotes
|
||||
|
|
@ -153,7 +153,7 @@ async function startRealtimeSubscription() {
|
|||
unsubscribe = relayHub.subscribe({
|
||||
id: `feed-${props.feedType || 'all'}`,
|
||||
filters,
|
||||
onEvent: (event) => {
|
||||
onEvent: (event: any) => {
|
||||
// Add new note to the beginning of the list
|
||||
const newNote = {
|
||||
id: event.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue