Enhance market module with new chat and events features

- Introduce chat module with components, services, and composables for real-time messaging.
- Implement events module with API service, components, and ticket purchasing functionality.
- Update app configuration to include new modules and their respective settings.
- Refactor existing components to integrate with the new chat and events features.
- Enhance market store and services to support new functionalities and improve order management.
- Update routing to accommodate new views for chat and events, ensuring seamless navigation.
This commit is contained in:
padreug 2025-09-05 00:01:40 +02:00
parent 519a9003d4
commit e40ac91417
46 changed files with 6305 additions and 3264 deletions

143
src/modules/market/index.ts Normal file
View file

@ -0,0 +1,143 @@
import type { App } from 'vue'
import type { ModulePlugin } from '@/core/types'
import type { RouteRecordRaw } from 'vue-router'
import { container } from '@/core/di-container'
import { eventBus } from '@/core/event-bus'
// Import components
import MarketSettings from './components/MarketSettings.vue'
import MerchantStore from './components/MerchantStore.vue'
import ShoppingCart from './components/ShoppingCart.vue'
// Import services
import { NostrmarketService } from './services/nostrmarketService'
// Store will be imported when needed
// Import composables
import { useMarket } from './composables/useMarket'
import { useMarketPreloader } from './composables/useMarketPreloader'
// Define service tokens
export const MARKET_SERVICE_TOKEN = Symbol('marketService')
export const NOSTRMARKET_SERVICE_TOKEN = Symbol('nostrmarketService')
export interface MarketModuleConfig {
defaultCurrency: string
paymentTimeout: number
maxOrderHistory: number
supportedRelays?: string[]
}
/**
* Market Module Plugin
* Provides market, stall, and product management functionality
*/
export const marketModule: ModulePlugin = {
name: 'market',
version: '1.0.0',
dependencies: ['base'],
async install(app: App, options?: { config?: MarketModuleConfig }) {
console.log('🛒 Installing market module...')
const config = options?.config
if (!config) {
throw new Error('Market module requires configuration')
}
// Create and register services
const nostrmarketService = new NostrmarketService()
container.provide(NOSTRMARKET_SERVICE_TOKEN, nostrmarketService)
// Register global components
app.component('MarketSettings', MarketSettings)
app.component('MerchantStore', MerchantStore)
app.component('ShoppingCart', ShoppingCart)
// Market store will be initialized when first used
// Set up event listeners for integration with other modules
setupEventListeners()
console.log('✅ Market module installed successfully')
},
async uninstall() {
console.log('🗑️ Uninstalling market module...')
// Clean up services
container.remove(NOSTRMARKET_SERVICE_TOKEN)
console.log('✅ Market module uninstalled')
},
routes: [
{
path: '/market',
name: 'market',
component: () => import('./views/MarketPage.vue'),
meta: {
title: 'Market',
requiresAuth: false
}
},
{
path: '/market/dashboard',
name: 'market-dashboard',
component: () => import('./views/MarketDashboard.vue'),
meta: {
title: 'Market Dashboard',
requiresAuth: true
}
}
] as RouteRecordRaw[],
components: {
MarketSettings,
MerchantStore,
ShoppingCart
},
composables: {
useMarket,
useMarketPreloader
},
services: {
nostrmarket: NOSTRMARKET_SERVICE_TOKEN
}
}
// Set up event listeners for integration with other modules
function setupEventListeners() {
// Listen for auth events
eventBus.on('auth:logout', () => {
console.log('Market module: user logged out, clearing market data')
// Could clear market-specific user data here
})
// Listen for payment events from other modules
eventBus.on('payment:completed', (event) => {
console.log('Market module: payment completed', event.data)
// Could update order status or refresh market data here
})
// Emit market-specific events
eventBus.on('market:order-placed', (event) => {
console.log('Market order placed:', event.data)
// Other modules can listen to this event
})
eventBus.on('market:product-added', (event) => {
console.log('Market product added:', event.data)
// Other modules can listen to this event
})
}
export default marketModule
// Re-export types and composables for external use
export type * from './types/market'
export { useMarket, useMarketPreloader } from './composables'
export { useMarketStore } from './stores/market'