orionplace-react 0.7.0 → 0.7.2
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/package.json +1 -1
- package/src/project-readme.mjs +4 -5
- package/templates/app/_storefront/ProductPage.tsx +3 -7
- package/templates/app/_storefront/StorefrontProductStructuredData.tsx +2 -4
- package/templates/app/_storefront/storefrontRoutes.tsx +0 -3
- package/templates/components/orionplace/contact/EmailUnsubscribe.module.css +2 -1
- package/templates/components/orionplace/shared/OrionplaceImage.tsx +2 -1
- package/templates/interfaces/orionplace/appBase/IAppLoadCommon.ts +2 -0
- package/templates/lib/orionplace/productStructuredData.ts +5 -4
- package/templates/lib/orionplace/serverRoute.tsx +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orionplace-react",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Next.js 16 storefront for your Orionplace marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English and Russian, plus an Android app build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/project-readme.mjs
CHANGED
|
@@ -413,11 +413,10 @@ out; the journal and other pages stay indexable. Leave it empty on a live shop.
|
|
|
413
413
|
|
|
414
414
|
Every product page carries schema.org product data for Google and Yandex: the
|
|
415
415
|
price, the crossed-out old price, stock, photos, brand, seller, rating and the
|
|
416
|
-
return terms the page shows.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
out. The delivery cost is not included: it depends on the buyer's address.
|
|
416
|
+
return terms the page shows. The return terms name the shop's shipping
|
|
417
|
+
countries, which Application Load sends in \`init.shipping_countries\`; without
|
|
418
|
+
a shipping country they are left out. The delivery cost is not included: it
|
|
419
|
+
depends on the buyer's address.
|
|
421
420
|
|
|
422
421
|
This setup does not add analytics.
|
|
423
422
|
|
|
@@ -17,11 +17,10 @@ import styles from '@/app/storefront.module.css';
|
|
|
17
17
|
|
|
18
18
|
export function ProductPage({
|
|
19
19
|
productId,
|
|
20
|
-
previewKey
|
|
20
|
+
previewKey = '',
|
|
21
21
|
initialProduct,
|
|
22
|
-
initialError
|
|
23
|
-
origin
|
|
24
|
-
shippingCountries = '',
|
|
22
|
+
initialError = '',
|
|
23
|
+
origin = '',
|
|
25
24
|
}: {
|
|
26
25
|
productId: number;
|
|
27
26
|
previewKey?: string;
|
|
@@ -29,8 +28,6 @@ export function ProductPage({
|
|
|
29
28
|
initialError?: string;
|
|
30
29
|
/** The visitor's origin from the server render. */
|
|
31
30
|
origin?: string;
|
|
32
|
-
/** ORIONPLACE_SHIPPING_COUNTRIES from the server's .env. */
|
|
33
|
-
shippingCountries?: string;
|
|
34
31
|
}) {
|
|
35
32
|
const api = useOrionplaceApi();
|
|
36
33
|
const init = useOrionplace(selectInit);
|
|
@@ -63,7 +60,6 @@ export function ProductPage({
|
|
|
63
60
|
<StorefrontProductStructuredData
|
|
64
61
|
product={metadataProduct}
|
|
65
62
|
origin={origin}
|
|
66
|
-
shippingCountries={shippingCountries}
|
|
67
63
|
/>
|
|
68
64
|
<StorefrontProduct
|
|
69
65
|
productId={productId}
|
|
@@ -30,13 +30,10 @@ import {
|
|
|
30
30
|
export function StorefrontProductStructuredData({
|
|
31
31
|
product,
|
|
32
32
|
origin,
|
|
33
|
-
shippingCountries,
|
|
34
33
|
}: {
|
|
35
34
|
product?: IProduct;
|
|
36
35
|
/** The visitor's origin from the server render (storefrontPublicOrigin). */
|
|
37
36
|
origin: string;
|
|
38
|
-
/** ORIONPLACE_SHIPPING_COUNTRIES from the server's .env. */
|
|
39
|
-
shippingCountries: string;
|
|
40
37
|
}) {
|
|
41
38
|
const pathname = usePathname();
|
|
42
39
|
const search = useSearchParams().toString();
|
|
@@ -62,7 +59,8 @@ export function StorefrontProductStructuredData({
|
|
|
62
59
|
).slice(0, 160),
|
|
63
60
|
currencyId,
|
|
64
61
|
currencyCode: init?.currencies?.[currencyId]?.currency_code,
|
|
65
|
-
|
|
62
|
+
// The backend's shipping countries, for the return terms.
|
|
63
|
+
shippingCountries: shippingCountryCodes(init?.shipping_countries),
|
|
66
64
|
showSeller: !init?.visual_settings?.single_seller_mode,
|
|
67
65
|
absoluteUrl: (value) => storefrontAbsoluteUrl(value, origin),
|
|
68
66
|
})
|
|
@@ -99,8 +99,6 @@ export interface StorefrontRouteContext {
|
|
|
99
99
|
address: string;
|
|
100
100
|
/** The visitor's origin (storefrontPublicOrigin), for complete addresses. */
|
|
101
101
|
origin?: string;
|
|
102
|
-
/** ORIONPLACE_SHIPPING_COUNTRIES from the server's .env. */
|
|
103
|
-
shippingCountries?: string;
|
|
104
102
|
appLoad: { result: AppLoadResult | null; failure: AppLoadFailure | null };
|
|
105
103
|
/** The storefront language of this request. */
|
|
106
104
|
locale: () => Promise<string>;
|
|
@@ -466,7 +464,6 @@ const routes: Record<string, Loader> = {
|
|
|
466
464
|
initialProduct={initialProduct}
|
|
467
465
|
initialError={initialError}
|
|
468
466
|
origin={context.origin ?? ''}
|
|
469
|
-
shippingCountries={context.shippingCountries ?? ''}
|
|
470
467
|
/>
|
|
471
468
|
),
|
|
472
469
|
};
|
|
@@ -62,7 +62,8 @@ export function OrionplaceImage({
|
|
|
62
62
|
className={`${styles.image} ${className}`.trim()}
|
|
63
63
|
data-logo-type={dataLogoType}
|
|
64
64
|
onError={() => setFailed(true)}
|
|
65
|
-
|
|
65
|
+
// The callback has no payload (the element's load event stays inside).
|
|
66
|
+
onLoad={onLoad ? () => onLoad() : undefined}
|
|
66
67
|
/>
|
|
67
68
|
);
|
|
68
69
|
}
|
|
@@ -24,6 +24,8 @@ export interface IAppLoadCommon {
|
|
|
24
24
|
weights: Record<string, IAppLoadCommonUnit>;
|
|
25
25
|
lengths: Record<string, IAppLoadCommonUnit>;
|
|
26
26
|
geo_location_enabled: boolean;
|
|
27
|
+
/** ISO codes of the shop's shipping countries, sorted. */
|
|
28
|
+
shipping_countries?: string[];
|
|
27
29
|
is_authenticated: boolean;
|
|
28
30
|
wallet?: Record<string, IAppLoadCommonWalletValue>;
|
|
29
31
|
logos: IAppLoadCommonLogos;
|
|
@@ -45,7 +45,7 @@ export interface StorefrontProductDataOptions {
|
|
|
45
45
|
/** The currency the page shows prices in (its ID and code). */
|
|
46
46
|
currencyId: string;
|
|
47
47
|
currencyCode: string | undefined;
|
|
48
|
-
/**
|
|
48
|
+
/** App Load `init.shipping_countries`, parsed by shippingCountryCodes(). */
|
|
49
49
|
shippingCountries: string[];
|
|
50
50
|
/** False when the page hides the seller (single-seller storefront). */
|
|
51
51
|
showSeller: boolean;
|
|
@@ -54,11 +54,12 @@ export interface StorefrontProductDataOptions {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* The countries the shop ships to
|
|
58
|
-
*
|
|
57
|
+
* The countries the shop ships to: App Load `init.shipping_countries` (the
|
|
58
|
+
* backend's countries marked as shipping countries), as valid ISO 3166-1
|
|
59
|
+
* alpha-2 codes.
|
|
59
60
|
*/
|
|
60
61
|
export function shippingCountryCodes(value: unknown): string[] {
|
|
61
|
-
const codes = String(value ?? '')
|
|
62
|
+
const codes = (Array.isArray(value) ? value.join(' ') : String(value ?? ''))
|
|
62
63
|
.split(/[\s,;]+/)
|
|
63
64
|
.map((code) => code.trim().toUpperCase())
|
|
64
65
|
.filter((code) => /^[A-Z]{2}$/.test(code));
|
|
@@ -38,7 +38,6 @@ export async function renderStorefrontRoute(
|
|
|
38
38
|
origin: storefrontPublicOrigin(
|
|
39
39
|
incoming.get('x-forwarded-host') ?? incoming.get('host'),
|
|
40
40
|
),
|
|
41
|
-
shippingCountries: process.env.ORIONPLACE_SHIPPING_COUNTRIES ?? '',
|
|
42
41
|
appLoad: await getOrionplaceAppLoad(),
|
|
43
42
|
locale: getOrionplaceServerLocale,
|
|
44
43
|
api: getOrionplaceServerApi,
|