@revenexx/cover 0.2.39 → 0.2.40

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.
@@ -12,9 +12,17 @@ const props = withDefaults(defineProps<{
12
12
  isSaving: boolean;
13
13
  saveError: string | null;
14
14
  typeOptions: { label: string; value: string }[];
15
- /** False when another system owns the address: no edit, no delete. */
15
+ /**
16
+ * False when another system owns the address: no edit, no delete.
17
+ * Unset, it follows account.addresses.editable — so a page that renders
18
+ * the card without passing it (a theme's own copy of the address page)
19
+ * still hides what the storefront must not offer.
20
+ */
16
21
  editable?: boolean;
17
- }>(), { editable: true });
22
+ }>(), { editable: undefined });
23
+
24
+ const configEditable = useMasterDataEditable("addresses");
25
+ const canEdit = computed(() => props.editable ?? configEditable.value);
18
26
 
19
27
  const formState = defineModel<AccountAddressFormState>("formState", { required: true });
20
28
 
@@ -66,7 +74,7 @@ function confirmDelete() {
66
74
  </p>
67
75
  </div>
68
76
  <div
69
- v-if="editable"
77
+ v-if="canEdit"
70
78
  class="flex items-center gap-1"
71
79
  >
72
80
  <UTooltip :text="t('actions.edit')">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.39",
3
+ "version": "0.2.40",
4
4
  "description": "Cover \u2014 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",
@@ -18,6 +18,24 @@ interface AccountProfileRaw {
18
18
  };
19
19
  }
20
20
 
21
+ /** The contact's own phone, or "" — a missing number is not an error. */
22
+ async function contactPhone(contactId: string | undefined): Promise<string> {
23
+ if (!contactId) {
24
+ return "";
25
+ }
26
+ try {
27
+ const contact = await useRevenexxSdk().call<{ phone?: string | null }>(
28
+ "GET",
29
+ `/v1/customers/contacts/${encodeURIComponent(contactId)}`,
30
+ );
31
+ return contact.phone ?? "";
32
+ }
33
+ catch (err) {
34
+ getLogService().error("Profile: contact phone lookup failed", apiErrorContext(err));
35
+ return "";
36
+ }
37
+ }
38
+
21
39
  export default defineEventHandler(async (event): Promise<AccountProfileResponse> => {
22
40
  // Session guard — the profile endpoint always requires a login, regardless
23
41
  // of which identity implementation resolves the user below.
@@ -42,8 +60,25 @@ export default defineEventHandler(async (event): Promise<AccountProfileResponse>
42
60
  // resolves the real customer through the public API.
43
61
  const user = await getAccountService(event).getUser(event);
44
62
 
45
- // Profile extras (phone, company) live in the mutable demo store until a
46
- // platform profile capability exists.
63
+ // Live: the buyer's own phone from their contact, and the company from
64
+ // their organisation. Both used to come from the demo store whatever the
65
+ // mode, so every live buyer saw the demo profile's company and number.
66
+ const live = resolveServiceKey(event, { domain: "accountService", mockKey: "mock", liveKey: "api" }) === "api";
67
+ if (live) {
68
+ const [phone, organization] = await Promise.all([
69
+ contactPhone(session.contactId),
70
+ getOrganizationService(event).get(event).catch(() => null),
71
+ ]);
72
+ return {
73
+ name: user.name,
74
+ email: user.email,
75
+ phone,
76
+ company: organization?.name ?? "",
77
+ initials: user.initials,
78
+ };
79
+ }
80
+
81
+ // Mock: the phone and company of the demo profile.
47
82
  const profileData = await readCoverMutableJson<AccountProfileRaw>("account/profile.json");
48
83
 
49
84
  return {