diff --git a/components/header/Preheader.tsx b/components/header/Preheader.tsx
index 26b969f..ee9895d 100644
--- a/components/header/Preheader.tsx
+++ b/components/header/Preheader.tsx
@@ -35,7 +35,7 @@ export default ({
"https://deco-sites-assets.s3.sa-east-1.amazonaws.com/journeys/f5044d94-348f-4a63-aa15-76949855d78d/us-flag.webp",
label: "EN",
value: "en",
- salesChannel: "1"
+ salesChannel: "1",
},
{
alt: "Canada",
@@ -43,7 +43,7 @@ export default ({
"https://deco-sites-assets.s3.sa-east-1.amazonaws.com/journeys/d83429c1-3a7a-4751-8056-e26c7f33bd0a/ca-flag.webp",
label: "EN",
value: "en-ca",
- salesChannel: "2"
+ salesChannel: "2",
},
{
flag:
@@ -51,14 +51,14 @@ export default ({
alt: "Canada - French",
label: "FR",
value: "fr-ca",
- salesChannel: "3"
+ salesChannel: "3",
},
],
url,
...props
}: PreheaderProps) => {
const [currentLang, ...otherLanguages] = langs;
- const isKidzHome = url.pathname === "/kidz";
+ const isKidzHome = url?.pathname === "/kidz";
const isDesktop = useDevice() === "desktop";
if (!isDesktop) {
@@ -112,7 +112,7 @@ export default ({
-
+
diff --git a/components/product/ProductCard.tsx b/components/product/ProductCard.tsx
index 49c190e..67acf10 100644
--- a/components/product/ProductCard.tsx
+++ b/components/product/ProductCard.tsx
@@ -34,7 +34,7 @@ function ProductCard({
index,
class: _class,
currencyCode,
- locale
+ locale,
}: Props) {
const { url, image: images, offers, isVariantOf } = product;
const title = isVariantOf?.name ?? product.name;
@@ -58,10 +58,10 @@ function ProductCard({
},
});
- const USDollar = new Intl.NumberFormat("en-US", {
- style: "currency",
- currency: "USD",
- });
+ // const USDollar = new Intl.NumberFormat("en-US", {
+ // style: "currency",
+ // currency: "USD",
+ // });
return (
- {formatPrice(price, currencyCode, locale)}
+ {formatPrice(price, currencyCode, locale)}
diff --git a/components/product/ProductSlider.tsx b/components/product/ProductSlider.tsx
index 65f2858..da4c71c 100644
--- a/components/product/ProductSlider.tsx
+++ b/components/product/ProductSlider.tsx
@@ -14,7 +14,9 @@ interface Props {
locale: string;
}
-function ProductSlider({ products, itemListName, currencyCode, locale }: Props) {
+function ProductSlider(
+ { products, itemListName, currencyCode, locale }: Props,
+) {
const id = useId();
const device = useDevice();
diff --git a/components/search/SearchResult.tsx b/components/search/SearchResult.tsx
index 9baff02..48e9996 100644
--- a/components/search/SearchResult.tsx
+++ b/components/search/SearchResult.tsx
@@ -13,7 +13,7 @@ import Sort from "./Sort.tsx";
import { useDevice, useScript, useSection } from "@deco/deco/hooks";
import { type SectionProps } from "@deco/deco";
import { getCookies } from "std/http/cookie.ts";
-import { CurrencyCode } from "apps/shopify/utils/enums.ts";
+// import { CurrencyCode } from "apps/shopify/utils/enums.ts";
export interface Layout {
/**
* @title Pagination
@@ -301,7 +301,6 @@ function SearchResult({ page, ...props }: SectionProps
) {
return ;
}
return ;
-
}
export const loader = (props: Props, req: Request) => {
@@ -312,6 +311,6 @@ export const loader = (props: Props, req: Request) => {
currencyCode: vtexSegment.currencyCode,
locale: vtexSegment.cultureInfo,
url: req.url,
- }
-}
+ };
+};
export default SearchResult;
diff --git a/components/search/Searchbar/Suggestions.tsx b/components/search/Searchbar/Suggestions.tsx
index bb942c8..c4ee944 100644
--- a/components/search/Searchbar/Suggestions.tsx
+++ b/components/search/Searchbar/Suggestions.tsx
@@ -7,12 +7,21 @@ import Icon from "../../ui/Icon.tsx";
import Slider from "../../ui/Slider.tsx";
import { ACTION, NAME } from "./Form.tsx";
import { type Resolved } from "@deco/deco";
+import { getCookies } from "std/http/cookie.ts";
export interface Props {
/**
* @title Suggestions Integration
* @todo: improve this typings ({query: string, count: number}) => Suggestions
*/
loader: Resolved;
+ /**
+ * @ignore
+ */
+ currencyCode?: string;
+ /**
+ * @ignore
+ */
+ locale?: string;
}
export const action = async (props: Props, req: Request, ctx: AppContext) => {
const {
@@ -25,7 +34,7 @@ export const action = async (props: Props, req: Request, ctx: AppContext) => {
...loaderProps,
query,
})) as Suggestion | null;
- return { suggestion };
+ return { suggestion, ...props };
};
export const loader = async (props: Props, req: Request, ctx: AppContext) => {
const {
@@ -37,11 +46,20 @@ export const loader = async (props: Props, req: Request, ctx: AppContext) => {
...loaderProps,
query,
})) as Suggestion | null;
- return { suggestion };
+
+ const cookies = getCookies(req.headers);
+ const vtexSegment = JSON.parse(atob(cookies["vtex_segment"]));
+ return {
+ suggestion,
+ currencyCode: vtexSegment.currencyCode,
+ locale: vtexSegment.cultureInfo,
+ };
};
-function Suggestions(
- { suggestion }: ComponentProps,
-) {
+function Suggestions({
+ suggestion,
+ currencyCode,
+ locale,
+}: ComponentProps) {
let { products = [], searches = [] } = suggestion ?? {};
products ??= [];
@@ -87,6 +105,8 @@ function Suggestions(
product={product}
index={index}
itemListName="Suggeestions"
+ currencyCode={currencyCode}
+ locale={locale}
/>
))}
diff --git a/components/shipping/Results.tsx b/components/shipping/Results.tsx
index bcc26b7..4ba10c9 100644
--- a/components/shipping/Results.tsx
+++ b/components/shipping/Results.tsx
@@ -66,8 +66,8 @@ export default function Results({ result }: ComponentProps) {
))}
- Delivery times start counting from confirmation of the order payment and may vary according to the quantity of products in the
- bag.
+ Delivery times start counting from confirmation of the order payment and
+ may vary according to the quantity of products in the bag.
);
diff --git a/components/wishlist/WishlistGallery.tsx b/components/wishlist/WishlistGallery.tsx
index f2d9434..f2de2fc 100644
--- a/components/wishlist/WishlistGallery.tsx
+++ b/components/wishlist/WishlistGallery.tsx
@@ -1,3 +1,4 @@
+import { getCookies } from "std/http/cookie.ts";
import SearchResult, {
Props as SearchResultProps,
} from "../search/SearchResult.tsx";
@@ -18,12 +19,23 @@ function WishlistGallery(props: SectionProps) {
);
}
- return
;
+ return (
+
+ );
}
export const loader = (props: Props, req: Request) => {
+ const cookies = getCookies(req.headers);
+ const vtexSegment = JSON.parse(atob(cookies["vtex_segment"]));
+
return {
...props,
url: req.url,
+ currencyCode: vtexSegment.currencyCode,
+ locale: vtexSegment.cultureInfo,
};
};
export default WishlistGallery;
diff --git a/sections/Component.tsx b/sections/Component.tsx
index 6cda691..4d1dda9 100644
--- a/sections/Component.tsx
+++ b/sections/Component.tsx
@@ -20,8 +20,8 @@ export class ErrorBoundary extends Component<{
}, {
error: Error | null;
}> {
- state = { error: null };
- static getDerivedStateFromError(error: Error) {
+ override state = { error: null };
+ static override getDerivedStateFromError(error: Error) {
return { error };
}
render() {
diff --git a/sections/Header/Header.tsx b/sections/Header/Header.tsx
index 83b58b8..45f9a9d 100644
--- a/sections/Header/Header.tsx
+++ b/sections/Header/Header.tsx
@@ -1,4 +1,4 @@
-import type { LoadingFallbackProps } from "@deco/deco";
+import type { LoadingFallbackProps, SectionProps } from "@deco/deco";
import { useDevice, useScript } from "@deco/deco/hooks";
import type { ImageWidget } from "apps/admin/widgets.ts";
import Image from "apps/website/components/Image.tsx";
@@ -47,11 +47,11 @@ export interface PreheaderProps {
* @ignore
*/
currentLang?: Lang;
- alerts: Alert[];
+ alerts?: Alert[];
/**
* @ignore
*/
- url: URL;
+ url?: URL;
}
/**
@@ -84,6 +84,10 @@ export interface Props {
* @description Usefull for lazy loading hidden elements, like hamburguer menus etc
* @hide true */
loading?: "eager" | "lazy";
+ /**
+ * @ignore
+ */
+ url?: string;
}
export function Alerts({ alerts }: { alerts: Alert[] }) {
@@ -146,9 +150,7 @@ export function Alerts({ alerts }: { alerts: Alert[] }) {
);
}
-const Desktop = (
- { navItems, logo, searchbar, loading }: ReturnType
,
-) => (
+const Desktop = ({ navItems, logo, searchbar, loading }: Props) => (
<>