diff --git a/src/modules/market/components/MerchantStore.vue b/src/modules/market/components/MerchantStore.vue index 3e6896f..ae755a9 100644 --- a/src/modules/market/components/MerchantStore.vue +++ b/src/modules/market/components/MerchantStore.vue @@ -443,6 +443,102 @@ + + +
+
+

Products

+ +
+ + +
+
+ Loading products... +
+ + +
+
+ +
+

No Products Yet

+

Start selling by adding your first product

+ +
+ + +
+
+ +
+ + +
+ + +
+
+

{{ product.name }}

+

+ {{ product.config.description }} +

+
+ +
+
+ + {{ product.price }} {{ product.config.currency || activeStall?.currency || 'sat' }} + +
+ Qty: {{ product.quantity }} +
+
+
+ + {{ product.active ? 'Active' : 'Inactive' }} + +
+
+ + +
+ + {{ category }} + +
+ + +
+ +
+
+
+
+
+ @@ -660,6 +756,35 @@ + + + + + + Add New Product + + +
+
+ +

Product Creation Coming Soon

+

+ We're working on the product creation form. This will allow you to add products with images, descriptions, pricing, and inventory management. +

+
+ +
+ +
+
+
+
diff --git a/src/modules/market/services/nostrmarketAPI.ts b/src/modules/market/services/nostrmarketAPI.ts index d765b8f..7ba371e 100644 --- a/src/modules/market/services/nostrmarketAPI.ts +++ b/src/modules/market/services/nostrmarketAPI.ts @@ -55,6 +55,45 @@ export interface Zone { countries: string[] } +export interface ProductShippingCost { + id: string + cost: number +} + +export interface ProductConfig { + description?: string + currency?: string + use_autoreply?: boolean + autoreply_message?: string + shipping: ProductShippingCost[] +} + +export interface Product { + id?: string + stall_id: string + name: string + categories: string[] + images: string[] + price: number + quantity: number + active: boolean + pending: boolean + config: ProductConfig + event_id?: string + event_created_at?: number +} + +export interface CreateProductRequest { + stall_id: string + name: string + categories: string[] + images: string[] + price: number + quantity: number + active: boolean + config: ProductConfig +} + export interface CreateZoneRequest { name: string currency: string @@ -315,4 +354,109 @@ export class NostrmarketAPI extends BaseService { return baseCurrencies } } + + /** + * Get products for a stall + */ + async getProducts(walletInkey: string, stallId: string, pending: boolean = false): Promise { + const products = await this.request( + `/api/v1/stall/product/${stallId}?pending=${pending}`, + walletInkey, + { method: 'GET' } + ) + + this.debug('Retrieved products:', { + stallId, + count: products?.length || 0, + pending + }) + + return products || [] + } + + /** + * Create a new product + */ + async createProduct( + walletAdminkey: string, + productData: CreateProductRequest + ): Promise { + const product = await this.request( + '/api/v1/product', + walletAdminkey, + { + method: 'POST', + body: JSON.stringify(productData), + } + ) + + this.debug('Created product:', { + productId: product.id, + productName: product.name, + stallId: product.stall_id + }) + + return product + } + + /** + * Update an existing product + */ + async updateProduct( + walletAdminkey: string, + productId: string, + productData: Product + ): Promise { + const product = await this.request( + `/api/v1/product/${productId}`, + walletAdminkey, + { + method: 'PATCH', + body: JSON.stringify(productData), + } + ) + + this.debug('Updated product:', { + productId: product.id, + productName: product.name + }) + + return product + } + + /** + * Get a single product by ID + */ + async getProduct(walletInkey: string, productId: string): Promise { + try { + const product = await this.request( + `/api/v1/product/${productId}`, + walletInkey, + { method: 'GET' } + ) + + this.debug('Retrieved product:', { + productId: product?.id, + productName: product?.name + }) + + return product + } catch (error) { + this.debug('Failed to get product:', error) + return null + } + } + + /** + * Delete a product + */ + async deleteProduct(walletAdminkey: string, productId: string): Promise { + await this.request( + `/api/v1/product/${productId}`, + walletAdminkey, + { method: 'DELETE' } + ) + + this.debug('Deleted product:', { productId }) + } } \ No newline at end of file