@revenexx/cover 0.2.5 → 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.
- package/app/api/account.ts +3 -0
- package/app/app.config.ts +2 -0
- package/app/components/account/organization/AccountOrganization.vue +159 -0
- package/app/components/account/team/AccountTeam.vue +346 -0
- package/app/composables/useAccountOrganization.ts +25 -0
- package/app/composables/useAccountTeam.ts +34 -0
- package/app/config/navigation.ts +2 -1
- package/app/interfaces/account/organization.ts +19 -0
- package/app/interfaces/account/team.ts +25 -0
- package/i18n/locales/de/account.json +65 -0
- package/i18n/locales/en/account.json +65 -0
- package/package.json +2 -2
- package/server/api/account/organization.get.ts +5 -0
- package/server/api/account/organization.put.ts +9 -0
- package/server/api/account/team/[id].put.ts +21 -0
- package/server/api/account/team.get.ts +5 -0
- package/server/api/account/team.post.ts +21 -0
- package/server/interfaces/organization.ts +16 -0
- package/server/interfaces/team.ts +17 -0
- package/server/services/ApiAddressBookService.ts +6 -6
- package/server/services/ApiCartService.ts +7 -14
- package/server/services/ApiOrganizationService.ts +68 -0
- package/server/services/ApiTeamService.ts +106 -0
- package/server/services/MockOrganizationService.ts +29 -0
- package/server/services/MockTeamService.ts +48 -0
- package/server/utils/liveCatalog.ts +6 -5
- package/server/utils/liveOrderLists.ts +8 -8
- package/server/utils/organizationService.ts +25 -0
- package/server/utils/teamService.ts +25 -0
package/app/api/account.ts
CHANGED
|
@@ -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
|
@@ -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
|
+
};
|
package/app/config/navigation.ts
CHANGED
|
@@ -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/
|
|
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
|
+
}
|