fix(subscriptions): fix subscription UI and API after store→merchant migration

Store detail page now shows all platform subscriptions instead of always
"No Subscription Found". Subscriptions listing page renamed from Store
to Merchant throughout (template, JS, menu, i18n) with Platform column
added. Tiers API supports platform_id filtering.

Merchant detail page no longer hardcodes 'oms' platform — loads all
platforms, shows subscription cards per platform with labels, and the
Create Subscription modal includes a platform selector with
platform-filtered tiers. Create button always accessible in Quick Actions.

Edit modal on /admin/subscriptions loads tiers from API filtered by
platform instead of hardcoded options, sends tier_code (not tier) to
match PATCH schema, and shows platform context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-10 19:17:51 +01:00
parent 0984ff7d17
commit 0b37274140
14 changed files with 414 additions and 326 deletions

View File

@@ -13,9 +13,7 @@ function adminStoreDetail() {
// Store detail page specific state
currentPage: 'store-detail',
store: null,
subscription: null,
subscriptionTier: null,
usageMetrics: [],
subscriptions: [],
loading: false,
error: null,
storeCode: null,
@@ -44,7 +42,7 @@ function adminStoreDetail() {
await this.loadStore();
// Load subscription after store is loaded
if (this.store?.id) {
await this.loadSubscription();
await this.loadSubscriptions();
}
} else {
detailLog.error('No store code in URL');
@@ -102,14 +100,14 @@ function adminStoreDetail() {
return formatted;
},
// Load subscription data for this store via convenience endpoint
async loadSubscription() {
// Load subscriptions data for this store via convenience endpoint
async loadSubscriptions() {
if (!this.store?.id) {
detailLog.warn('Cannot load subscription: no store ID');
detailLog.warn('Cannot load subscriptions: no store ID');
return;
}
detailLog.info('Loading subscription for store:', this.store.id);
detailLog.info('Loading subscriptions for store:', this.store.id);
try {
const url = `/admin/subscriptions/store/${this.store.id}`;
@@ -118,24 +116,20 @@ function adminStoreDetail() {
const response = await apiClient.get(url);
window.LogConfig.logApiCall('GET', url, response, 'response');
this.subscription = response.subscription;
this.subscriptionTier = response.tier;
this.usageMetrics = response.features || [];
this.subscriptions = response.subscriptions || [];
detailLog.info('Subscription loaded:', {
tier: this.subscription?.tier,
status: this.subscription?.status,
features_count: this.usageMetrics.length
detailLog.info('Subscriptions loaded:', {
count: this.subscriptions.length,
platforms: this.subscriptions.map(e => e.platform_name)
});
} catch (error) {
// 404 means no subscription exists - that's OK
if (error.status === 404) {
detailLog.info('No subscription found for store');
this.subscription = null;
this.usageMetrics = [];
detailLog.info('No subscriptions found for store');
this.subscriptions = [];
} else {
detailLog.warn('Failed to load subscription:', error.message);
detailLog.warn('Failed to load subscriptions:', error.message);
}
}
},