diff --git a/src/modules/market/components/CreateStoreDialog.vue b/src/modules/market/components/CreateStoreDialog.vue index 613c005..78ef1b3 100644 --- a/src/modules/market/components/CreateStoreDialog.vue +++ b/src/modules/market/components/CreateStoreDialog.vue @@ -47,10 +47,14 @@ Currency * - - + @@ -275,6 +279,7 @@ const toast = useToast() // Local state const isCreating = ref(false) const createError = ref(null) +const isLoadingCurrencies = ref(false) const availableCurrencies = ref(['sat']) const availableZones = ref([]) const showNewZoneForm = ref(false) @@ -331,11 +336,27 @@ const onSubmit = form.handleSubmit(async (values) => { // Methods const loadAvailableCurrencies = async () => { + isLoadingCurrencies.value = true try { const currencies = await nostrmarketAPI.getCurrencies() - availableCurrencies.value = currencies + if (currencies.length > 0) { + // Ensure 'sat' is always first in the list + const satIndex = currencies.indexOf('sat') + if (satIndex === -1) { + // Add 'sat' at the beginning if not present + availableCurrencies.value = ['sat', ...currencies] + } else if (satIndex > 0) { + // Move 'sat' to the beginning if present but not first + const withoutSat = currencies.filter(c => c !== 'sat') + availableCurrencies.value = ['sat', ...withoutSat] + } else { + availableCurrencies.value = currencies + } + } } catch (error) { console.error('Failed to load currencies:', error) + } finally { + isLoadingCurrencies.value = false } } diff --git a/src/modules/market/components/DashboardOverview.vue b/src/modules/market/components/DashboardOverview.vue index 103c07a..804d77c 100644 --- a/src/modules/market/components/DashboardOverview.vue +++ b/src/modules/market/components/DashboardOverview.vue @@ -77,77 +77,6 @@ - -
- -
-

- - Customer Actions -

-
- - - -
-
- - -
-

- - Merchant Actions -

-
- - - -
-
-
-

Recent Activity

@@ -216,15 +145,12 @@ - diff --git a/src/modules/market/components/MerchantStore.vue b/src/modules/market/components/MerchantStore.vue index 50da407..381fcae 100644 --- a/src/modules/market/components/MerchantStore.vue +++ b/src/modules/market/components/MerchantStore.vue @@ -49,84 +49,47 @@
- -
-
-
-

My Stores

-

- Manage your stores and products -

+ +
+
+
+ + +
+
+
-
-
- -
-
-
- - -
- - - - -
- -
-
- - -
+ +
- -
- -
- {{ activeStall.currency }} -
-
-

{{ activeStall.name }}

-

{{ activeStall.config?.description || 'Manage incoming orders and your products' }}

-
-
- - +
+

{{ activeStall.name }}

+ {{ activeStall.currency }} +
+

{{ activeStall.config?.description || 'Manage incoming orders and your products' }}

+
@@ -188,20 +151,23 @@
- -
+ +
+
+ Coming Soon +

Satisfaction

-

{{ storeStats.satisfaction }}%

+

--%

-
- +
+
- {{ storeStats.totalReviews }} reviews + No reviews yet
@@ -430,7 +396,6 @@ import { injectService, SERVICE_TOKENS } from '@/core/di-container' import CreateStoreDialog from './CreateStoreDialog.vue' import CreateProductDialog from './CreateProductDialog.vue' import DeleteConfirmDialog from './DeleteConfirmDialog.vue' -import StoreCard from './StoreCard.vue' import MerchantOrders from './MerchantOrders.vue' const router = useRouter() @@ -652,14 +617,6 @@ const loadStallProducts = async () => { } } -const manageStall = (stallId: string) => { - activeStallId.value = stallId -} - -const viewStallProducts = (stallId: string) => { - activeStallId.value = stallId -} - const navigateToMarket = () => router.push('/market') const checkMerchantProfile = async () => { @@ -697,7 +654,6 @@ const checkMerchantProfile = async () => { // Event handlers const onStoreCreated = async (_stall: Stall) => { await loadStallsList() - toast.success('Store created successfully!') } const onProductCreated = async (_product: Product) => { diff --git a/src/modules/market/components/OrderHistory.vue b/src/modules/market/components/OrderHistory.vue index 0807c97..54401fa 100644 --- a/src/modules/market/components/OrderHistory.vue +++ b/src/modules/market/components/OrderHistory.vue @@ -212,19 +212,6 @@
- -
-

Debug Information

-
-
Total Orders in Store: {{ Object.keys(marketStore.orders).length }}
-
Filtered Orders: {{ filteredOrders.length }}
-
Order Events Subscribed: {{ orderEvents.isSubscribed ? 'Yes' : 'No' }}
-
Relay Hub Connected: {{ relayHub.isConnected ? 'Yes' : 'No' }}
-
Auth Status: {{ auth.isAuthenticated ? 'Authenticated' : 'Not Authenticated' }}
-
Current User: {{ auth.currentUser?.value?.pubkey ? 'Yes' : 'No' }}
-
-
-
@@ -312,8 +299,6 @@ const pendingOrders = computed(() => allOrders.value.filter(o => o.status === 'p const paidOrders = computed(() => allOrders.value.filter(o => o.status === 'paid').length) const pendingPayments = computed(() => allOrders.value.filter(o => !isOrderPaid(o)).length) -const isDevelopment = computed(() => import.meta.env.DEV) - // Methods const isOrderPaid = (order: any) => { // Prioritize the 'paid' field from Nostr status updates (type 2) @@ -497,34 +482,9 @@ onMounted(() => { paymentService.forceResetPaymentState() } - // Orders are already loaded in the market store - console.log('Order History component loaded with', allOrders.value.length, 'orders') - console.log('Market store orders:', marketStore.orders) - - // Debug: Log order details for orders with payment requests - allOrders.value.forEach(order => { - if (order.paymentRequest) { - console.log('Order with payment request:', { - id: order.id, - paymentRequest: order.paymentRequest.substring(0, 50) + '...', - hasPaymentRequest: !!order.paymentRequest, - status: order.status, - paymentStatus: order.paymentStatus - }) - } - }) - - console.log('Order events status:', orderEvents.isSubscribed.value) - console.log('Relay hub connected:', relayHub.isConnected.value) - console.log('Auth status:', auth.isAuthenticated) - console.log('Current user:', auth.currentUser?.value?.pubkey) - // Start listening for order events if not already listening if (!orderEvents.isSubscribed.value) { - console.log('Starting order events listener...') orderEvents.initialize() - } else { - console.log('Order events already listening') } }) diff --git a/src/modules/market/services/nostrmarketAPI.ts b/src/modules/market/services/nostrmarketAPI.ts index 4913aa0..528336f 100644 --- a/src/modules/market/services/nostrmarketAPI.ts +++ b/src/modules/market/services/nostrmarketAPI.ts @@ -329,6 +329,34 @@ export class NostrmarketAPI extends BaseService { return stall } + /** + * Update an existing stall + */ + async updateStall( + walletAdminkey: string, + stallId: string, + stallData: Partial<{ + name: string + config: { + description?: string + image_url?: string + } + }> + ): Promise { + const stall = await this.request( + `/api/v1/stall/${stallId}`, + walletAdminkey, + { + method: 'PATCH', + body: JSON.stringify(stallData), + } + ) + + this.debug('Updated stall:', { stallId: stall.id, stallName: stall.name }) + + return stall + } + /** * Get available shipping zones */ @@ -371,30 +399,70 @@ export class NostrmarketAPI extends BaseService { } /** - * Get available currencies + * Update an existing shipping zone + */ + async updateZone( + walletAdminkey: string, + zoneId: string, + zoneData: Zone + ): Promise { + const zone = await this.request( + `/api/v1/zone/${zoneId}`, + walletAdminkey, + { + method: 'PATCH', + body: JSON.stringify(zoneData), + } + ) + + this.debug('Updated zone:', { zoneId: zone.id, zoneName: zone.name }) + + return zone + } + + /** + * Delete a shipping zone + */ + async deleteZone(walletAdminkey: string, zoneId: string): Promise { + await this.request( + `/api/v1/zone/${zoneId}`, + walletAdminkey, + { method: 'DELETE' } + ) + + this.debug('Deleted zone:', { zoneId }) + } + + /** + * Get available currencies from the LNbits core API + * This endpoint returns currencies allowed by the server configuration */ async getCurrencies(): Promise { - const baseCurrencies = ['sat'] + // Call the LNbits core API directly (not under /nostrmarket) + const url = `${this.baseUrl}/api/v1/currencies` try { - const apiCurrencies = await this.request( - '/api/v1/currencies', - '', // No authentication needed for currencies endpoint - { method: 'GET' } - ) + const response = await fetch(url, { + method: 'GET', + headers: { 'Content-Type': 'application/json' } + }) - if (apiCurrencies && Array.isArray(apiCurrencies)) { - // Combine base currencies with API currencies, removing duplicates - const allCurrencies = [...baseCurrencies, ...apiCurrencies.filter(currency => !baseCurrencies.includes(currency))] - this.debug('Retrieved currencies:', { count: allCurrencies.length, currencies: allCurrencies }) - return allCurrencies + if (!response.ok) { + throw new Error(`Failed to fetch currencies: ${response.status}`) } - this.debug('No API currencies returned, using base currencies only') - return baseCurrencies + const apiCurrencies = await response.json() + + if (apiCurrencies && Array.isArray(apiCurrencies)) { + this.debug('Retrieved currencies from LNbits core:', { count: apiCurrencies.length, currencies: apiCurrencies }) + return apiCurrencies + } + + this.debug('No currencies returned from server, using default') + return ['sat'] } catch (error) { - this.debug('Failed to get currencies, falling back to base currencies:', error) - return baseCurrencies + this.debug('Failed to get currencies, using default:', error) + return ['sat'] } } diff --git a/target-ui.md b/target-ui.md new file mode 100644 index 0000000..7b8e802 --- /dev/null +++ b/target-ui.md @@ -0,0 +1,216 @@ + + +