@revenexx/cover 0.2.6 → 0.2.7

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.
@@ -5,4 +5,7 @@ export const accountApi = {
5
5
  addressUpdate: (id: string) => `/api/account/address/${id}`,
6
6
  addressCreate: () => "/api/account/address",
7
7
  addressDelete: (id: string) => `/api/account/address/${id}`,
8
+ organization: () => "/api/account/organization",
9
+ team: () => "/api/account/team",
10
+ teamMemberUpdate: (id: string) => `/api/account/team/${id}`,
8
11
  };
package/app/app.config.ts CHANGED
@@ -13,6 +13,8 @@ export default defineAppConfig({
13
13
  schemaService: "local-file",
14
14
  accountService: "mock",
15
15
  addressService: "mock",
16
+ organizationService: "mock",
17
+ contactsService: "mock",
16
18
  authService: "mock",
17
19
  productService: "mock",
18
20
  categoryService: "mock",
@@ -0,0 +1,159 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The buyer's own company (organization) — read view of the company identity
4
+ * (name, VAT id, status) with an edit modal for the touchable fields. Backed
5
+ * by the organization service (customers.organizations on the live API).
6
+ * Private buyers (no organization in the session) get an empty state.
7
+ */
8
+ import type { AccountOrganizationFormState } from "../../../interfaces/account/organization";
9
+
10
+ const { icon } = useIcons();
11
+ const { t } = useI18n();
12
+ const toast = useToast();
13
+ const { organization, status, error, updateOrganization } = useAccountOrganization();
14
+
15
+ const editing = ref(false);
16
+ const saving = ref(false);
17
+ const form = reactive<AccountOrganizationFormState>({ name: "", vatId: "" });
18
+
19
+ function openEdit(): void {
20
+ form.name = organization.value?.name ?? "";
21
+ form.vatId = organization.value?.vatId ?? "";
22
+ editing.value = true;
23
+ }
24
+
25
+ async function save(): Promise<void> {
26
+ if (!form.name.trim()) {
27
+ return;
28
+ }
29
+ saving.value = true;
30
+ try {
31
+ await updateOrganization({ name: form.name.trim(), vatId: form.vatId.trim() });
32
+ editing.value = false;
33
+ toast.add({ title: t("organization.saved"), color: "success", icon: icon("success"), duration: 2000 });
34
+ }
35
+ catch {
36
+ toast.add({ title: t("organization.saveError"), color: "error", icon: icon("error"), duration: 3000 });
37
+ }
38
+ finally {
39
+ saving.value = false;
40
+ }
41
+ }
42
+ </script>
43
+
44
+ <template>
45
+ <div>
46
+ <UiFeedbackErrorBoundary
47
+ v-if="error"
48
+ :title="t('organization.errorTitle')"
49
+ :description="t('organization.errorDescription')"
50
+ :show-retry="false"
51
+ />
52
+
53
+ <div
54
+ v-else-if="status === 'pending'"
55
+ class="space-y-3"
56
+ >
57
+ <USkeleton class="h-9 w-full" />
58
+ <USkeleton class="h-9 w-2/3" />
59
+ </div>
60
+
61
+ <UiFeedbackEmptyState
62
+ v-else-if="!organization"
63
+ :icon="icon('user')"
64
+ :title="t('organization.empty.title')"
65
+ :description="t('organization.empty.description')"
66
+ />
67
+
68
+ <section
69
+ v-else
70
+ class="border border-(--ui-border) rounded-xl overflow-hidden"
71
+ >
72
+ <div class="flex items-center justify-between gap-3 px-4 sm:px-5 py-3 bg-elevated/60 border-b border-(--ui-border)">
73
+ <h2 class="text-sm font-semibold text-highlighted">
74
+ {{ t('organization.companySection') }}
75
+ </h2>
76
+ <UButton
77
+ color="neutral"
78
+ variant="outline"
79
+ size="sm"
80
+ :icon="icon('edit')"
81
+ :label="t('organization.edit')"
82
+ @click="openEdit"
83
+ />
84
+ </div>
85
+ <dl class="p-4 sm:p-5 grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4">
86
+ <div>
87
+ <dt class="text-xs text-muted">
88
+ {{ t('organization.fields.name') }}
89
+ </dt>
90
+ <dd class="text-highlighted font-medium">
91
+ {{ organization.name || '—' }}
92
+ </dd>
93
+ </div>
94
+ <div>
95
+ <dt class="text-xs text-muted">
96
+ {{ t('organization.fields.vatId') }}
97
+ </dt>
98
+ <dd class="text-highlighted tabular-nums">
99
+ {{ organization.vatId || '—' }}
100
+ </dd>
101
+ </div>
102
+ <div>
103
+ <dt class="text-xs text-muted">
104
+ {{ t('organization.fields.status') }}
105
+ </dt>
106
+ <dd>
107
+ <UBadge
108
+ :color="organization.status === 'active' ? 'success' : 'error'"
109
+ variant="subtle"
110
+ size="sm"
111
+ :label="t(`organization.status.${organization.status}`)"
112
+ />
113
+ </dd>
114
+ </div>
115
+ </dl>
116
+ </section>
117
+
118
+ <UModal
119
+ v-model:open="editing"
120
+ :title="t('organization.editTitle')"
121
+ >
122
+ <template #body>
123
+ <div class="space-y-4">
124
+ <UFormField :label="t('organization.fields.name')" required>
125
+ <UInput
126
+ v-model="form.name"
127
+ class="w-full"
128
+ :placeholder="t('organization.fields.name')"
129
+ />
130
+ </UFormField>
131
+ <UFormField :label="t('organization.fields.vatId')">
132
+ <UInput
133
+ v-model="form.vatId"
134
+ class="w-full"
135
+ placeholder="DE123456789"
136
+ />
137
+ </UFormField>
138
+ </div>
139
+ </template>
140
+ <template #footer>
141
+ <div class="flex items-center justify-end gap-2 w-full">
142
+ <UButton
143
+ color="neutral"
144
+ variant="ghost"
145
+ :label="t('organization.cancel')"
146
+ @click="editing = false"
147
+ />
148
+ <UButton
149
+ color="primary"
150
+ :loading="saving"
151
+ :disabled="!form.name.trim()"
152
+ :label="t('organization.save')"
153
+ @click="save"
154
+ />
155
+ </div>
156
+ </template>
157
+ </UModal>
158
+ </div>
159
+ </template>
@@ -0,0 +1,346 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The buyer's company team (contacts) — a data table of members with an
4
+ * Invite button opening the create modal, and a per-row edit action that
5
+ * changes the member's role. Backed by the team service
6
+ * (customers.contacts on the live API). Private buyers (no organization in
7
+ * the session) get an empty state.
8
+ */
9
+ import type { TableColumn } from "@nuxt/ui";
10
+
11
+ import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamRole, AccountTeamStatus } from "../../../interfaces/account/team";
12
+
13
+ const { icon } = useIcons();
14
+ const { t } = useI18n();
15
+ const toast = useToast();
16
+ const { members, status, error, inviteMember, updateMemberRole } = useAccountTeam();
17
+ const { tableUi } = useDataTable();
18
+
19
+ const ROLES: AccountTeamRole[] = ["buyer", "approver", "admin", "requester"];
20
+
21
+ const roleColors: Record<AccountTeamRole, "primary" | "info" | "warning" | "neutral"> = {
22
+ admin: "primary",
23
+ approver: "warning",
24
+ buyer: "info",
25
+ requester: "neutral",
26
+ };
27
+
28
+ const statusColors: Record<AccountTeamStatus, "success" | "warning" | "error"> = {
29
+ active: "success",
30
+ invited: "warning",
31
+ blocked: "error",
32
+ };
33
+
34
+ const roleItems = computed(() =>
35
+ ROLES.map(value => ({ value, label: t(`team.roles.${value}`) })),
36
+ );
37
+
38
+ /* ---- search ------------------------------------------------------------ */
39
+ const search = ref("");
40
+
41
+ const filtered = computed(() => {
42
+ const query = search.value.trim().toLowerCase();
43
+ if (!query) {
44
+ return members.value;
45
+ }
46
+ return members.value.filter(member =>
47
+ [`${member.firstName} ${member.lastName}`, member.email, t(`team.roles.${member.role}`)]
48
+ .some(value => value.toLowerCase().includes(query)),
49
+ );
50
+ });
51
+
52
+ /* ---- columns + sorting ------------------------------------------------- */
53
+ const sorting = ref([{ id: "name", desc: false }]);
54
+
55
+ const columns = computed<TableColumn<AccountTeamMember>[]>(() => [
56
+ {
57
+ id: "name",
58
+ accessorFn: row => `${row.firstName} ${row.lastName}`.trim(),
59
+ header: t("team.columns.name"),
60
+ },
61
+ { accessorKey: "email", header: t("team.columns.email") },
62
+ { accessorKey: "role", header: t("team.columns.role"), enableSorting: false },
63
+ { accessorKey: "status", header: t("team.columns.status"), enableSorting: false },
64
+ { id: "actions", header: "", enableSorting: false },
65
+ ]);
66
+
67
+ /* ---- invite modal ------------------------------------------------------ */
68
+ const inviting = ref(false);
69
+ const savingInvite = ref(false);
70
+ const inviteForm = reactive<AccountTeamMemberFormState>({ email: "", firstName: "", lastName: "", role: "buyer" });
71
+
72
+ function openInvite(): void {
73
+ inviteForm.email = "";
74
+ inviteForm.firstName = "";
75
+ inviteForm.lastName = "";
76
+ inviteForm.role = "buyer";
77
+ inviting.value = true;
78
+ }
79
+
80
+ async function saveInvite(): Promise<void> {
81
+ if (!inviteForm.email.trim()) {
82
+ return;
83
+ }
84
+ savingInvite.value = true;
85
+ try {
86
+ await inviteMember({
87
+ email: inviteForm.email.trim(),
88
+ firstName: inviteForm.firstName.trim(),
89
+ lastName: inviteForm.lastName.trim(),
90
+ role: inviteForm.role,
91
+ });
92
+ inviting.value = false;
93
+ toast.add({ title: t("team.saved"), color: "success", icon: icon("success"), duration: 2000 });
94
+ }
95
+ catch {
96
+ toast.add({ title: t("team.saveError"), color: "error", icon: icon("error"), duration: 3000 });
97
+ }
98
+ finally {
99
+ savingInvite.value = false;
100
+ }
101
+ }
102
+
103
+ /* ---- edit-role modal --------------------------------------------------- */
104
+ const editing = ref(false);
105
+ const savingEdit = ref(false);
106
+ const editTarget = ref<AccountTeamMember | null>(null);
107
+ const editRole = ref<AccountTeamRole>("buyer");
108
+
109
+ function openEdit(member: AccountTeamMember): void {
110
+ editTarget.value = member;
111
+ editRole.value = member.role;
112
+ editing.value = true;
113
+ }
114
+
115
+ async function saveEdit(): Promise<void> {
116
+ if (!editTarget.value) {
117
+ return;
118
+ }
119
+ savingEdit.value = true;
120
+ try {
121
+ await updateMemberRole(editTarget.value.id, editRole.value);
122
+ editing.value = false;
123
+ toast.add({ title: t("team.saved"), color: "success", icon: icon("success"), duration: 2000 });
124
+ }
125
+ catch {
126
+ toast.add({ title: t("team.saveError"), color: "error", icon: icon("error"), duration: 3000 });
127
+ }
128
+ finally {
129
+ savingEdit.value = false;
130
+ }
131
+ }
132
+ </script>
133
+
134
+ <template>
135
+ <div>
136
+ <UiFeedbackErrorBoundary
137
+ v-if="error"
138
+ :title="t('team.errorTitle')"
139
+ :description="t('team.errorDescription')"
140
+ :show-retry="false"
141
+ />
142
+
143
+ <template v-else>
144
+ <UiTableToolbar
145
+ v-model:search="search"
146
+ :search-placeholder="t('team.searchPlaceholder')"
147
+ >
148
+ <template #actions>
149
+ <UButton
150
+ color="primary"
151
+ tabindex="0"
152
+ :icon="icon('plus')"
153
+ :label="t('team.invite')"
154
+ @click="openInvite"
155
+ />
156
+ </template>
157
+ </UiTableToolbar>
158
+
159
+ <UTable
160
+ v-model:sorting="sorting"
161
+ :data="filtered"
162
+ :columns="columns"
163
+ :loading="status === 'pending'"
164
+ :ui="tableUi"
165
+ >
166
+ <template #name-header="{ column }">
167
+ <UiTableSortButton
168
+ :column="column"
169
+ :label="t('team.columns.name')"
170
+ />
171
+ </template>
172
+ <template #email-header="{ column }">
173
+ <UiTableSortButton
174
+ :column="column"
175
+ :label="t('team.columns.email')"
176
+ />
177
+ </template>
178
+
179
+ <template #name-cell="{ row }">
180
+ <span class="font-semibold text-highlighted">
181
+ {{ `${row.original.firstName} ${row.original.lastName}`.trim() || '—' }}
182
+ </span>
183
+ <UBadge
184
+ v-if="row.original.isPrimary"
185
+ color="primary"
186
+ variant="subtle"
187
+ size="sm"
188
+ class="ml-1.5"
189
+ :label="t('team.primary')"
190
+ />
191
+ </template>
192
+ <template #role-cell="{ row }">
193
+ <UBadge
194
+ :color="roleColors[row.original.role]"
195
+ variant="subtle"
196
+ size="sm"
197
+ :label="t(`team.roles.${row.original.role}`)"
198
+ />
199
+ </template>
200
+ <template #status-cell="{ row }">
201
+ <UBadge
202
+ :color="statusColors[row.original.status]"
203
+ variant="outline"
204
+ size="sm"
205
+ :label="t(`team.statuses.${row.original.status}`)"
206
+ />
207
+ </template>
208
+ <template #actions-cell="{ row }">
209
+ <div class="flex items-center justify-end gap-1">
210
+ <UTooltip :text="t('team.editTitle')">
211
+ <UButton
212
+ :icon="icon('edit')"
213
+ color="neutral"
214
+ variant="ghost"
215
+ size="sm"
216
+ tabindex="0"
217
+ :aria-label="t('team.editTitle')"
218
+ @click="openEdit(row.original)"
219
+ />
220
+ </UTooltip>
221
+ </div>
222
+ </template>
223
+
224
+ <template #loading>
225
+ <div class="space-y-3 py-2">
226
+ <USkeleton
227
+ v-for="index in 5"
228
+ :key="index"
229
+ class="h-9 w-full"
230
+ />
231
+ </div>
232
+ </template>
233
+ <template #empty>
234
+ <UiFeedbackEmptyState
235
+ v-if="search"
236
+ :icon="icon('no-results')"
237
+ :title="t('table.noResults.title')"
238
+ :description="t('table.noResults.description')"
239
+ />
240
+ <UiFeedbackEmptyState
241
+ v-else
242
+ :icon="icon('users')"
243
+ :title="t('team.empty.title')"
244
+ :description="t('team.empty.description')"
245
+ />
246
+ </template>
247
+ </UTable>
248
+ </template>
249
+
250
+ <UModal
251
+ v-model:open="inviting"
252
+ :title="t('team.inviteTitle')"
253
+ >
254
+ <template #body>
255
+ <div class="space-y-4">
256
+ <UFormField
257
+ :label="t('team.columns.email')"
258
+ required
259
+ >
260
+ <UInput
261
+ v-model="inviteForm.email"
262
+ type="email"
263
+ class="w-full"
264
+ placeholder="name@firma.de"
265
+ />
266
+ </UFormField>
267
+ <div class="grid grid-cols-2 gap-4">
268
+ <UFormField :label="t('team.firstName')">
269
+ <UInput
270
+ v-model="inviteForm.firstName"
271
+ class="w-full"
272
+ />
273
+ </UFormField>
274
+ <UFormField :label="t('team.lastName')">
275
+ <UInput
276
+ v-model="inviteForm.lastName"
277
+ class="w-full"
278
+ />
279
+ </UFormField>
280
+ </div>
281
+ <UFormField :label="t('team.columns.role')">
282
+ <USelect
283
+ v-model="inviteForm.role"
284
+ :items="roleItems"
285
+ class="w-full"
286
+ />
287
+ </UFormField>
288
+ </div>
289
+ </template>
290
+ <template #footer>
291
+ <div class="flex items-center justify-end gap-2 w-full">
292
+ <UButton
293
+ color="neutral"
294
+ variant="ghost"
295
+ tabindex="0"
296
+ :label="t('team.cancel')"
297
+ @click="inviting = false"
298
+ />
299
+ <UButton
300
+ color="primary"
301
+ tabindex="0"
302
+ :loading="savingInvite"
303
+ :disabled="!inviteForm.email.trim()"
304
+ :label="t('team.invite')"
305
+ @click="saveInvite"
306
+ />
307
+ </div>
308
+ </template>
309
+ </UModal>
310
+
311
+ <UModal
312
+ v-model:open="editing"
313
+ :title="t('team.editTitle')"
314
+ >
315
+ <template #body>
316
+ <div class="space-y-4">
317
+ <UFormField :label="t('team.columns.role')">
318
+ <USelect
319
+ v-model="editRole"
320
+ :items="roleItems"
321
+ class="w-full"
322
+ />
323
+ </UFormField>
324
+ </div>
325
+ </template>
326
+ <template #footer>
327
+ <div class="flex items-center justify-end gap-2 w-full">
328
+ <UButton
329
+ color="neutral"
330
+ variant="ghost"
331
+ tabindex="0"
332
+ :label="t('team.cancel')"
333
+ @click="editing = false"
334
+ />
335
+ <UButton
336
+ color="primary"
337
+ tabindex="0"
338
+ :loading="savingEdit"
339
+ :label="t('team.save')"
340
+ @click="saveEdit"
341
+ />
342
+ </div>
343
+ </template>
344
+ </UModal>
345
+ </div>
346
+ </template>
@@ -0,0 +1,25 @@
1
+ import { accountApi } from "../api/account";
2
+ import type { AccountOrganization, AccountOrganizationFormState, AccountOrganizationResponse } from "../interfaces/account/organization";
3
+
4
+ export const useAccountOrganization = () => {
5
+ const { data, status, error, refresh } = useFetch<AccountOrganizationResponse>(
6
+ accountApi.organization(),
7
+ {
8
+ key: "account-organization",
9
+ default: () => ({ organization: null }),
10
+ },
11
+ );
12
+
13
+ const organization = computed(() => data.value.organization);
14
+
15
+ async function updateOrganization(formState: AccountOrganizationFormState): Promise<AccountOrganization> {
16
+ const updated = await $fetch<AccountOrganization>(accountApi.organization(), {
17
+ method: "PUT",
18
+ body: formState,
19
+ });
20
+ data.value = { organization: updated };
21
+ return updated;
22
+ }
23
+
24
+ return { organization, status, error, refresh, updateOrganization };
25
+ };
@@ -0,0 +1,34 @@
1
+ import { accountApi } from "../api/account";
2
+ import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamResponse, AccountTeamRole } from "../interfaces/account/team";
3
+
4
+ export const useAccountTeam = () => {
5
+ const { data, status, error, refresh } = useFetch<AccountTeamResponse>(
6
+ accountApi.team(),
7
+ {
8
+ key: "account-team",
9
+ default: () => ({ members: [] }),
10
+ },
11
+ );
12
+
13
+ const members = computed(() => data.value.members);
14
+
15
+ async function inviteMember(formState: AccountTeamMemberFormState): Promise<AccountTeamMember> {
16
+ const created = await $fetch<AccountTeamMember>(accountApi.team(), {
17
+ method: "POST",
18
+ body: formState,
19
+ });
20
+ data.value = { members: [...data.value.members, created] };
21
+ return created;
22
+ }
23
+
24
+ async function updateMemberRole(id: string, role: AccountTeamRole): Promise<AccountTeamMember> {
25
+ const updated = await $fetch<AccountTeamMember>(accountApi.teamMemberUpdate(id), {
26
+ method: "PUT",
27
+ body: { role },
28
+ });
29
+ data.value = { members: data.value.members.map(m => (m.id === id ? updated : m)) };
30
+ return updated;
31
+ }
32
+
33
+ return { members, status, error, refresh, inviteMember, updateMemberRole };
34
+ };
@@ -170,9 +170,10 @@ export const accountNavigation: AccountNavGroup[] = [
170
170
  links: [
171
171
  { labelKey: "account.nav.catalogs", icon: "book-2", to: "/account/catalogs" },
172
172
  { labelKey: "account.nav.accountSettings", icon: "user", to: "/account/profile", implemented: true },
173
+ { labelKey: "account.nav.organization", icon: "users", to: "/account/organization", implemented: true },
173
174
  { labelKey: "account.nav.orderSettings", icon: "settings", to: "/account/preferences", implemented: true },
174
175
  { labelKey: "account.nav.addresses", icon: "location", to: "/account/addresses", implemented: true },
175
- { labelKey: "account.nav.users", icon: "users", to: "/account/users" },
176
+ { labelKey: "account.nav.users", icon: "users", to: "/account/team", implemented: true },
176
177
  { labelKey: "account.nav.roles", icon: "key", to: "/account/roles" },
177
178
  { labelKey: "account.nav.customArticleNumbers", icon: "hash", to: "/account/custom-article-numbers" },
178
179
  ],
@@ -0,0 +1,19 @@
1
+ export type AccountOrganizationStatus = "active" | "blocked";
2
+
3
+ /** The buyer's own company, as shown on the account organization page. */
4
+ export interface AccountOrganization {
5
+ readonly id: string;
6
+ readonly name: string;
7
+ readonly vatId: string;
8
+ readonly status: AccountOrganizationStatus;
9
+ }
10
+
11
+ /** Editable company fields (the customers app's defined columns). */
12
+ export interface AccountOrganizationFormState {
13
+ name: string;
14
+ vatId: string;
15
+ }
16
+
17
+ export interface AccountOrganizationResponse {
18
+ readonly organization: AccountOrganization | null;
19
+ }
@@ -0,0 +1,25 @@
1
+ export type AccountTeamRole = "buyer" | "approver" | "admin" | "requester";
2
+ export type AccountTeamStatus = "invited" | "active" | "blocked";
3
+
4
+ /** A member (contact) of the buyer's company, as shown on the team page. */
5
+ export interface AccountTeamMember {
6
+ readonly id: string;
7
+ readonly firstName: string;
8
+ readonly lastName: string;
9
+ readonly email: string;
10
+ readonly role: AccountTeamRole;
11
+ readonly status: AccountTeamStatus;
12
+ readonly isPrimary: boolean;
13
+ }
14
+
15
+ /** Editable member fields (the invite form). */
16
+ export interface AccountTeamMemberFormState {
17
+ email: string;
18
+ firstName: string;
19
+ lastName: string;
20
+ role: AccountTeamRole;
21
+ }
22
+
23
+ export interface AccountTeamResponse {
24
+ readonly members: AccountTeamMember[];
25
+ }
@@ -186,6 +186,7 @@
186
186
  "iotDevices": "IoT-Geräte",
187
187
  "catalogs": "Kataloge",
188
188
  "accountSettings": "Stammdaten",
189
+ "organization": "Firmendaten",
189
190
  "addresses": "Adressen",
190
191
  "users": "Benutzer",
191
192
  "roles": "Rollen",
@@ -458,5 +459,69 @@
458
459
  "alwaysActive": "Immer in den aktiven Warenkorb legen",
459
460
  "alwaysActiveHint": "Beim Hinzufügen von Artikeln wird nicht mehr gefragt, in welchen Warenkorb die Position gelegt werden soll.",
460
461
  "saved": "Einstellung gespeichert"
462
+ },
463
+ "organization": {
464
+ "title": "Firmendaten",
465
+ "description": "Daten Ihres Unternehmens ansehen und bearbeiten.",
466
+ "companySection": "Unternehmen",
467
+ "edit": "Bearbeiten",
468
+ "editTitle": "Firmendaten bearbeiten",
469
+ "save": "Speichern",
470
+ "cancel": "Abbrechen",
471
+ "saved": "Firmendaten gespeichert",
472
+ "saveError": "Speichern fehlgeschlagen",
473
+ "errorTitle": "Firmendaten nicht verfügbar",
474
+ "errorDescription": "Die Firmendaten konnten nicht geladen werden.",
475
+ "fields": {
476
+ "name": "Firmenname",
477
+ "vatId": "USt-IdNr.",
478
+ "status": "Status"
479
+ },
480
+ "status": {
481
+ "active": "Aktiv",
482
+ "blocked": "Gesperrt"
483
+ },
484
+ "empty": {
485
+ "title": "Kein Unternehmen",
486
+ "description": "Ihr Konto ist keinem Unternehmen zugeordnet."
487
+ }
488
+ },
489
+ "team": {
490
+ "title": "Benutzer",
491
+ "description": "Verwalten Sie die Benutzer Ihres Unternehmens und deren Rollen.",
492
+ "searchPlaceholder": "Nach Name, E-Mail oder Rolle suchen …",
493
+ "invite": "Benutzer einladen",
494
+ "inviteTitle": "Benutzer einladen",
495
+ "editTitle": "Rolle ändern",
496
+ "primary": "Hauptkontakt",
497
+ "firstName": "Vorname",
498
+ "lastName": "Nachname",
499
+ "save": "Speichern",
500
+ "cancel": "Abbrechen",
501
+ "saved": "Gespeichert",
502
+ "saveError": "Speichern fehlgeschlagen",
503
+ "errorTitle": "Benutzer nicht verfügbar",
504
+ "errorDescription": "Die Benutzer konnten nicht geladen werden.",
505
+ "columns": {
506
+ "name": "Name",
507
+ "email": "E-Mail",
508
+ "role": "Rolle",
509
+ "status": "Status"
510
+ },
511
+ "roles": {
512
+ "buyer": "Einkäufer",
513
+ "approver": "Genehmiger",
514
+ "admin": "Administrator",
515
+ "requester": "Anforderer"
516
+ },
517
+ "statuses": {
518
+ "invited": "Eingeladen",
519
+ "active": "Aktiv",
520
+ "blocked": "Gesperrt"
521
+ },
522
+ "empty": {
523
+ "title": "Keine Benutzer",
524
+ "description": "Laden Sie über „Benutzer einladen“ den ersten Benutzer ein."
525
+ }
461
526
  }
462
527
  }
@@ -186,6 +186,7 @@
186
186
  "iotDevices": "IoT devices",
187
187
  "catalogs": "Catalogs",
188
188
  "accountSettings": "Master data",
189
+ "organization": "Company",
189
190
  "addresses": "Addresses",
190
191
  "users": "Users",
191
192
  "roles": "Roles",
@@ -458,5 +459,69 @@
458
459
  "alwaysActive": "Always add to the active cart",
459
460
  "alwaysActiveHint": "Adding articles no longer asks which cart the item should go to.",
460
461
  "saved": "Setting saved"
462
+ },
463
+ "organization": {
464
+ "title": "Company",
465
+ "description": "View and edit your company details.",
466
+ "companySection": "Company",
467
+ "edit": "Edit",
468
+ "editTitle": "Edit company details",
469
+ "save": "Save",
470
+ "cancel": "Cancel",
471
+ "saved": "Company details saved",
472
+ "saveError": "Save failed",
473
+ "errorTitle": "Company details unavailable",
474
+ "errorDescription": "The company details could not be loaded.",
475
+ "fields": {
476
+ "name": "Company name",
477
+ "vatId": "VAT ID",
478
+ "status": "Status"
479
+ },
480
+ "status": {
481
+ "active": "Active",
482
+ "blocked": "Blocked"
483
+ },
484
+ "empty": {
485
+ "title": "No company",
486
+ "description": "Your account is not linked to a company."
487
+ }
488
+ },
489
+ "team": {
490
+ "title": "Users",
491
+ "description": "Manage your company's users and their roles.",
492
+ "searchPlaceholder": "Search by name, email or role…",
493
+ "invite": "Invite user",
494
+ "inviteTitle": "Invite user",
495
+ "editTitle": "Change role",
496
+ "primary": "Primary contact",
497
+ "firstName": "First name",
498
+ "lastName": "Last name",
499
+ "save": "Save",
500
+ "cancel": "Cancel",
501
+ "saved": "Saved",
502
+ "saveError": "Save failed",
503
+ "errorTitle": "Users unavailable",
504
+ "errorDescription": "The users could not be loaded.",
505
+ "columns": {
506
+ "name": "Name",
507
+ "email": "Email",
508
+ "role": "Role",
509
+ "status": "Status"
510
+ },
511
+ "roles": {
512
+ "buyer": "Buyer",
513
+ "approver": "Approver",
514
+ "admin": "Admin",
515
+ "requester": "Requester"
516
+ },
517
+ "statuses": {
518
+ "invited": "Invited",
519
+ "active": "Active",
520
+ "blocked": "Blocked"
521
+ },
522
+ "empty": {
523
+ "title": "No users",
524
+ "description": "Invite the first user via “Invite user”."
525
+ }
461
526
  }
462
527
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Cover — revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -0,0 +1,5 @@
1
+ import type { AccountOrganizationResponse } from "../../../app/interfaces/account/organization";
2
+
3
+ export default defineEventHandler(async (event): Promise<AccountOrganizationResponse> => {
4
+ return { organization: await getOrganizationService(event).get(event) };
5
+ });
@@ -0,0 +1,9 @@
1
+ import type { AccountOrganization, AccountOrganizationFormState } from "../../../app/interfaces/account/organization";
2
+
3
+ export default defineEventHandler(async (event): Promise<AccountOrganization> => {
4
+ const body = await readBody<AccountOrganizationFormState>(event);
5
+ return getOrganizationService(event).update(event, {
6
+ name: String(body?.name ?? "").trim(),
7
+ vatId: String(body?.vatId ?? "").trim(),
8
+ });
9
+ });
@@ -0,0 +1,21 @@
1
+ import type { AccountTeamMember, AccountTeamRole } from "../../../../app/interfaces/account/team";
2
+
3
+ interface TeamUpdateBody {
4
+ readonly role?: unknown;
5
+ }
6
+
7
+ const ROLES: AccountTeamRole[] = ["buyer", "approver", "admin", "requester"];
8
+
9
+ export default defineEventHandler(async (event): Promise<AccountTeamMember> => {
10
+ const id = getRouterParam(event, "id");
11
+ if (!id) {
12
+ throw createError({ statusCode: 400, statusMessage: "Missing member id" });
13
+ }
14
+
15
+ const body = await readBody<TeamUpdateBody>(event);
16
+ if (!ROLES.includes(body.role as AccountTeamRole)) {
17
+ throw createError({ statusCode: 422, statusMessage: "Invalid role" });
18
+ }
19
+
20
+ return getTeamService(event).update(event, id, { role: body.role as AccountTeamRole });
21
+ });
@@ -0,0 +1,5 @@
1
+ import type { AccountTeamResponse } from "../../../app/interfaces/account/team";
2
+
3
+ export default defineEventHandler(async (event): Promise<AccountTeamResponse> => {
4
+ return { members: await getTeamService(event).list(event) };
5
+ });
@@ -0,0 +1,21 @@
1
+ import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamRole } from "../../../app/interfaces/account/team";
2
+
3
+ const ROLES: AccountTeamRole[] = ["buyer", "approver", "admin", "requester"];
4
+
5
+ function toRole(value: unknown): AccountTeamRole {
6
+ return ROLES.includes(value as AccountTeamRole) ? value as AccountTeamRole : "buyer";
7
+ }
8
+
9
+ export default defineEventHandler(async (event): Promise<AccountTeamMember> => {
10
+ const body = await readBody<Partial<AccountTeamMemberFormState>>(event);
11
+ const email = String(body?.email ?? "").trim();
12
+ if (!email) {
13
+ throw createError({ statusCode: 422, statusMessage: "email is required" });
14
+ }
15
+ return getTeamService(event).invite(event, {
16
+ email,
17
+ firstName: String(body?.firstName ?? "").trim(),
18
+ lastName: String(body?.lastName ?? "").trim(),
19
+ role: toRole(body?.role),
20
+ });
21
+ });
@@ -0,0 +1,16 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { AccountOrganization, AccountOrganizationFormState } from "../../app/interfaces/account/organization";
4
+
5
+ /**
6
+ * Service contract for the buyer's own company (organization) — the account
7
+ * organization page reads and edits it.
8
+ * - "mock" — bundled demo company (account/organization.json)
9
+ * - "api" — the contact's organization in the customers app via the public API
10
+ * Register the active implementation via app.config → organizationService.
11
+ */
12
+ export interface IOrganizationService {
13
+ /** The signed-in contact's organization, or null when the session carries none. */
14
+ get(event: H3Event): Promise<AccountOrganization | null>;
15
+ update(event: H3Event, input: AccountOrganizationFormState): Promise<AccountOrganization>;
16
+ }
@@ -0,0 +1,17 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamRole } from "../../app/interfaces/account/team";
4
+
5
+ /**
6
+ * Service contract for the buyer's company team (contacts) — the account
7
+ * team page lists members, invites new ones and changes their role.
8
+ * - "mock" — bundled demo members (kept in-memory for the process lifetime)
9
+ * - "api" — the organization's contacts in the customers app via the public API
10
+ * Register the active implementation via app.config → contactsService.
11
+ */
12
+ export interface ITeamService {
13
+ /** The signed-in contact's organization members. */
14
+ list(event: H3Event): Promise<AccountTeamMember[]>;
15
+ invite(event: H3Event, input: AccountTeamMemberFormState): Promise<AccountTeamMember>;
16
+ update(event: H3Event, id: string, patch: { role: AccountTeamRole }): Promise<AccountTeamMember>;
17
+ }
@@ -0,0 +1,68 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { AccountOrganization, AccountOrganizationFormState } from "../../app/interfaces/account/organization";
4
+
5
+ import type { IOrganizationService } from "../interfaces/organization";
6
+
7
+ /** Raw organization row from the customers app (snake_case API shape). */
8
+ interface ApiOrgRow {
9
+ id: string;
10
+ name: string | null;
11
+ vat_id: string | null;
12
+ status: string | null;
13
+ }
14
+
15
+ function toAccountOrganization(row: ApiOrgRow): AccountOrganization {
16
+ return {
17
+ id: row.id,
18
+ name: row.name ?? "",
19
+ vatId: row.vat_id ?? "",
20
+ status: row.status === "blocked" ? "blocked" : "active",
21
+ };
22
+ }
23
+
24
+ /**
25
+ * Live company data: the signed-in contact's organization in the customers
26
+ * app. The organization id comes from the session cookie (auth/me link);
27
+ * contacts without an organization (private buyers) have none.
28
+ */
29
+ export class ApiOrganizationService implements IOrganizationService {
30
+ async get(event: H3Event): Promise<AccountOrganization | null> {
31
+ const { organization_id } = sessionOrderRefs(event);
32
+ if (!organization_id) {
33
+ return null;
34
+ }
35
+ try {
36
+ const row = await useRevenexxSdk().customers.customersOrganizationsGet({
37
+ id: organization_id,
38
+ }) as unknown as ApiOrgRow;
39
+ return toAccountOrganization(row);
40
+ }
41
+ catch (err) {
42
+ getLogService().error("API request failed: organization/get", apiErrorContext(err));
43
+ throw createError({ statusCode: 502, statusMessage: "Organization service unavailable" });
44
+ }
45
+ }
46
+
47
+ async update(event: H3Event, input: AccountOrganizationFormState): Promise<AccountOrganization> {
48
+ const { organization_id } = sessionOrderRefs(event);
49
+ if (!organization_id) {
50
+ throw createError({ statusCode: 401, statusMessage: "No organization in session" });
51
+ }
52
+ try {
53
+ const row = await useRevenexxSdk().customers.customersOrganizationsUpdate({
54
+ id: organization_id,
55
+ name: input.name,
56
+ vatId: input.vatId || undefined,
57
+ }) as unknown as ApiOrgRow;
58
+ return toAccountOrganization(row);
59
+ }
60
+ catch (err) {
61
+ if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
62
+ throw createError({ statusCode: 422, message: err.message });
63
+ }
64
+ getLogService().error("API request failed: organization/update", apiErrorContext(err));
65
+ throw createError({ statusCode: 502, statusMessage: "Organization service unavailable" });
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,106 @@
1
+ import type { ContactRole } from "@revenexx/sdk";
2
+ import type { H3Event } from "h3";
3
+
4
+ import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamRole, AccountTeamStatus } from "../../app/interfaces/account/team";
5
+
6
+ import type { ITeamService } from "../interfaces/team";
7
+
8
+ /** Raw contact row from the customers app (snake_case API shape). */
9
+ interface ApiContactRow {
10
+ id?: string;
11
+ organization_id?: string | null;
12
+ email?: string;
13
+ first_name?: string | null;
14
+ last_name?: string | null;
15
+ role?: string;
16
+ status?: string;
17
+ is_primary?: boolean;
18
+ }
19
+
20
+ const ROLES: AccountTeamRole[] = ["buyer", "approver", "admin", "requester"];
21
+ const STATUSES: AccountTeamStatus[] = ["invited", "active", "blocked"];
22
+
23
+ function toRole(value: string | undefined): AccountTeamRole {
24
+ return ROLES.includes(value as AccountTeamRole) ? value as AccountTeamRole : "buyer";
25
+ }
26
+
27
+ function toStatus(value: string | undefined): AccountTeamStatus {
28
+ return STATUSES.includes(value as AccountTeamStatus) ? value as AccountTeamStatus : "active";
29
+ }
30
+
31
+ function toAccountTeamMember(row: ApiContactRow): AccountTeamMember {
32
+ return {
33
+ id: row.id ?? "",
34
+ firstName: row.first_name ?? "",
35
+ lastName: row.last_name ?? "",
36
+ email: row.email ?? "",
37
+ role: toRole(row.role),
38
+ status: toStatus(row.status),
39
+ isPrimary: row.is_primary === true,
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Live team data: the contacts of the signed-in contact's organization in the
45
+ * customers app. The organization id comes from the session cookie (auth/me
46
+ * link); contacts without an organization (private buyers) get an empty list.
47
+ */
48
+ export class ApiTeamService implements ITeamService {
49
+ async list(event: H3Event): Promise<AccountTeamMember[]> {
50
+ const { organization_id } = sessionOrderRefs(event);
51
+ if (!organization_id) {
52
+ return [];
53
+ }
54
+ try {
55
+ const { items } = await useRevenexxSdk().customers.customersContactsList() as unknown as { items: ApiContactRow[] };
56
+ return (items ?? [])
57
+ .filter(row => row.organization_id === organization_id)
58
+ .map(toAccountTeamMember);
59
+ }
60
+ catch (err) {
61
+ getLogService().error("API request failed: team/list", apiErrorContext(err));
62
+ throw createError({ statusCode: 502, statusMessage: "Team service unavailable" });
63
+ }
64
+ }
65
+
66
+ async invite(event: H3Event, input: AccountTeamMemberFormState): Promise<AccountTeamMember> {
67
+ const { organization_id } = sessionOrderRefs(event);
68
+ if (!organization_id) {
69
+ throw createError({ statusCode: 401, statusMessage: "No organization in session" });
70
+ }
71
+ try {
72
+ const row = await useRevenexxSdk().customers.customersContactsCreate({
73
+ email: input.email,
74
+ firstName: input.firstName || undefined,
75
+ lastName: input.lastName || undefined,
76
+ role: input.role as ContactRole,
77
+ organizationId: organization_id,
78
+ }) as unknown as ApiContactRow;
79
+ return toAccountTeamMember(row);
80
+ }
81
+ catch (err) {
82
+ if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
83
+ throw createError({ statusCode: 422, message: err.message });
84
+ }
85
+ getLogService().error("API request failed: team/invite", apiErrorContext(err));
86
+ throw createError({ statusCode: 502, statusMessage: "Team service unavailable" });
87
+ }
88
+ }
89
+
90
+ async update(_event: H3Event, id: string, patch: { role: AccountTeamRole }): Promise<AccountTeamMember> {
91
+ try {
92
+ const row = await useRevenexxSdk().customers.customersContactsUpdate({
93
+ id,
94
+ role: patch.role as ContactRole,
95
+ }) as unknown as ApiContactRow;
96
+ return toAccountTeamMember(row);
97
+ }
98
+ catch (err) {
99
+ if (err instanceof RevenexxException && (err.code === 400 || err.code === 422)) {
100
+ throw createError({ statusCode: 422, message: err.message });
101
+ }
102
+ getLogService().error("API request failed: team/update", apiErrorContext(err));
103
+ throw createError({ statusCode: 502, statusMessage: "Team service unavailable" });
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,29 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { AccountOrganization, AccountOrganizationFormState } from "../../app/interfaces/account/organization";
4
+
5
+ import type { IOrganizationService } from "../interfaces/organization";
6
+
7
+ /**
8
+ * Demo company: seeded from the bundled organization config, with edits kept
9
+ * in-memory for the process lifetime so the demo "save" round-trips visibly
10
+ * (the registry holds this as a singleton).
11
+ */
12
+ export class MockOrganizationService implements IOrganizationService {
13
+ private override: Partial<AccountOrganizationFormState> = {};
14
+
15
+ async get(_event: H3Event): Promise<AccountOrganization> {
16
+ const cfg = await readCoverConfigJson<{ name?: string }>("account/organization.json");
17
+ return {
18
+ id: "demo-org",
19
+ name: this.override.name ?? cfg.name ?? "Demo GmbH",
20
+ vatId: this.override.vatId ?? "DE123456789",
21
+ status: "active",
22
+ };
23
+ }
24
+
25
+ async update(event: H3Event, input: AccountOrganizationFormState): Promise<AccountOrganization> {
26
+ this.override = { name: input.name, vatId: input.vatId };
27
+ return this.get(event);
28
+ }
29
+ }
@@ -0,0 +1,48 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { AccountTeamMember, AccountTeamMemberFormState, AccountTeamRole } from "../../app/interfaces/account/team";
4
+
5
+ import type { ITeamService } from "../interfaces/team";
6
+
7
+ /**
8
+ * Demo team: a small set of seeded members kept in-memory for the process
9
+ * lifetime so the demo "invite" / "change role" round-trip visibly (the
10
+ * registry holds this as a singleton).
11
+ */
12
+ export class MockTeamService implements ITeamService {
13
+ private members: AccountTeamMember[] = [
14
+ { id: "demo-1", firstName: "Anna", lastName: "Berger", email: "anna.berger@demo-gmbh.de", role: "admin", status: "active", isPrimary: true },
15
+ { id: "demo-2", firstName: "Tobias", lastName: "Klein", email: "tobias.klein@demo-gmbh.de", role: "approver", status: "active", isPrimary: false },
16
+ { id: "demo-3", firstName: "Sara", lastName: "Vogel", email: "sara.vogel@demo-gmbh.de", role: "buyer", status: "invited", isPrimary: false },
17
+ ];
18
+
19
+ private nextId = 4;
20
+
21
+ async list(_event: H3Event): Promise<AccountTeamMember[]> {
22
+ return this.members;
23
+ }
24
+
25
+ async invite(_event: H3Event, input: AccountTeamMemberFormState): Promise<AccountTeamMember> {
26
+ const member: AccountTeamMember = {
27
+ id: `demo-${this.nextId++}`,
28
+ firstName: input.firstName,
29
+ lastName: input.lastName,
30
+ email: input.email,
31
+ role: input.role,
32
+ status: "invited",
33
+ isPrimary: false,
34
+ };
35
+ this.members = [...this.members, member];
36
+ return member;
37
+ }
38
+
39
+ async update(_event: H3Event, id: string, patch: { role: AccountTeamRole }): Promise<AccountTeamMember> {
40
+ const existing = this.members.find(m => m.id === id);
41
+ if (!existing) {
42
+ throw createError({ statusCode: 404, statusMessage: "Member not found" });
43
+ }
44
+ const updated: AccountTeamMember = { ...existing, role: patch.role };
45
+ this.members = this.members.map(m => (m.id === id ? updated : m));
46
+ return updated;
47
+ }
48
+ }
@@ -0,0 +1,25 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { IOrganizationService } from "../interfaces/organization";
4
+ import { ApiOrganizationService } from "../services/ApiOrganizationService";
5
+ import { MockOrganizationService } from "../services/MockOrganizationService";
6
+
7
+ /**
8
+ * Registry of organization (company) service implementations. The active one
9
+ * is selected by the `organizationService` key in app.config.ts:
10
+ * - "mock" — bundled demo company (account/organization.json)
11
+ * - "api" — the contact's organization in the customers app (public revenexx API)
12
+ */
13
+ const serviceRegistry: Record<string, IOrganizationService> = {
14
+ mock: new MockOrganizationService(),
15
+ api: new ApiOrganizationService(),
16
+ };
17
+
18
+ export function getOrganizationService(event?: H3Event): IOrganizationService {
19
+ const key = resolveServiceKey(event, {
20
+ domain: "organizationService",
21
+ mockKey: "mock",
22
+ liveKey: "api",
23
+ });
24
+ return serviceRegistry[key] ?? serviceRegistry["mock"]!;
25
+ }
@@ -0,0 +1,25 @@
1
+ import type { H3Event } from "h3";
2
+
3
+ import type { ITeamService } from "../interfaces/team";
4
+ import { ApiTeamService } from "../services/ApiTeamService";
5
+ import { MockTeamService } from "../services/MockTeamService";
6
+
7
+ /**
8
+ * Registry of team (company contacts) service implementations. The active one
9
+ * is selected by the `contactsService` key in app.config.ts:
10
+ * - "mock" — bundled demo members (kept in-memory for the process lifetime)
11
+ * - "api" — the organization's contacts in the customers app (public revenexx API)
12
+ */
13
+ const serviceRegistry: Record<string, ITeamService> = {
14
+ mock: new MockTeamService(),
15
+ api: new ApiTeamService(),
16
+ };
17
+
18
+ export function getTeamService(event?: H3Event): ITeamService {
19
+ const key = resolveServiceKey(event, {
20
+ domain: "contactsService",
21
+ mockKey: "mock",
22
+ liveKey: "api",
23
+ });
24
+ return serviceRegistry[key] ?? serviceRegistry["mock"]!;
25
+ }