@revenexx/cover 0.11.0 → 0.13.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.
- package/app/components/account/carts/AccountCartsTable.vue +4 -2
- package/app/components/auth/AuthLoginPanel.vue +71 -16
- package/app/components/auth/AuthRegisterPanel.vue +1 -1
- package/app/components/cart/recommend/CartCrossSell.vue +2 -1
- package/app/components/cart/switcher/CartSwitcher.vue +5 -2
- package/app/components/listing/ListingFilterBar.vue +1 -0
- package/app/components/listing/ListingFilterDrawer.vue +1 -0
- package/app/components/listing/ListingFilterRail.vue +1 -0
- package/app/components/search/filter/SearchFacets.vue +10 -3
- package/app/components/search/filter/SearchFacetsBar.vue +7 -3
- package/app/components/search/filter/SearchFacetsDrawer.vue +7 -2
- package/app/components/ui/forms/SearchInput.vue +4 -1
- package/app/composables/useAuthStore.ts +4 -2
- package/app/composables/useFacetMeta.ts +6 -6
- package/app/composables/useProductListing.ts +18 -2
- package/app/composables/useSearchListing.ts +16 -0
- package/app/interfaces/auth.ts +12 -2
- package/app/interfaces/shopSettings.ts +84 -0
- package/app/shared/locale.ts +114 -0
- package/i18n/locales/de/auth.json +41 -2
- package/i18n/locales/de/cart.json +2 -1
- package/i18n/locales/en/auth.json +41 -2
- package/i18n/locales/en/cart.json +2 -1
- package/nuxt.config.ts +22 -0
- package/package.json +1 -1
- package/server/api/account/quotes/[id]/order.post.ts +14 -3
- package/server/api/auth/login.post.ts +16 -3
- package/server/api/cart/calculate.post.ts +4 -0
- package/server/api/carts/[id]/activate.post.ts +7 -0
- package/server/api/carts/[id]/index.delete.ts +2 -0
- package/server/api/carts/index.post.ts +4 -0
- package/server/api/categories/[slug]/subcategories.get.ts +34 -31
- package/server/api/orders/index.post.ts +78 -31
- package/server/api/payment/psp-config.get.ts +11 -21
- package/server/api/quotes/request.post.ts +2 -2
- package/server/api/typesense/search.post.ts +61 -317
- package/server/api/typesense/suggest.post.ts +14 -9
- package/server/{api/typesense/drop.get.ts → dev/typesense/drop.ts} +2 -1
- package/server/{api/typesense/health.get.ts → dev/typesense/health.ts} +1 -0
- package/server/dev/typesense/seed.ts +59 -0
- package/server/dev/typesense/seedDocuments.ts +105 -0
- package/server/interfaces/auth.ts +10 -1
- package/server/routes/punchout/start.get.ts +44 -16
- package/server/services/ApiAuthService.ts +22 -6
- package/server/services/ApiBrandService.ts +28 -42
- package/server/services/ApiCartService.ts +64 -22
- package/server/services/ApiProductService.ts +10 -11
- package/server/services/MockAuthService.ts +21 -2
- package/server/utils/buyerIdentity.ts +11 -0
- package/server/utils/cartOwnership.ts +40 -0
- package/server/utils/liveCatalog.ts +132 -49
- package/server/utils/liveListingSearch.ts +201 -0
- package/server/utils/livePrices.ts +24 -9
- package/server/utils/orderLinePrices.ts +72 -0
- package/server/utils/paymentFee.ts +59 -0
- package/server/utils/pspConfig.ts +42 -0
- package/server/utils/revenexxSdk.ts +25 -2
- package/server/utils/searchClient.ts +305 -0
- package/server/utils/searchMultiSearchFallback.ts +216 -0
- package/server/utils/shopSettings.ts +5 -0
- package/server/api/typesense/seed.get.ts +0 -111
|
@@ -15,10 +15,12 @@ const { to } = useAppUrl();
|
|
|
15
15
|
const toast = useToast();
|
|
16
16
|
const cart = useCartStore();
|
|
17
17
|
const { settings } = useB2BContext();
|
|
18
|
+
const { isPunchout } = usePunchoutVisit();
|
|
18
19
|
const { formatCurrency } = useCartSummaryFormatting();
|
|
19
20
|
const { tableUi } = useDataTable();
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
// A punchout visit has exactly one cart, the one handed back (RAD-109).
|
|
23
|
+
const enabled = computed(() => settings.value?.cart.multipleCarts === true && !isPunchout.value);
|
|
22
24
|
|
|
23
25
|
/* ---- search ----------------------------------------------------------- */
|
|
24
26
|
const search = ref("");
|
|
@@ -113,7 +115,7 @@ function onDelete(): void {
|
|
|
113
115
|
color="neutral"
|
|
114
116
|
variant="subtle"
|
|
115
117
|
:icon="icon('info')"
|
|
116
|
-
:title="t('cart.multi.page.disabled')"
|
|
118
|
+
:title="isPunchout ? t('cart.multi.page.punchout') : t('cart.multi.page.disabled')"
|
|
117
119
|
/>
|
|
118
120
|
|
|
119
121
|
<template v-else>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { LoginFormState } from "../../interfaces/auth";
|
|
3
|
+
import type { LoginIdentifierKind } from "../../interfaces/shopSettings";
|
|
4
|
+
import { loginIdentifierField, loginIdentifierKind, offeredLoginIdentifiers } from "../../interfaces/shopSettings";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* "I already have an account" panel of the split login page. Owns the login
|
|
@@ -29,6 +31,17 @@ const magicLinkOffered = computed(() => signIn.value?.magicLink === true);
|
|
|
29
31
|
const otpOffered = computed(() => signIn.value?.emailOtp === true);
|
|
30
32
|
const anyMailedWay = computed(() => magicLinkOffered.value || otpOffered.value);
|
|
31
33
|
|
|
34
|
+
/**
|
|
35
|
+
* What the password field asks for (RAD-151): an address, a username, a
|
|
36
|
+
* customer number, or any mix the merchant switched on. Label, keyboard,
|
|
37
|
+
* autofill and validation follow it — a field that insists on an address would
|
|
38
|
+
* refuse a buyer the shop lets in by username before the shop ever saw it.
|
|
39
|
+
*/
|
|
40
|
+
const identifierField = computed(() => loginIdentifierField(signIn.value?.identifiers));
|
|
41
|
+
const identifierLabel = computed(() => t(`${identifierField.value.key}.label`));
|
|
42
|
+
/** Where it accepts only an address, the mailed ways share that one field. */
|
|
43
|
+
const identifierIsEmail = computed(() => identifierField.value.type === "email");
|
|
44
|
+
|
|
32
45
|
/* ---- signing in by mail ------------------------------------------------ */
|
|
33
46
|
|
|
34
47
|
/** Which mailed way the buyer is in the middle of, and how far. */
|
|
@@ -38,13 +51,21 @@ const mailSent = ref(false);
|
|
|
38
51
|
const otpUserId = ref<string | null>(null);
|
|
39
52
|
const otpCode = ref("");
|
|
40
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The address a link or code goes to. The mailed ways only ever take an
|
|
56
|
+
* address, so where the sign-in field accepts a username too, they get a field
|
|
57
|
+
* of their own rather than mailing whatever was typed.
|
|
58
|
+
*/
|
|
59
|
+
const mailAddress = computed(() => (passwordOffered.value && identifierIsEmail.value ? state.identifier : state.email).trim());
|
|
60
|
+
const mailNeedsOwnField = computed(() => !passwordOffered.value || !identifierIsEmail.value);
|
|
61
|
+
|
|
41
62
|
async function requestMail(kind: "magic-link" | "otp"): Promise<void> {
|
|
42
|
-
if (!
|
|
63
|
+
if (!mailAddress.value) {
|
|
43
64
|
return;
|
|
44
65
|
}
|
|
45
66
|
mailedKind.value = kind;
|
|
46
67
|
try {
|
|
47
|
-
otpUserId.value = await auth.requestSignInMail(kind,
|
|
68
|
+
otpUserId.value = await auth.requestSignInMail(kind, mailAddress.value);
|
|
48
69
|
mailSent.value = true;
|
|
49
70
|
}
|
|
50
71
|
catch {
|
|
@@ -77,14 +98,41 @@ function startOver(): void {
|
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
const state = reactive<LoginFormState>({
|
|
80
|
-
|
|
101
|
+
identifier: "",
|
|
81
102
|
password: "",
|
|
103
|
+
email: "",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/** The kind of identifier last submitted — what a refusal is worded for. */
|
|
107
|
+
const submittedKind = ref<LoginIdentifierKind>("email");
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The refusal, in the words of what was typed. Wrong credentials name the
|
|
111
|
+
* identifier the buyer used; a customer number adds that it signs in as the
|
|
112
|
+
* company's primary contact, which is why a buyer's own password does not
|
|
113
|
+
* open it. An identifier the shop does not take says which ones it does.
|
|
114
|
+
*/
|
|
115
|
+
const errorMessage = computed(() => {
|
|
116
|
+
if (!error.value) {
|
|
117
|
+
return "";
|
|
118
|
+
}
|
|
119
|
+
if (error.value === "auth.login.errors.invalidCredentials") {
|
|
120
|
+
return t(`auth.login.errors.invalidCredentialsBy.${submittedKind.value}`);
|
|
121
|
+
}
|
|
122
|
+
if (error.value === "auth.login.errors.identifierNotOffered") {
|
|
123
|
+
return t(error.value, { accepted: identifierLabel.value });
|
|
124
|
+
}
|
|
125
|
+
return t(error.value);
|
|
82
126
|
});
|
|
83
127
|
|
|
84
128
|
async function onSubmit(): Promise<void> {
|
|
129
|
+
const identifier = state.identifier.trim();
|
|
130
|
+
// One accepted kind is what was meant, whatever it looks like.
|
|
131
|
+
const offered = offeredLoginIdentifiers(signIn.value?.identifiers);
|
|
132
|
+
submittedKind.value = offered.length === 1 ? offered[0]! : loginIdentifierKind(identifier);
|
|
85
133
|
try {
|
|
86
134
|
await auth.login({
|
|
87
|
-
|
|
135
|
+
identifier,
|
|
88
136
|
password: state.password,
|
|
89
137
|
});
|
|
90
138
|
emit("success");
|
|
@@ -123,7 +171,7 @@ async function onSubmit(): Promise<void> {
|
|
|
123
171
|
{{ t(passwordOffered ? 'auth.login.mailed.alternative' : 'auth.login.mailed.only') }}
|
|
124
172
|
</p>
|
|
125
173
|
<UInput
|
|
126
|
-
v-if="
|
|
174
|
+
v-if="mailNeedsOwnField"
|
|
127
175
|
v-model="state.email"
|
|
128
176
|
type="email"
|
|
129
177
|
class="w-full"
|
|
@@ -135,7 +183,7 @@ async function onSubmit(): Promise<void> {
|
|
|
135
183
|
v-if="magicLinkOffered"
|
|
136
184
|
color="neutral"
|
|
137
185
|
:variant="passwordOffered ? 'outline' : 'solid'"
|
|
138
|
-
:disabled="!
|
|
186
|
+
:disabled="!mailAddress || loading"
|
|
139
187
|
:label="t('auth.login.mailed.requestLink')"
|
|
140
188
|
@click="requestMail('magic-link')"
|
|
141
189
|
/>
|
|
@@ -143,7 +191,7 @@ async function onSubmit(): Promise<void> {
|
|
|
143
191
|
v-if="otpOffered"
|
|
144
192
|
color="neutral"
|
|
145
193
|
:variant="passwordOffered ? 'outline' : 'solid'"
|
|
146
|
-
:disabled="!
|
|
194
|
+
:disabled="!mailAddress || loading"
|
|
147
195
|
:label="t('auth.login.mailed.requestCode')"
|
|
148
196
|
@click="requestMail('otp')"
|
|
149
197
|
/>
|
|
@@ -155,7 +203,7 @@ async function onSubmit(): Promise<void> {
|
|
|
155
203
|
color="success"
|
|
156
204
|
variant="soft"
|
|
157
205
|
:title="t('auth.login.mailed.sentTitle')"
|
|
158
|
-
:description="t(mailedKind === 'otp' ? 'auth.login.mailed.sentCode' : 'auth.login.mailed.sentLink', { email:
|
|
206
|
+
:description="t(mailedKind === 'otp' ? 'auth.login.mailed.sentCode' : 'auth.login.mailed.sentLink', { email: mailAddress })"
|
|
159
207
|
/>
|
|
160
208
|
<!-- The code is typed back here; a link is followed instead. -->
|
|
161
209
|
<div
|
|
@@ -193,15 +241,22 @@ async function onSubmit(): Promise<void> {
|
|
|
193
241
|
class="space-y-4"
|
|
194
242
|
@submit="onSubmit"
|
|
195
243
|
>
|
|
244
|
+
<!-- Keyed on the type: FormKit fixes an input's type when it mounts. -->
|
|
196
245
|
<FormKit
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
246
|
+
:key="identifierField.type"
|
|
247
|
+
v-model="state.identifier"
|
|
248
|
+
:type="identifierField.type"
|
|
249
|
+
:label="identifierLabel"
|
|
250
|
+
name="identifier"
|
|
251
|
+
:validation="identifierField.validation"
|
|
252
|
+
:validation-label="identifierLabel"
|
|
253
|
+
:autocomplete="identifierField.autocomplete"
|
|
254
|
+
:inputmode="identifierField.inputmode"
|
|
255
|
+
autocapitalize="none"
|
|
256
|
+
spellcheck="false"
|
|
257
|
+
:help="identifierField.customerNumber ? t('auth.login.identifierHelp.customerNumber') : undefined"
|
|
203
258
|
input-class="h-8 py-1 bg-(--ui-bg)"
|
|
204
|
-
:placeholder="t(
|
|
259
|
+
:placeholder="t(`${identifierField.key}.placeholder`)"
|
|
205
260
|
/>
|
|
206
261
|
|
|
207
262
|
<FormKit
|
|
@@ -219,7 +274,7 @@ async function onSubmit(): Promise<void> {
|
|
|
219
274
|
v-if="error"
|
|
220
275
|
color="error"
|
|
221
276
|
variant="soft"
|
|
222
|
-
:title="
|
|
277
|
+
:title="errorMessage"
|
|
223
278
|
/>
|
|
224
279
|
|
|
225
280
|
<UButton
|
|
@@ -16,7 +16,7 @@ const props = defineProps<{
|
|
|
16
16
|
}>();
|
|
17
17
|
|
|
18
18
|
const { icon } = useIcons();
|
|
19
|
-
const { t } = useI18n();
|
|
19
|
+
const { locale, t } = useI18n();
|
|
20
20
|
const toast = useToast();
|
|
21
21
|
const cart = useCartStore();
|
|
22
22
|
|
|
@@ -33,6 +33,7 @@ const { data } = useFetch<{ products: ProductList[] }>(searchApi.search(), {
|
|
|
33
33
|
key: `cart-cross-sell:${props.popular ? "popular" : "category"}`,
|
|
34
34
|
method: "POST",
|
|
35
35
|
body: requestBody,
|
|
36
|
+
headers: computed(() => ({ "x-locale": locale.value })),
|
|
36
37
|
server: false,
|
|
37
38
|
lazy: true,
|
|
38
39
|
default: () => ({ products: [] }),
|
|
@@ -5,15 +5,18 @@ import type { DropdownMenuItem } from "@nuxt/ui";
|
|
|
5
5
|
/**
|
|
6
6
|
* Cart switcher for the cart page (multiple-carts feature): pick the
|
|
7
7
|
* active cart, create a new one, rename or delete the current one.
|
|
8
|
-
* Renders nothing while the org flag is off
|
|
8
|
+
* Renders nothing while the org flag is off, and on a punchout visit: the
|
|
9
|
+
* visit works in the one cart its procurement system receives (RAD-109), and
|
|
10
|
+
* the BFF refuses switching or deleting it with 409 `punchout_cart_fixed`.
|
|
9
11
|
*/
|
|
10
12
|
const { icon } = useIcons();
|
|
11
13
|
const { t } = useI18n();
|
|
12
14
|
const toast = useToast();
|
|
13
15
|
const cart = useCartStore();
|
|
14
16
|
const { settings } = useB2BContext();
|
|
17
|
+
const { isPunchout } = usePunchoutVisit();
|
|
15
18
|
|
|
16
|
-
const enabled = computed(() => settings.value?.cart.multipleCarts === true);
|
|
19
|
+
const enabled = computed(() => settings.value?.cart.multipleCarts === true && !isPunchout.value);
|
|
17
20
|
|
|
18
21
|
const createOpen = ref(false);
|
|
19
22
|
const renameOpen = ref(false);
|
|
@@ -55,6 +55,7 @@ const listing = props.listing;
|
|
|
55
55
|
v-model="listing.activeFilters.value"
|
|
56
56
|
v-model:price-range="listing.priceRange.value"
|
|
57
57
|
:facets="listing.facets.value"
|
|
58
|
+
:show-price="listing.priceFilter.value"
|
|
58
59
|
/>
|
|
59
60
|
</div>
|
|
60
61
|
<div class="border-t border-(--ui-border) p-4">
|
|
@@ -7,11 +7,15 @@ import type { PriceRange, SearchFacet } from "../../../interfaces/search-facets"
|
|
|
7
7
|
* shared facet logic (toggling, labels, debounced price) lives in
|
|
8
8
|
* useFacetFilters; this component owns the vertical accordion presentation.
|
|
9
9
|
*/
|
|
10
|
-
const props = defineProps<{
|
|
10
|
+
const props = withDefaults(defineProps<{
|
|
11
11
|
facets: SearchFacet[];
|
|
12
12
|
modelValue: Record<string, string[]>;
|
|
13
13
|
priceRange: PriceRange;
|
|
14
|
-
|
|
14
|
+
/** Offer the price range — off where the index carries no price. */
|
|
15
|
+
showPrice?: boolean;
|
|
16
|
+
}>(), {
|
|
17
|
+
showPrice: true,
|
|
18
|
+
});
|
|
15
19
|
|
|
16
20
|
const emit = defineEmits<{
|
|
17
21
|
"update:modelValue": [value: Record<string, string[]>];
|
|
@@ -108,7 +112,10 @@ function toggleGroup(field: string): void {
|
|
|
108
112
|
</section>
|
|
109
113
|
|
|
110
114
|
<!-- Price range -->
|
|
111
|
-
<section
|
|
115
|
+
<section
|
|
116
|
+
v-if="showPrice"
|
|
117
|
+
class="py-1"
|
|
118
|
+
>
|
|
112
119
|
<button
|
|
113
120
|
type="button"
|
|
114
121
|
tabindex="0"
|
|
@@ -7,11 +7,15 @@ import type { PriceRange, SearchFacet } from "../../../interfaces/search-facets"
|
|
|
7
7
|
* logic with the vertical SearchFacets via useFacetFilters; only the popover
|
|
8
8
|
* presentation differs.
|
|
9
9
|
*/
|
|
10
|
-
const props = defineProps<{
|
|
10
|
+
const props = withDefaults(defineProps<{
|
|
11
11
|
facets: SearchFacet[];
|
|
12
12
|
modelValue: Record<string, string[]>;
|
|
13
13
|
priceRange: PriceRange;
|
|
14
|
-
|
|
14
|
+
/** Offer the price range — off where the index carries no price. */
|
|
15
|
+
showPrice?: boolean;
|
|
16
|
+
}>(), {
|
|
17
|
+
showPrice: true,
|
|
18
|
+
});
|
|
15
19
|
|
|
16
20
|
const emit = defineEmits<{
|
|
17
21
|
"update:modelValue": [value: Record<string, string[]>];
|
|
@@ -94,7 +98,7 @@ const {
|
|
|
94
98
|
</UPopover>
|
|
95
99
|
|
|
96
100
|
<!-- Price -->
|
|
97
|
-
<UPopover>
|
|
101
|
+
<UPopover v-if="showPrice">
|
|
98
102
|
<UButton
|
|
99
103
|
color="neutral"
|
|
100
104
|
variant="outline"
|
|
@@ -3,11 +3,15 @@ import type { PriceRange, SearchFacet } from "../../../interfaces/search-facets"
|
|
|
3
3
|
|
|
4
4
|
const { icon } = useIcons();
|
|
5
5
|
|
|
6
|
-
const props = defineProps<{
|
|
6
|
+
const props = withDefaults(defineProps<{
|
|
7
7
|
facets: SearchFacet[];
|
|
8
8
|
modelValue: Record<string, string[]>;
|
|
9
9
|
priceRange: PriceRange;
|
|
10
|
-
|
|
10
|
+
/** Offer the price range — off where the index carries no price. */
|
|
11
|
+
showPrice?: boolean;
|
|
12
|
+
}>(), {
|
|
13
|
+
showPrice: true,
|
|
14
|
+
});
|
|
11
15
|
|
|
12
16
|
const emit = defineEmits<{
|
|
13
17
|
"update:modelValue": [value: Record<string, string[]>];
|
|
@@ -50,6 +54,7 @@ const priceRangeProxy = computed({
|
|
|
50
54
|
v-model="filtersProxy"
|
|
51
55
|
v-model:price-range="priceRangeProxy"
|
|
52
56
|
:facets="facets"
|
|
57
|
+
:show-price="showPrice"
|
|
53
58
|
/>
|
|
54
59
|
</div>
|
|
55
60
|
</template>
|
|
@@ -24,7 +24,7 @@ const props = withDefaults(defineProps<{
|
|
|
24
24
|
placeholder: undefined,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
const { t } = useI18n();
|
|
27
|
+
const { locale, t } = useI18n();
|
|
28
28
|
|
|
29
29
|
const placeholder = computed(() => props.placeholder || t("search.input.placeholder"));
|
|
30
30
|
|
|
@@ -85,6 +85,9 @@ async function fetchSuggestions(q: string): Promise<void> {
|
|
|
85
85
|
const data = await $fetch<{ suggestions: Suggestion[] }>(searchApi.suggest(), {
|
|
86
86
|
method: "POST",
|
|
87
87
|
body: { q },
|
|
88
|
+
// The BFF filters the index by locale; without it, it guesses from the
|
|
89
|
+
// cookie or Accept-Language and may suggest the other language.
|
|
90
|
+
headers: { "x-locale": locale.value },
|
|
88
91
|
}).catch(() => ({ suggestions: [] }));
|
|
89
92
|
suggestions.value = data.suggestions;
|
|
90
93
|
}
|
|
@@ -42,6 +42,8 @@ function mapAuthError(err: unknown, context: "login" | "recovery" | "register" =
|
|
|
42
42
|
return "auth.login.errors.accountBlocked";
|
|
43
43
|
case "organization_blocked":
|
|
44
44
|
return "auth.login.errors.organizationBlocked";
|
|
45
|
+
case "identifier_not_offered":
|
|
46
|
+
return "auth.login.errors.identifierNotOffered";
|
|
45
47
|
case "general_rate_limit_exceeded":
|
|
46
48
|
return context === "recovery"
|
|
47
49
|
? "auth.recovery.errors.rateLimited"
|
|
@@ -114,13 +116,13 @@ export const useAuthStore = defineStore("auth", () => {
|
|
|
114
116
|
}
|
|
115
117
|
};
|
|
116
118
|
|
|
117
|
-
const login = async ({
|
|
119
|
+
const login = async ({ identifier, password }: LoginInput) => {
|
|
118
120
|
loading.value = true;
|
|
119
121
|
error.value = null;
|
|
120
122
|
try {
|
|
121
123
|
const result = await $fetch<{ user: AuthUser; session: StoredSession }>("/api/auth/login", {
|
|
122
124
|
method: "POST",
|
|
123
|
-
body: {
|
|
125
|
+
body: { identifier, password },
|
|
124
126
|
});
|
|
125
127
|
user.value = result.user;
|
|
126
128
|
session.value = result.session;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { productsApi } from "../api/products";
|
|
2
|
+
import { pickLocalizedLabel } from "../shared/locale";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Per-tenant Typesense facet metadata — the subset of product
|
|
@@ -52,13 +53,14 @@ export function useFacetMeta() {
|
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Resolve a localized label for a facet whose Typesense field name
|
|
55
|
-
* is `attrs.<code>`.
|
|
56
|
-
*
|
|
56
|
+
* is `attrs.<code>`. Same chain the BFF uses for every catalogue label
|
|
57
|
+
* (requested → de → en, `de` and `de-DE` keys alike), then the raw code
|
|
58
|
+
* so the UI never renders an empty header.
|
|
57
59
|
*/
|
|
58
60
|
function label(code: string): string {
|
|
59
61
|
const entry = byCode.value.get(code);
|
|
60
62
|
if (!entry) return code;
|
|
61
|
-
return entry.labels
|
|
63
|
+
return pickLocalizedLabel(entry.labels, locale.value, code);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
/**
|
|
@@ -71,9 +73,7 @@ export function useFacetMeta() {
|
|
|
71
73
|
function valueLabel(code: string, value: string): string {
|
|
72
74
|
const entry = byCode.value.get(code);
|
|
73
75
|
if (!entry) return value;
|
|
74
|
-
|
|
75
|
-
if (!optionLabels) return value;
|
|
76
|
-
return optionLabels[locale.value] ?? optionLabels.en ?? value;
|
|
76
|
+
return pickLocalizedLabel(entry.options[value], locale.value, value);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
return { codes, byCode, label, valueLabel, status, error };
|
|
@@ -52,6 +52,13 @@ export interface ListingResponse {
|
|
|
52
52
|
found: number;
|
|
53
53
|
page: number;
|
|
54
54
|
perPage: number;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a price range filters anything on this index. Absent means yes
|
|
57
|
+
* (older BFFs); the live index answers false when it carries no price.
|
|
58
|
+
*/
|
|
59
|
+
priceFilter?: boolean;
|
|
60
|
+
/** Where curation sends this search instead of showing results. */
|
|
61
|
+
redirect?: string;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
/**
|
|
@@ -289,9 +296,18 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
289
296
|
.filter((f): f is SearchFacet => Boolean(f && f.counts.length > 0));
|
|
290
297
|
});
|
|
291
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Whether the price filter is offered. The live index may carry no price
|
|
301
|
+
* field; a filter that does nothing is not shown at all.
|
|
302
|
+
*/
|
|
303
|
+
const priceFilter = computed(() => data.value?.priceFilter !== false);
|
|
304
|
+
|
|
305
|
+
/** A curated redirect for this query (search view only), or undefined. */
|
|
306
|
+
const redirect = computed(() => data.value?.redirect || undefined);
|
|
307
|
+
|
|
292
308
|
const activeFilterCount = computed(() =>
|
|
293
309
|
Object.values(activeFilters.value).reduce((sum, values) => sum + values.length, 0)
|
|
294
|
-
+ (priceRange.value.min !== undefined || priceRange.value.max !== undefined ? 1 : 0),
|
|
310
|
+
+ (priceFilter.value && (priceRange.value.min !== undefined || priceRange.value.max !== undefined) ? 1 : 0),
|
|
295
311
|
);
|
|
296
312
|
|
|
297
313
|
const chips = computed(() => {
|
|
@@ -326,7 +342,7 @@ export function useProductListing(options: ProductListingOptions) {
|
|
|
326
342
|
})));
|
|
327
343
|
|
|
328
344
|
return {
|
|
329
|
-
query, sort, sortOptions, page, activeFilters, priceRange,
|
|
345
|
+
query, sort, sortOptions, page, activeFilters, priceRange, priceFilter, redirect,
|
|
330
346
|
data, pending, error, execute,
|
|
331
347
|
products, facets, found, totalPages, isEmpty,
|
|
332
348
|
chips, activeFilterCount, removeChip, clearFilters,
|
|
@@ -63,6 +63,20 @@ export const useSearchListing = (options: SearchListingOptions) => {
|
|
|
63
63
|
listEvent: () => ({ event: "search", listId: "search", term: query.value }),
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
// Curation can send a query somewhere else (a category, a landing page):
|
|
67
|
+
// the search answers with a redirect action instead of results to show.
|
|
68
|
+
// Followed on the client and only for a term the visitor actually searched
|
|
69
|
+
// (`?q`), so the editor canvas, which renders an authored sample, stays put.
|
|
70
|
+
// `replace` keeps the back button from bouncing straight back here.
|
|
71
|
+
const redirecting = computed(() => routeQuery.value !== undefined && Boolean(listing.redirect.value));
|
|
72
|
+
if (import.meta.client) {
|
|
73
|
+
watch(() => (routeQuery.value !== undefined ? listing.redirect.value : undefined), (target) => {
|
|
74
|
+
if (target) {
|
|
75
|
+
void navigateTo(target, { replace: true, external: /^https?:\/\//i.test(target) });
|
|
76
|
+
}
|
|
77
|
+
}, { immediate: true });
|
|
78
|
+
}
|
|
79
|
+
|
|
66
80
|
// `?q=*` is the match-all link (Typesense's native catch-all query): the
|
|
67
81
|
// full catalog, presented as such instead of as results for a "*" term.
|
|
68
82
|
const isCatalog = computed(() => query.value.trim() === "*");
|
|
@@ -93,6 +107,8 @@ export const useSearchListing = (options: SearchListingOptions) => {
|
|
|
93
107
|
category, subcategory, categorySlug, subcategorySlug,
|
|
94
108
|
title, breadcrumb,
|
|
95
109
|
q, searchInput, pushQuery,
|
|
110
|
+
/** True while the search is being sent to a curated redirect target. */
|
|
111
|
+
redirecting,
|
|
96
112
|
};
|
|
97
113
|
};
|
|
98
114
|
|
package/app/interfaces/auth.ts
CHANGED
|
@@ -69,7 +69,11 @@ export interface RegisterInput {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export interface LoginInput {
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* What the buyer signs in with: an address, a username or a customer
|
|
74
|
+
* number, whichever the shop accepts (RAD-151).
|
|
75
|
+
*/
|
|
76
|
+
identifier: string;
|
|
73
77
|
password: string;
|
|
74
78
|
}
|
|
75
79
|
|
|
@@ -91,8 +95,14 @@ export interface StoredSession {
|
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
export interface LoginFormState {
|
|
94
|
-
|
|
98
|
+
/** The password sign-in field — whatever identifiers the shop accepts. */
|
|
99
|
+
identifier: string;
|
|
95
100
|
password: string;
|
|
101
|
+
/**
|
|
102
|
+
* The address a mailed link or code goes to. Only its own field where the
|
|
103
|
+
* sign-in field accepts more than an address; otherwise it is that field.
|
|
104
|
+
*/
|
|
105
|
+
email: string;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
export interface RegisterFormState {
|
|
@@ -202,6 +202,24 @@ export interface SignInAppSettings {
|
|
|
202
202
|
emailOtp: boolean;
|
|
203
203
|
/** customers.email_verification — when the address has to be confirmed. */
|
|
204
204
|
emailVerification: "off" | "on_registration" | "required_for_login";
|
|
205
|
+
/**
|
|
206
|
+
* What a buyer may type into the password sign-in field (RAD-151). The
|
|
207
|
+
* mailed ways — link and code — always take an address, whatever is here.
|
|
208
|
+
*/
|
|
209
|
+
identifiers: LoginIdentifierAppSettings;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface LoginIdentifierAppSettings {
|
|
213
|
+
/** customers.login_identifier_email — on unless the merchant turned it off. */
|
|
214
|
+
email: boolean;
|
|
215
|
+
/** customers.login_identifier_username — off until asked for. */
|
|
216
|
+
username: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* customers.login_identifier_customer_number — off until asked for. A
|
|
219
|
+
* customer number names a company, so it signs in as that company's
|
|
220
|
+
* primary contact.
|
|
221
|
+
*/
|
|
222
|
+
customerNumber: boolean;
|
|
205
223
|
}
|
|
206
224
|
|
|
207
225
|
/* ------------------------------------------------------------------ */
|
|
@@ -321,3 +339,69 @@ export function resolvePriceBasis(prices: PriceAppSettings): "net" | "gross" {
|
|
|
321
339
|
}
|
|
322
340
|
return prices.stored;
|
|
323
341
|
}
|
|
342
|
+
|
|
343
|
+
/* ------------------------------------------------------------------ */
|
|
344
|
+
/* What the sign-in field asks for */
|
|
345
|
+
/* ------------------------------------------------------------------ */
|
|
346
|
+
|
|
347
|
+
export type LoginIdentifierKind = "email" | "username" | "customerNumber";
|
|
348
|
+
|
|
349
|
+
/** In the order a label names them. */
|
|
350
|
+
const IDENTIFIER_ORDER: readonly LoginIdentifierKind[] = ["email", "username", "customerNumber"];
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The identifiers this shop accepts, in label order.
|
|
354
|
+
*
|
|
355
|
+
* Never empty: the customers app takes the address when the merchant has
|
|
356
|
+
* switched every identifier off — a misconfiguration narrows a shop and never
|
|
357
|
+
* shuts it — so the field has to ask for the address in that case too.
|
|
358
|
+
*/
|
|
359
|
+
export function offeredLoginIdentifiers(identifiers?: LoginIdentifierAppSettings | null): LoginIdentifierKind[] {
|
|
360
|
+
const offered = IDENTIFIER_ORDER.filter(kind =>
|
|
361
|
+
kind === "email" ? identifiers?.email !== false : identifiers?.[kind] === true,
|
|
362
|
+
);
|
|
363
|
+
return offered.length > 0 ? offered : ["email"];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Which kind of identifier a typed value is, by the same rule the customers
|
|
368
|
+
* app applies: an `@` makes an address, digits alone a customer number, and
|
|
369
|
+
* anything else is a username.
|
|
370
|
+
*/
|
|
371
|
+
export function loginIdentifierKind(value: string): LoginIdentifierKind {
|
|
372
|
+
const trimmed = value.trim();
|
|
373
|
+
if (trimmed.includes("@")) {
|
|
374
|
+
return "email";
|
|
375
|
+
}
|
|
376
|
+
if (/^[0-9]+$/.test(trimmed)) {
|
|
377
|
+
return "customerNumber";
|
|
378
|
+
}
|
|
379
|
+
return "username";
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** How the password sign-in field presents itself for one set of identifiers. */
|
|
383
|
+
export interface LoginIdentifierField {
|
|
384
|
+
/** i18n key under which `.label` and `.placeholder` name the field. */
|
|
385
|
+
key: string;
|
|
386
|
+
type: "email" | "text";
|
|
387
|
+
autocomplete: "email" | "username";
|
|
388
|
+
inputmode: "email" | "numeric" | "text";
|
|
389
|
+
/** FormKit validation: the address format only where nothing else is accepted. */
|
|
390
|
+
validation: string;
|
|
391
|
+
/** Whether a customer number is accepted, which signs in as the company's primary contact. */
|
|
392
|
+
customerNumber: boolean;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export function loginIdentifierField(identifiers?: LoginIdentifierAppSettings | null): LoginIdentifierField {
|
|
396
|
+
const offered = offeredLoginIdentifiers(identifiers);
|
|
397
|
+
const emailOnly = offered.length === 1 && offered[0] === "email";
|
|
398
|
+
const numberOnly = offered.length === 1 && offered[0] === "customerNumber";
|
|
399
|
+
return {
|
|
400
|
+
key: `auth.login.identifier.${offered.join("_")}`,
|
|
401
|
+
type: emailOnly ? "email" : "text",
|
|
402
|
+
autocomplete: emailOnly ? "email" : "username",
|
|
403
|
+
inputmode: emailOnly ? "email" : numberOnly ? "numeric" : "text",
|
|
404
|
+
validation: emailOnly ? "required|email" : "required",
|
|
405
|
+
customerNumber: offered.includes("customerNumber"),
|
|
406
|
+
};
|
|
407
|
+
}
|