@saasicat/ui-vue 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +47 -0
  3. package/dist/index.cjs +3776 -0
  4. package/dist/index.d.cts +2395 -0
  5. package/dist/index.d.ts +2395 -0
  6. package/dist/index.js +3659 -0
  7. package/dist/testing-e2e/admin-pages-suite.cjs +134 -0
  8. package/dist/testing-e2e/admin-pages-suite.d.cts +37 -0
  9. package/dist/testing-e2e/admin-pages-suite.d.ts +37 -0
  10. package/dist/testing-e2e/admin-pages-suite.js +109 -0
  11. package/package.json +87 -0
  12. package/src/action-registry.ts +110 -0
  13. package/src/batch-column-fetcher.ts +152 -0
  14. package/src/boot-loader.ts +60 -0
  15. package/src/components/BundleVersionPublishDialog.vue +359 -0
  16. package/src/components/BusinessTypeVersionEditorDialog.vue +417 -0
  17. package/src/components/BusinessTypeVersionPublishDialog.vue +258 -0
  18. package/src/components/FeatureGate.vue +56 -0
  19. package/src/components/KpiCard.vue +53 -0
  20. package/src/components/KvBlock.vue +36 -0
  21. package/src/components/MarketingPromotionsTab.vue +861 -0
  22. package/src/components/MfaPromptDialog.vue +104 -0
  23. package/src/components/TenantActionConfirmDialog.vue +252 -0
  24. package/src/components/VersionDiffPreview.vue +150 -0
  25. package/src/components/bundle-editor/BundleCreatePanel.vue +681 -0
  26. package/src/components/bundle-editor/BundleFeaturesEditor.vue +215 -0
  27. package/src/components/bundle-editor/BundlePlanCompatPicker.vue +316 -0
  28. package/src/components/bundle-editor/BundleQuotasEditor.vue +219 -0
  29. package/src/components/bundle-editor/BundleStatusBanner.vue +189 -0
  30. package/src/components/bundle-editor/BundleVersionInlineEditor.vue +659 -0
  31. package/src/components/bundle-editor/BundleVersionStrip.vue +207 -0
  32. package/src/components/bundle-editor/bundle-version-status.ts +164 -0
  33. package/src/components/bundle-editor/catalog-i18n.ts +85 -0
  34. package/src/components/dialogs/PilotCreateDialog.vue +780 -0
  35. package/src/components/dialogs/PilotEditDialog.vue +548 -0
  36. package/src/components/dialogs/PromoCodeCreateDialog.vue +737 -0
  37. package/src/components/dialogs/PromoCodeEditDialog.vue +859 -0
  38. package/src/components/dialogs/types.ts +126 -0
  39. package/src/components/plan/PlanCycleToggle.vue +99 -0
  40. package/src/components/plan/PlanGrid.vue +211 -0
  41. package/src/components/plan/PriceSummary.vue +293 -0
  42. package/src/components/plan/PromoCodeInput.vue +192 -0
  43. package/src/components/plan/PublicBundleGrid.vue +287 -0
  44. package/src/components/plan-cockpit/PlanCockpit.vue +993 -0
  45. package/src/components/plan-cockpit/PlanCockpitAuditLog.vue +65 -0
  46. package/src/components/plan-cockpit/PlanCockpitDiffPanel.vue +91 -0
  47. package/src/components/plan-cockpit/PlanCockpitHeader.vue +98 -0
  48. package/src/components/plan-cockpit/PlanCockpitImpactPanel.vue +99 -0
  49. package/src/components/plan-cockpit/PlanCockpitKpis.vue +57 -0
  50. package/src/components/plan-cockpit/PlanCockpitVersions.vue +226 -0
  51. package/src/components/plan-cockpit/types.ts +72 -0
  52. package/src/components/plan-create-dialog/PlanCreateDialog.vue +508 -0
  53. package/src/components/plan-detail/PlanAuditLog.vue +59 -0
  54. package/src/components/plan-detail/PlanDetail.vue +1195 -0
  55. package/src/components/plan-detail/PlanDetailHeader.vue +185 -0
  56. package/src/components/plan-detail/PlanDetailKpis.vue +57 -0
  57. package/src/components/plan-detail/PlanTerminateDialog.vue +76 -0
  58. package/src/components/plan-detail/PlanVersionDiffPanel.vue +149 -0
  59. package/src/components/plan-detail/PlanVersionsPanel.vue +255 -0
  60. package/src/components/plan-detail/types.ts +59 -0
  61. package/src/components/plan-list/PlanList.vue +1067 -0
  62. package/src/components/plan-matrix/PlanMatrix.vue +1113 -0
  63. package/src/components/plan-review/PlanReview.vue +742 -0
  64. package/src/components/plan-version-editor/PlanCatalogPreview.vue +184 -0
  65. package/src/components/plan-version-editor/PlanComponentPool.vue +272 -0
  66. package/src/components/plan-version-editor/PlanVersionBasket.vue +281 -0
  67. package/src/components/plan-version-editor/PlanVersionDiffDialog.vue +84 -0
  68. package/src/components/plan-version-editor/PlanVersionEditor.vue +1728 -0
  69. package/src/components/plan-version-editor/PlanVersionEditorHeader.vue +94 -0
  70. package/src/components/plan-version-editor/types.ts +96 -0
  71. package/src/components/wizard-stepper/WizardStepper.vue +107 -0
  72. package/src/create-admin-routes.ts +68 -0
  73. package/src/create-super-admin-app.ts +345 -0
  74. package/src/entitlement-provider.ts +36 -0
  75. package/src/feature-router-guard.ts +77 -0
  76. package/src/http-json.ts +62 -0
  77. package/src/index.ts +98 -0
  78. package/src/manifest-loader.ts +139 -0
  79. package/src/manifest-store-factory.ts +114 -0
  80. package/src/nav-builder.ts +274 -0
  81. package/src/pages-standard/AdminLayout.vue +411 -0
  82. package/src/pages-standard/AdminManifestErrorPage.vue +79 -0
  83. package/src/pages-standard/AuditPage.vue +223 -0
  84. package/src/pages-standard/BundlesPage.vue +910 -0
  85. package/src/pages-standard/BusinessTypesPage.vue +662 -0
  86. package/src/pages-standard/DashboardPage.vue +595 -0
  87. package/src/pages-standard/DiscoveryPage.vue +663 -0
  88. package/src/pages-standard/EmailHistoryPage.vue +576 -0
  89. package/src/pages-standard/MarketingCatalogPage.vue +1771 -0
  90. package/src/pages-standard/PilotsPage.vue +577 -0
  91. package/src/pages-standard/PlanVersionsPage.vue +216 -0
  92. package/src/pages-standard/PlansPage.vue +1222 -0
  93. package/src/pages-standard/PlatformEmailPage.vue +434 -0
  94. package/src/pages-standard/PromoCodeDetailPage.vue +331 -0
  95. package/src/pages-standard/PromoCodesPage.vue +589 -0
  96. package/src/pages-standard/SubscriptionsPage.vue +159 -0
  97. package/src/pages-standard/SuperAdminLoginPage.vue +299 -0
  98. package/src/pages-standard/SuperAdminSetupWizard.vue +405 -0
  99. package/src/pages-standard/TenantDetailPage.vue +432 -0
  100. package/src/pages-standard/TenantsPage.vue +732 -0
  101. package/src/pages-standard/UsersPage.vue +504 -0
  102. package/src/pages-standard/bundles-page/BundleAccordionList.vue +116 -0
  103. package/src/pages-standard/bundles-page/BundleDetailPanel.vue +193 -0
  104. package/src/pages-standard/bundles-page/BundlesFilterBar.vue +48 -0
  105. package/src/pages-standard/bundles-page/BundlesHeader.vue +67 -0
  106. package/src/pages-standard/bundles-page/BundlesKpis.vue +39 -0
  107. package/src/pages-standard/bundles-page/types.ts +15 -0
  108. package/src/pages-standard/discovery-page/CatalogEntryTransPanel.vue +246 -0
  109. package/src/pages-standard/discovery-page/DiscoveryCapList.vue +171 -0
  110. package/src/pages-standard/discovery-page/DiscoveryFeatureCard.vue +410 -0
  111. package/src/pages-standard/discovery-page/DiscoveryHeader.vue +31 -0
  112. package/src/pages-standard/discovery-page/DiscoveryKpis.vue +47 -0
  113. package/src/pages-standard/discovery-page/DiscoveryMetaBanner.vue +26 -0
  114. package/src/pages-standard/discovery-page/DiscoveryQuotaCard.vue +247 -0
  115. package/src/pages-standard/discovery-page/DiscoveryStatusControl.vue +73 -0
  116. package/src/pages-standard/discovery-page/discovery-ui.ts +166 -0
  117. package/src/pages-standard/email-history.types.ts +48 -0
  118. package/src/pages-standard/marketing-catalog/MarketingCatalogAdmin.vue +448 -0
  119. package/src/pages-standard/marketing-catalog/MarketingCatalogHeader.vue +93 -0
  120. package/src/pages-standard/marketing-catalog/MarketingCatalogPreview.vue +138 -0
  121. package/src/pages-standard/marketing-catalog/MarketingCatalogToolbar.vue +58 -0
  122. package/src/pages-standard/marketing-catalog/types.ts +43 -0
  123. package/src/pages-standard/plan-versions/PlanDiffCard.vue +132 -0
  124. package/src/pages-standard/plan-versions/PlanVersionHeader.vue +293 -0
  125. package/src/pages-standard/plan-versions/PlanVersionStatusBadge.vue +48 -0
  126. package/src/pages-standard/plan-versions/PlanVersionsAudit.vue +307 -0
  127. package/src/pages-standard/plan-versions/PlanVersionsDiff.vue +269 -0
  128. package/src/pages-standard/plan-versions/PlanVersionsKpi.vue +65 -0
  129. package/src/pages-standard/plan-versions/PlanVersionsList.vue +292 -0
  130. package/src/pages-standard/plan-versions/PlanVersionsMatrix.vue +261 -0
  131. package/src/pages-standard/plan-versions/PlanVersionsTimeline.vue +300 -0
  132. package/src/pages-standard/plan-versions/VersionDiffPreview.vue +167 -0
  133. package/src/pages-standard/plan-versions/format.ts +53 -0
  134. package/src/pages-standard/plan-versions/types.ts +33 -0
  135. package/src/pages-standard/plans-page/PlanArchiveDialog.vue +50 -0
  136. package/src/pages-standard/plans-page/PlanBundleOverview.vue +147 -0
  137. package/src/pages-standard/plans-page/PlanDiscardDraftDialog.vue +46 -0
  138. package/src/pages-standard/plans-page/PlanPublishDialog.vue +106 -0
  139. package/src/pages-standard/plans-page/PlansPageToast.vue +69 -0
  140. package/src/pages-standard/plans-page/types.ts +18 -0
  141. package/src/pages-standard/platform-email.types.ts +41 -0
  142. package/src/pages-standard/sa-theme.css +223 -0
  143. package/src/pages-standard/tenants/StatusPill.vue +62 -0
  144. package/src/pages-standard/tenants/format.ts +38 -0
  145. package/src/pages-tenant/LimitsRow.vue +67 -0
  146. package/src/pages-tenant/MySubscriptionBundlesPage.vue +604 -0
  147. package/src/pages-tenant/OnboardingConfigurator.vue +417 -0
  148. package/src/pages-tenant/PackageSnapshotPanel.vue +241 -0
  149. package/src/pages-tenant/PendingVersionBanner.vue +126 -0
  150. package/src/pages-tenant/PlanChangeWizard.vue +630 -0
  151. package/src/pages-tenant/TenantPlanSection.vue +729 -0
  152. package/src/pages-tenant/UsageBar.vue +107 -0
  153. package/src/pages-tenant/default-i18n.ts +280 -0
  154. package/src/pages-tenant/tenant-plan-section/BundlePreviewDialog.vue +304 -0
  155. package/src/pages-tenant/tenant-plan-section/TenantBundleStore.vue +323 -0
  156. package/src/pages-tenant/tenant-plan-section/TenantFeatureMatrix.vue +122 -0
  157. package/src/pages-tenant/tenant-plan-section/TenantPlanCardHeader.vue +67 -0
  158. package/src/pages-tenant/tenant-plan-section/TenantUsageGrid.vue +31 -0
  159. package/src/plan-versions-catalog.ts +368 -0
  160. package/src/platform-loaders.ts +68 -0
  161. package/src/project-page-host.ts +108 -0
  162. package/src/testing-e2e/admin-pages-suite.ts +187 -0
  163. package/src/types.ts +58 -0
  164. package/src/use-actions.ts +25 -0
  165. package/src/use-api-list.ts +151 -0
  166. package/src/use-audit-entries.ts +48 -0
  167. package/src/use-batch-columns.ts +59 -0
  168. package/src/use-bulk-publish.ts +150 -0
  169. package/src/use-bundle-versions-map.ts +112 -0
  170. package/src/use-bundles.ts +297 -0
  171. package/src/use-business-types.ts +269 -0
  172. package/src/use-catalog-entries.ts +243 -0
  173. package/src/use-discovery.ts +158 -0
  174. package/src/use-entitlement.ts +87 -0
  175. package/src/use-live-plan-versions.ts +126 -0
  176. package/src/use-manifest.ts +57 -0
  177. package/src/use-marketing-projections.ts +160 -0
  178. package/src/use-nav.ts +33 -0
  179. package/src/use-plan-editor.ts +162 -0
  180. package/src/use-plan-versions.ts +83 -0
  181. package/src/use-plans.ts +375 -0
  182. package/src/use-platform-tenant-actions.ts +286 -0
  183. package/src/use-promotions.ts +126 -0
  184. package/src/use-public-boot.ts +40 -0
  185. package/src/use-subscription-draft.ts +355 -0
  186. package/src/use-super-admin-context.ts +93 -0
  187. package/src/use-tenant-action-flow.ts +238 -0
  188. package/src/use-tenant-billing-catalog.ts +160 -0
  189. package/src/use-tenant-billing.ts +453 -0
  190. package/src/use-tenant-manifest.ts +94 -0
  191. package/src/use-tenant-subscription-bundles.ts +148 -0
  192. package/src/use-tenants.ts +61 -0
  193. package/src/version.ts +10 -0
@@ -0,0 +1,159 @@
1
+ <template>
2
+ <div class="sa-subscriptions">
3
+ <header class="sa-subscriptions__head">
4
+ <div>
5
+ <h1 class="sa-subscriptions__title">Abonnements</h1>
6
+ <p v-if="subtitle" class="sa-subscriptions__sub">{{ subtitle }}</p>
7
+ </div>
8
+ <slot name="head-actions" />
9
+ </header>
10
+
11
+ <div class="sa-subscriptions__body">
12
+ <div class="sa-subscriptions__card">
13
+ <q-table
14
+ flat
15
+ :rows="rows"
16
+ :columns="effectiveColumns"
17
+ row-key="id"
18
+ :pagination="{ rowsPerPage: 0 }"
19
+ :loading="loading"
20
+ hide-pagination
21
+ />
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { computed, onMounted, ref } from 'vue';
29
+
30
+ // Platform standard page: subscriptions (minimal). Apps pass
31
+ // `loadSubscriptions` + optional `columns` through — default columns show
32
+ // tenant/plan/status/period.
33
+
34
+ export interface SubscriptionRow {
35
+ id: string;
36
+ tenant?: { slug?: string; name?: string };
37
+ tenantSlug?: string;
38
+ plan?: string;
39
+ planId?: string;
40
+ status?: string;
41
+ periodEndsAt?: string | null;
42
+ monthlyNet?: string | number | null;
43
+ [extra: string]: unknown;
44
+ }
45
+
46
+ interface Column {
47
+ name: string;
48
+ label: string;
49
+ field: string | ((r: SubscriptionRow) => unknown);
50
+ align?: 'left' | 'right' | 'center';
51
+ sortable?: boolean;
52
+ }
53
+
54
+ const props = withDefaults(
55
+ defineProps<{
56
+ loadSubscriptions: () => Promise<SubscriptionRow[]>;
57
+ subtitle?: string;
58
+ columns?: readonly Column[];
59
+ }>(),
60
+ {},
61
+ );
62
+
63
+ const rows = ref<SubscriptionRow[]>([]);
64
+ const loading = ref(false);
65
+
66
+ const defaultColumns: Column[] = [
67
+ {
68
+ name: 'tenant',
69
+ label: 'Mandant',
70
+ field: (r) => r.tenant?.name ?? r.tenant?.slug ?? r.tenantSlug ?? '—',
71
+ align: 'left',
72
+ sortable: true,
73
+ },
74
+ {
75
+ name: 'plan',
76
+ label: 'Plan',
77
+ field: (r) => r.plan ?? r.planId ?? '—',
78
+ align: 'left',
79
+ },
80
+ {
81
+ name: 'status',
82
+ label: 'Status',
83
+ field: (r) => r.status ?? '—',
84
+ align: 'left',
85
+ },
86
+ {
87
+ name: 'periodEndsAt',
88
+ label: 'Endet',
89
+ field: (r) => formatDate(r.periodEndsAt) ?? '∞',
90
+ align: 'left',
91
+ },
92
+ ];
93
+
94
+ const effectiveColumns = computed<Column[]>(() =>
95
+ props.columns ? [...props.columns] : defaultColumns,
96
+ );
97
+
98
+ async function reload() {
99
+ loading.value = true;
100
+ try {
101
+ rows.value = await props.loadSubscriptions();
102
+ } catch (err) {
103
+ rows.value = [];
104
+ console.warn('[SubscriptionsPage] loadSubscriptions failed:', err);
105
+ } finally {
106
+ loading.value = false;
107
+ }
108
+ }
109
+
110
+ onMounted(reload);
111
+
112
+ function formatDate(iso: string | null | undefined): string | null {
113
+ if (!iso) return null;
114
+ try {
115
+ return new Date(iso).toLocaleDateString('de-DE', {
116
+ day: '2-digit',
117
+ month: 'short',
118
+ year: 'numeric',
119
+ });
120
+ } catch {
121
+ return String(iso);
122
+ }
123
+ }
124
+ </script>
125
+
126
+ <style scoped>
127
+ .sa-subscriptions {
128
+ min-height: calc(100vh - 56px);
129
+ background: var(--sa-bg-app, #f1f5f9);
130
+ }
131
+ .sa-subscriptions__head {
132
+ padding: 20px 28px 8px;
133
+ display: flex;
134
+ align-items: flex-start;
135
+ justify-content: space-between;
136
+ gap: 16px;
137
+ }
138
+ .sa-subscriptions__title {
139
+ margin: 0;
140
+ font-family: var(--sa-font-head, system-ui, sans-serif);
141
+ font-weight: 700;
142
+ font-size: 22px;
143
+ color: var(--sa-heading, #0f172a);
144
+ }
145
+ .sa-subscriptions__sub {
146
+ margin: 4px 0 0;
147
+ color: var(--sa-muted-dark, #475569);
148
+ font-size: 13.5px;
149
+ }
150
+ .sa-subscriptions__body {
151
+ padding: 12px 28px 28px;
152
+ }
153
+ .sa-subscriptions__card {
154
+ background: #fff;
155
+ border: 1px solid var(--sa-border, #e2e8f0);
156
+ border-radius: 12px;
157
+ overflow: hidden;
158
+ }
159
+ </style>
@@ -0,0 +1,299 @@
1
+ <template>
2
+ <SuperAdminSetupWizard
3
+ v-if="needsSetup"
4
+ :display-name="brandName"
5
+ :icon="iconText"
6
+ @done="needsSetup = false"
7
+ />
8
+ <div v-else class="sa-login-wrap">
9
+ <div class="sa-login-card">
10
+ <div class="sa-login-brand">
11
+ <div v-if="logoUrl" class="sa-login-logo sa-login-logo--img">
12
+ <img :src="logoUrl" :alt="brandName" />
13
+ </div>
14
+ <div v-else class="sa-login-logo sa-login-logo--text">
15
+ {{ iconText }}
16
+ </div>
17
+ <div class="sa-login-brand__text">
18
+ <div class="sa-login-brand__name">{{ brandName }}</div>
19
+ <div class="sa-login-brand__tag">{{ tagText }}</div>
20
+ </div>
21
+ </div>
22
+
23
+ <h1 class="sa-login-title">Anmelden</h1>
24
+ <p v-if="subtitle" class="sa-login-subtitle">{{ subtitle }}</p>
25
+
26
+ <q-form @submit.prevent="handleSubmit" class="sa-login-form">
27
+ <q-input
28
+ v-model="form.email"
29
+ label="E-Mail"
30
+ type="email"
31
+ outlined
32
+ dense
33
+ autofocus
34
+ :disable="loading"
35
+ class="q-mb-sm"
36
+ :rules="[(v: string) => /\S+@\S+\.\S+/.test(v) || 'Bitte gültige E-Mail']"
37
+ />
38
+ <q-input
39
+ v-model="form.password"
40
+ label="Passwort"
41
+ :type="showPw ? 'text' : 'password'"
42
+ outlined
43
+ dense
44
+ :disable="loading"
45
+ class="q-mb-sm"
46
+ :rules="[(v: string) => v.length > 0 || 'Passwort ist Pflicht']"
47
+ >
48
+ <template #append>
49
+ <q-icon
50
+ :name="showPw ? 'visibility_off' : 'visibility'"
51
+ class="cursor-pointer"
52
+ @click="showPw = !showPw"
53
+ />
54
+ </template>
55
+ </q-input>
56
+
57
+ <q-banner v-if="errorMessage" class="sa-login-error" rounded>
58
+ {{ errorMessage }}
59
+ </q-banner>
60
+
61
+ <q-btn
62
+ unelevated
63
+ color="primary"
64
+ icon="login"
65
+ label="Anmelden"
66
+ :loading="loading"
67
+ :disable="!canSubmit"
68
+ class="full-width q-mt-sm"
69
+ type="submit"
70
+ />
71
+ </q-form>
72
+
73
+ <div v-if="devHint" class="sa-login-hint">
74
+ Test-Account: <code>{{ devHint.email }}</code> / <code>{{ devHint.password }}</code>
75
+ </div>
76
+ </div>
77
+
78
+ <div v-if="bootEnvironment" class="sa-login-env">
79
+ {{ brandName }} · {{ bootEnvironment }}
80
+ </div>
81
+ </div>
82
+ </template>
83
+
84
+ <script setup lang="ts">
85
+ import { computed, onMounted, reactive, ref } from 'vue';
86
+ import { useRouter } from 'vue-router';
87
+ import type { SetupStatusResponse } from '@saasicat/types';
88
+
89
+ import { usePublicBoot } from '../use-public-boot.js';
90
+ import {
91
+ useSuperAdminBrand,
92
+ useSuperAdminEndpoints,
93
+ useSuperAdminHttp,
94
+ useSuperAdminLoginAdapter,
95
+ } from '../use-super-admin-context.js';
96
+ import { getJson } from '../http-json.js';
97
+ import SuperAdminSetupWizard from './SuperAdminSetupWizard.vue';
98
+
99
+ interface Props {
100
+ /**
101
+ * Optional additional subtitle below the title (e.g. a hint about the
102
+ * SUPER_ADMIN role). Empty by default.
103
+ */
104
+ subtitle?: string;
105
+ }
106
+
107
+ const props = defineProps<Props>();
108
+
109
+ const router = useRouter();
110
+ const brand = useSuperAdminBrand();
111
+ const endpoints = useSuperAdminEndpoints();
112
+ const adapter = useSuperAdminLoginAdapter();
113
+ const http = useSuperAdminHttp();
114
+ const boot = usePublicBoot({ endpoint: endpoints.publicBootEndpoint, http });
115
+
116
+ const form = reactive({ email: adapter.devHint?.email ?? '', password: '' });
117
+ const showPw = ref(false);
118
+ const loading = ref(false);
119
+ const errorMessage = ref<string | null>(null);
120
+ // First run: as long as no SUPER_ADMIN exists, this page shows the setup
121
+ // wizard instead of the login. Apps without a SetupModule return 404 → stays false.
122
+ const needsSetup = ref(false);
123
+
124
+ const brandName = computed(() => boot.boot.value?.project.displayName ?? brand.name);
125
+ const tagText = computed(() => boot.boot.value?.project.label ?? brand.tag ?? 'SuperAdmin');
126
+ const iconText = computed(() => boot.boot.value?.project.icon ?? brand.logoText);
127
+ const logoUrl = computed(() => boot.boot.value?.project.logoUrl ?? null);
128
+ const bootEnvironment = computed(() => {
129
+ const env = boot.boot.value?.project.environment;
130
+ return env && env !== 'production' ? env : null;
131
+ });
132
+
133
+ const devHint = computed(() => {
134
+ if (!adapter.devHint) return null;
135
+ if (boot.boot.value?.project.environment === 'production') return null;
136
+ return adapter.devHint;
137
+ });
138
+
139
+ const canSubmit = computed(
140
+ () => /\S+@\S+\.\S+/.test(form.email) && form.password.length >= 1 && !loading.value,
141
+ );
142
+
143
+ onMounted(() => {
144
+ void boot.load();
145
+ void checkSetup();
146
+ });
147
+
148
+ async function checkSetup(): Promise<void> {
149
+ try {
150
+ const status = await getJson<SetupStatusResponse>(
151
+ http,
152
+ `${endpoints.apiBase}/setup/status`,
153
+ );
154
+ needsSetup.value = status.needsSetup === true;
155
+ } catch {
156
+ // Setup endpoint not present (app without a SetupModule) → normal login.
157
+ }
158
+ }
159
+
160
+ function describeError(
161
+ result: Extract<Awaited<ReturnType<typeof adapter.login>>, { ok: false }>,
162
+ ): string {
163
+ if (result.message) return result.message;
164
+ if (result.code === 'BAD_CREDENTIALS') return 'E-Mail oder Passwort falsch.';
165
+ if (result.code === 'NOT_SUPER_ADMIN') {
166
+ return 'Dieser Account hat keine SUPER_ADMIN-Rolle. Bitte Tenant-Frontend nutzen.';
167
+ }
168
+ return 'Anmeldung fehlgeschlagen.';
169
+ }
170
+
171
+ async function handleSubmit(): Promise<void> {
172
+ if (!canSubmit.value) return;
173
+ loading.value = true;
174
+ errorMessage.value = null;
175
+ try {
176
+ const result = await adapter.login(form.email, form.password);
177
+ if (result.ok) {
178
+ await router.push(adapter.redirectAfterLogin ?? '/admin/dashboard');
179
+ return;
180
+ }
181
+ errorMessage.value = describeError(result);
182
+ } catch (err) {
183
+ const e = err as { response?: { data?: { message?: string; code?: string } } };
184
+ errorMessage.value =
185
+ e.response?.data?.message ?? e.response?.data?.code ?? 'Anmeldung fehlgeschlagen.';
186
+ } finally {
187
+ loading.value = false;
188
+ }
189
+ }
190
+ </script>
191
+
192
+ <style scoped>
193
+ .sa-login-wrap {
194
+ min-height: 100vh;
195
+ display: flex;
196
+ flex-direction: column;
197
+ align-items: center;
198
+ justify-content: center;
199
+ padding: 24px;
200
+ background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
201
+ }
202
+ .sa-login-card {
203
+ width: 420px;
204
+ max-width: 92vw;
205
+ background: #fff;
206
+ border-radius: 18px;
207
+ padding: 32px;
208
+ box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
209
+ }
210
+ .sa-login-brand {
211
+ display: flex;
212
+ align-items: center;
213
+ gap: 12px;
214
+ margin-bottom: 22px;
215
+ }
216
+ .sa-login-logo {
217
+ width: 44px;
218
+ height: 44px;
219
+ border-radius: 10px;
220
+ display: flex;
221
+ align-items: center;
222
+ justify-content: center;
223
+ overflow: hidden;
224
+ }
225
+ .sa-login-logo--text {
226
+ background: var(--sa-login-logo-bg, linear-gradient(135deg, #475569, #1e293b));
227
+ color: var(--sa-login-logo-color, #fff);
228
+ font-weight: 800;
229
+ font-size: 18px;
230
+ text-transform: uppercase;
231
+ }
232
+ .sa-login-logo--img img {
233
+ width: 100%;
234
+ height: 100%;
235
+ object-fit: contain;
236
+ }
237
+ .sa-login-brand__name {
238
+ font-weight: 800;
239
+ font-size: 16px;
240
+ color: #0f172a;
241
+ line-height: 1.1;
242
+ }
243
+ .sa-login-brand__tag {
244
+ font-size: 12px;
245
+ color: var(--sa-login-tag-color, #475569);
246
+ text-transform: uppercase;
247
+ letter-spacing: 0.08em;
248
+ }
249
+
250
+ .sa-login-title {
251
+ font-size: 22px;
252
+ font-weight: 800;
253
+ color: #0f172a;
254
+ margin: 0 0 6px;
255
+ }
256
+ .sa-login-subtitle {
257
+ font-size: 13px;
258
+ color: #475569;
259
+ margin: 0 0 20px;
260
+ line-height: 1.5;
261
+ }
262
+
263
+ .sa-login-form {
264
+ display: flex;
265
+ flex-direction: column;
266
+ }
267
+ .full-width {
268
+ width: 100%;
269
+ }
270
+ .sa-login-error {
271
+ background: #fef2f2;
272
+ border: 1px solid #fecaca;
273
+ color: #b91c1c;
274
+ font-size: 13px;
275
+ margin-top: 4px;
276
+ padding: 8px 12px;
277
+ border-radius: 8px;
278
+ }
279
+ .sa-login-hint {
280
+ margin-top: 18px;
281
+ padding: 10px 12px;
282
+ background: #f1f5f9;
283
+ border-radius: 8px;
284
+ font-size: 12px;
285
+ color: #475569;
286
+ }
287
+ .sa-login-hint code {
288
+ background: #e2e8f0;
289
+ padding: 1px 5px;
290
+ border-radius: 4px;
291
+ }
292
+ .sa-login-env {
293
+ margin-top: 18px;
294
+ color: #cbd5e1;
295
+ font-size: 12px;
296
+ text-transform: uppercase;
297
+ letter-spacing: 0.08em;
298
+ }
299
+ </style>