@gfed-medusa/sf-lib-common 3.3.3 → 3.3.5
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/dist/components/breadcrumbs/index.js +6 -2
- package/dist/components/breadcrumbs/index.js.map +1 -1
- package/dist/components/cart-mismatch-banner/index.d.ts +2 -2
- package/dist/components/cart-mismatch-banner/index.d.ts.map +1 -1
- package/dist/components/cart-mismatch-banner/index.js +11 -2
- package/dist/components/cart-mismatch-banner/index.js.map +1 -1
- package/dist/components/country-select/index.js +3 -1
- package/dist/components/country-select/index.js.map +1 -1
- package/dist/components/delete-button/index.d.ts +2 -2
- package/dist/components/error-message/index.d.ts +2 -2
- package/dist/components/error-message/index.js +3 -1
- package/dist/components/error-message/index.js.map +1 -1
- package/dist/components/free-shipping-price-nudge/index.d.ts +2 -2
- package/dist/components/free-shipping-price-nudge/index.js +64 -47
- package/dist/components/free-shipping-price-nudge/index.js.map +1 -1
- package/dist/components/interactive-link/index.d.ts +9 -6
- package/dist/components/interactive-link/index.d.ts.map +1 -1
- package/dist/components/interactive-link/index.js +6 -6
- package/dist/components/interactive-link/index.js.map +1 -1
- package/dist/components/line-item-options/index.d.ts +2 -2
- package/dist/components/line-item-price/index.d.ts +2 -2
- package/dist/components/localized-client-link/index.d.ts +2 -2
- package/dist/components/localized-client-link/index.js +10 -6
- package/dist/components/localized-client-link/index.js.map +1 -1
- package/dist/components/modal/index.d.ts +2 -2
- package/dist/components/preview-price/index.d.ts +2 -2
- package/dist/components/preview-price/index.js +3 -1
- package/dist/components/preview-price/index.js.map +1 -1
- package/dist/components/product-card/index.d.ts +2 -2
- package/dist/components/product-card/index.d.ts.map +1 -1
- package/dist/components/product-card/index.js +3 -3
- package/dist/components/product-card/index.js.map +1 -1
- package/dist/components/product-preview/index.d.ts +7 -3
- package/dist/components/product-preview/index.d.ts.map +1 -1
- package/dist/components/product-preview/index.js +4 -2
- package/dist/components/product-preview/index.js.map +1 -1
- package/dist/components/submit-button/index.d.ts +2 -2
- package/dist/components/thumbnail/index.d.ts +2 -0
- package/dist/components/thumbnail/index.d.ts.map +1 -1
- package/dist/components/thumbnail/index.js +7 -3
- package/dist/components/thumbnail/index.js.map +1 -1
- package/dist/lib/config/medusa.js +3 -2
- package/dist/lib/config/medusa.js.map +1 -1
- package/dist/lib/context/apollo-context.d.ts +2 -2
- package/dist/lib/context/apollo-context.d.ts.map +1 -1
- package/dist/lib/context/apollo-context.js +2 -1
- package/dist/lib/context/apollo-context.js.map +1 -1
- package/dist/lib/context/modal-context.d.ts +2 -2
- package/dist/lib/context/modal-context.d.ts.map +1 -1
- package/dist/lib/context/modal-context.js +3 -1
- package/dist/lib/context/modal-context.js.map +1 -1
- package/dist/lib/data/cart.js +35 -17
- package/dist/lib/data/cart.js.map +1 -1
- package/dist/lib/data/categories.js +2 -1
- package/dist/lib/data/categories.js.map +1 -1
- package/dist/lib/data/client-actions.js +7 -2
- package/dist/lib/data/client-actions.js.map +1 -1
- package/dist/lib/data/collections.js +7 -4
- package/dist/lib/data/collections.js.map +1 -1
- package/dist/lib/data/context.d.ts +2 -2
- package/dist/lib/data/context.js +3 -1
- package/dist/lib/data/context.js.map +1 -1
- package/dist/lib/data/cookies-actions.d.ts.map +1 -1
- package/dist/lib/data/cookies-actions.js +20 -10
- package/dist/lib/data/cookies-actions.js.map +1 -1
- package/dist/lib/data/cookies-utils.js +9 -3
- package/dist/lib/data/cookies-utils.js.map +1 -1
- package/dist/lib/data/customer.js +19 -10
- package/dist/lib/data/customer.js.map +1 -1
- package/dist/lib/data/footer.js +2 -1
- package/dist/lib/data/footer.js.map +1 -1
- package/dist/lib/data/orders.js +3 -2
- package/dist/lib/data/orders.js.map +1 -1
- package/dist/lib/data/regions.js +9 -6
- package/dist/lib/data/regions.js.map +1 -1
- package/dist/lib/globals/expose-globals.js +1 -1
- package/dist/lib/gql/apollo-client.js +12 -7
- package/dist/lib/gql/apollo-client.js.map +1 -1
- package/dist/lib/gql/fragments/cart.d.ts +9 -9
- package/dist/lib/gql/fragments/customer.d.ts +3 -3
- package/dist/lib/gql/fragments/product.d.ts +9 -10
- package/dist/lib/gql/fragments/product.d.ts.map +1 -1
- package/dist/lib/gql/fragments/product.js +1 -10
- package/dist/lib/gql/fragments/product.js.map +1 -1
- package/dist/lib/gql/mutations/cart.d.ts +6 -6
- package/dist/lib/gql/queries/cart.d.ts +2 -2
- package/dist/lib/gql/queries/cart.d.ts.map +1 -1
- package/dist/lib/gql/queries/collections.d.ts +3 -3
- package/dist/lib/gql/queries/collections.d.ts.map +1 -1
- package/dist/lib/gql/queries/customer.d.ts +2 -2
- package/dist/lib/gql/queries/customer.d.ts.map +1 -1
- package/dist/lib/gql/queries/footer.d.ts +3 -3
- package/dist/lib/gql/queries/order.d.ts +4 -4
- package/dist/lib/gql/queries/order.d.ts.map +1 -1
- package/dist/lib/gql/queries/order.js +1 -0
- package/dist/lib/gql/queries/order.js.map +1 -1
- package/dist/lib/gql/queries/product.d.ts +3 -4
- package/dist/lib/gql/queries/product.d.ts.map +1 -1
- package/dist/lib/gql/queries/product.js +2 -12
- package/dist/lib/gql/queries/product.js.map +1 -1
- package/dist/lib/gql/queries/regions.d.ts +3 -3
- package/dist/lib/gql/queries/shipping.d.ts +3 -3
- package/dist/lib/hooks/use-apollo.d.ts +2 -2
- package/dist/lib/hooks/use-apollo.js +2 -1
- package/dist/lib/hooks/use-apollo.js.map +1 -1
- package/dist/lib/hooks/use-cart.js +3 -1
- package/dist/lib/hooks/use-cart.js.map +1 -1
- package/dist/lib/hooks/use-customer.js +3 -1
- package/dist/lib/hooks/use-customer.js.map +1 -1
- package/dist/lib/utils/data-types.js +1 -1
- package/dist/lib/utils/data-types.js.map +1 -1
- package/dist/lib/utils/get-percentage-diff.js +3 -1
- package/dist/lib/utils/get-percentage-diff.js.map +1 -1
- package/dist/lib/utils/get-product-price.js +15 -5
- package/dist/lib/utils/get-product-price.js.map +1 -1
- package/dist/lib/utils/imagekit.d.ts +0 -4
- package/dist/lib/utils/imagekit.d.ts.map +1 -1
- package/dist/lib/utils/imagekit.js +5 -8
- package/dist/lib/utils/imagekit.js.map +1 -1
- package/dist/lib/utils/medusa-error.js +5 -2
- package/dist/lib/utils/medusa-error.js.map +1 -1
- package/dist/types/graphql.d.ts +1 -54
- package/dist/types/graphql.d.ts.map +1 -1
- package/dist/types/graphql.js +1 -203
- package/dist/types/graphql.js.map +1 -1
- package/package.json +4 -4
- package/dist/lib/data/search.d.ts +0 -9
- package/dist/lib/data/search.d.ts.map +0 -1
- package/dist/lib/data/search.js +0 -23
- package/dist/lib/data/search.js.map +0 -1
- package/dist/lib/hooks/use-search.d.ts +0 -22
- package/dist/lib/hooks/use-search.d.ts.map +0 -1
- package/dist/lib/hooks/use-search.js +0 -69
- package/dist/lib/hooks/use-search.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
import * as class_variance_authority_types0 from "class-variance-authority/types";
|
|
4
4
|
|
|
@@ -59,7 +59,7 @@ declare function ProductCard({
|
|
|
59
59
|
variant,
|
|
60
60
|
size,
|
|
61
61
|
className
|
|
62
|
-
}: ProductCardProps):
|
|
62
|
+
}: ProductCardProps): react_jsx_runtime0.JSX.Element;
|
|
63
63
|
//#endregion
|
|
64
64
|
export { ProductCard };
|
|
65
65
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/product-card/index.tsx"],"sourcesContent":[],"mappings":";;;;;cAYM;;;IAoBL,+BAAA,CAAA;AA5BiE,UA8BxD,KAAA,CAtBJ;EAsBI,OAAA,EAAK,MAAA;EAKL,GAAA,CAAA,EAAA,MAAO;AAYH;UAZJ,OAAA,CAe6C;EAC5C,EAAA,EAAA,MAAA;EADwB,KAAA,EAAA;IAAY,GAAA,EAAA,MAAA;IAuC/B,GAAA,CAAA,EAAA,MAAW;EACzB,CAAA;EACA,QAAA,CAAA,EAAA;IACA,QAAA,EAAA,MAAA;IACA,MAAA,EAAA,MAAA;EACA,CAAA;EACA,KAAA,EAAA,MAAA;EACA,IAAA,CAAA,EAAA,MAAA;EACC,KAAA,EAlDM,KAkDN;;UA/CO,gBAAA,SAAyB,YA+ChB,CAAA,OA/CoC,mBA+CpC,CAAA,CAAA;WA9CR;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCK,WAAA;;;;;;;;GAQb,mBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/product-card/index.tsx"],"sourcesContent":[],"mappings":";;;;;cAYM;;;IAoBL,+BAAA,CAAA;AA5BiE,UA8BxD,KAAA,CAtBJ;EAsBI,OAAA,EAAK,MAAA;EAKL,GAAA,CAAA,EAAA,MAAO;AAYH;UAZJ,OAAA,CAe6C;EAC5C,EAAA,EAAA,MAAA;EADwB,KAAA,EAAA;IAAY,GAAA,EAAA,MAAA;IAuC/B,GAAA,CAAA,EAAA,MAAW;EACzB,CAAA;EACA,QAAA,CAAA,EAAA;IACA,QAAA,EAAA,MAAA;IACA,MAAA,EAAA,MAAA;EACA,CAAA;EACA,KAAA,EAAA,MAAA;EACA,IAAA,CAAA,EAAA,MAAA;EACC,KAAA,EAlDM,KAkDN;;UA/CO,gBAAA,SAAyB,YA+ChB,CAAA,OA/CoC,mBA+CpC,CAAA,CAAA;WA9CR;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCK,WAAA;;;;;;;;GAQb,mBAAgB,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -35,7 +35,7 @@ const formatPrice = (price, locale = "en-GB", currency = "GBP") => {
|
|
|
35
35
|
});
|
|
36
36
|
return {
|
|
37
37
|
currentPrice: formatter.format(Number(price.current)),
|
|
38
|
-
oldPrice: price.old ? formatter.format(Number(price.old)) :
|
|
38
|
+
oldPrice: price.old ? formatter.format(Number(price.old)) : undefined
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
function ProductCard({ product, rating, badge, variants, variant, size, className }) {
|
|
@@ -93,7 +93,7 @@ function ProductCard({ product, rating, badge, variants, variant, size, classNam
|
|
|
93
93
|
quality: 60,
|
|
94
94
|
sizes: "(max-width: 576px) 280px, (max-width: 768px) 360px, (max-width: 992px) 240px, 200px"
|
|
95
95
|
}), badge && /* @__PURE__ */ jsx("div", {
|
|
96
|
-
className: "absolute
|
|
96
|
+
className: "absolute left-2 top-2",
|
|
97
97
|
children: /* @__PURE__ */ jsx(Badge, {
|
|
98
98
|
variant: "default",
|
|
99
99
|
children: badge.label
|
|
@@ -120,7 +120,7 @@ function ProductCard({ product, rating, badge, variants, variant, size, classNam
|
|
|
120
120
|
children: oldPrice
|
|
121
121
|
})]
|
|
122
122
|
}),
|
|
123
|
-
rating !==
|
|
123
|
+
rating !== undefined && /* @__PURE__ */ jsx("div", {
|
|
124
124
|
"data-testid": "product-card-rating",
|
|
125
125
|
className: "flex items-center gap-2",
|
|
126
126
|
children: /* @__PURE__ */ jsx(RatingCount, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/product-card/index.tsx"],"sourcesContent":["'use client';\n\nimport Image from 'next/image';\n\nimport { type VariantProps, cva } from 'class-variance-authority';\n\nimport { Badge } from '@gfed-medusa/sf-lib-ui/components/badge';\nimport { Button } from '@gfed-medusa/sf-lib-ui/components/button';\nimport { RatingCount } from '@gfed-medusa/sf-lib-ui/components/rating-count';\nimport { VariantSelector } from '@gfed-medusa/sf-lib-ui/components/variant-selector';\nimport { cn } from '@gfed-medusa/sf-lib-ui/lib/utils';\n\nconst productCardVariants = cva(\n 'rounded-2xl border overflow-hidden transition',\n {\n variants: {\n variant: {\n default: 'flex flex-col shadow-sm hover:shadow-md',\n withAddToCart: 'flex flex-col shadow-sm hover:shadow-md',\n minimal: 'flex flex-col hover:shadow hover:border-muted-foreground/30',\n },\n size: {\n sm: 'w-48',\n md: 'w-64',\n lg: 'w-80',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n },\n }\n);\n\ninterface Price {\n current: string;\n old?: string;\n}\n\ninterface Product {\n id: string;\n image: {\n src: string;\n alt?: string;\n };\n localize?: {\n currency: string;\n locale: string;\n };\n title: string;\n href?: string;\n price: Price;\n}\n\ninterface ProductCardProps extends VariantProps<typeof productCardVariants> {\n product: Product;\n rating?: {\n average: number;\n count?: number;\n };\n badge?: {\n label: string;\n variant?: 'default' | 'sale' | 'new' | 'limited';\n };\n variants?: {\n options: {\n value: string;\n label?: string;\n imageSrc?: string;\n color?: string;\n }[];\n value: string;\n onChange: (value: string) => void;\n };\n quantity?: {\n value: number;\n onChange: (value: number) => void;\n };\n className?: string;\n}\n\nconst formatPrice = (price: Price, locale = 'en-GB', currency = 'GBP') => {\n const formatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n });\n\n return {\n currentPrice: formatter.format(Number(price.current)),\n oldPrice: price.old ? formatter.format(Number(price.old)) : undefined,\n };\n};\n\nexport function ProductCard({\n product,\n rating,\n badge,\n variants,\n variant,\n size,\n className,\n}: ProductCardProps) {\n const { currentPrice, oldPrice } = formatPrice(\n product.price,\n product.localize?.locale,\n product.localize?.currency\n );\n\n switch (variant) {\n case 'minimal':\n return (\n <div\n className={cn(\n productCardVariants({ variant, size }),\n 'w-60 overflow-hidden rounded-2xl border p-0 shadow-sm'\n )}\n >\n <div className=\"relative h-72 w-full overflow-hidden\">\n <Image\n src={product.image.src}\n alt={product.image.alt ?? product.title}\n fill\n className=\"object-cover\"\n sizes=\"240px\"\n quality={60}\n />\n </div>\n\n <div className=\"flex flex-col gap-1 p-3\">\n <div className=\"flex items-center justify-between\">\n <h3 className=\"truncate text-base font-medium\">\n {product.href ? (\n <a href={product.href} className=\"hover:underline\">\n {product.title}\n </a>\n ) : (\n product.title\n )}\n </h3>\n <p className=\"mt-0 text-lg font-semibold text-gray-900\">\n {currentPrice}\n </p>\n </div>\n <p className=\"text-xs text-gray-500\">7 colors</p>\n </div>\n </div>\n );\n default:\n return (\n <div className={cn(productCardVariants({ variant, size }), className)}>\n {/* Image */}\n <div className=\"relative aspect-[1/1]\">\n <Image\n src={product.image.src}\n alt={product.image.alt ?? product.title}\n fill\n className={cn('object-cover')}\n priority\n quality={60}\n sizes=\"(max-width: 576px) 280px, (max-width: 768px) 360px, (max-width: 992px) 240px, 200px\"\n />\n {badge && (\n <div className=\"absolute
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/product-card/index.tsx"],"sourcesContent":["'use client';\n\nimport Image from 'next/image';\n\nimport { type VariantProps, cva } from 'class-variance-authority';\n\nimport { Badge } from '@gfed-medusa/sf-lib-ui/components/badge';\nimport { Button } from '@gfed-medusa/sf-lib-ui/components/button';\nimport { RatingCount } from '@gfed-medusa/sf-lib-ui/components/rating-count';\nimport { VariantSelector } from '@gfed-medusa/sf-lib-ui/components/variant-selector';\nimport { cn } from '@gfed-medusa/sf-lib-ui/lib/utils';\n\nconst productCardVariants = cva(\n 'rounded-2xl border overflow-hidden transition',\n {\n variants: {\n variant: {\n default: 'flex flex-col shadow-sm hover:shadow-md',\n withAddToCart: 'flex flex-col shadow-sm hover:shadow-md',\n minimal: 'flex flex-col hover:shadow hover:border-muted-foreground/30',\n },\n size: {\n sm: 'w-48',\n md: 'w-64',\n lg: 'w-80',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'md',\n },\n }\n);\n\ninterface Price {\n current: string;\n old?: string;\n}\n\ninterface Product {\n id: string;\n image: {\n src: string;\n alt?: string;\n };\n localize?: {\n currency: string;\n locale: string;\n };\n title: string;\n href?: string;\n price: Price;\n}\n\ninterface ProductCardProps extends VariantProps<typeof productCardVariants> {\n product: Product;\n rating?: {\n average: number;\n count?: number;\n };\n badge?: {\n label: string;\n variant?: 'default' | 'sale' | 'new' | 'limited';\n };\n variants?: {\n options: {\n value: string;\n label?: string;\n imageSrc?: string;\n color?: string;\n }[];\n value: string;\n onChange: (value: string) => void;\n };\n quantity?: {\n value: number;\n onChange: (value: number) => void;\n };\n className?: string;\n}\n\nconst formatPrice = (price: Price, locale = 'en-GB', currency = 'GBP') => {\n const formatter = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n });\n\n return {\n currentPrice: formatter.format(Number(price.current)),\n oldPrice: price.old ? formatter.format(Number(price.old)) : undefined,\n };\n};\n\nexport function ProductCard({\n product,\n rating,\n badge,\n variants,\n variant,\n size,\n className,\n}: ProductCardProps) {\n const { currentPrice, oldPrice } = formatPrice(\n product.price,\n product.localize?.locale,\n product.localize?.currency\n );\n\n switch (variant) {\n case 'minimal':\n return (\n <div\n className={cn(\n productCardVariants({ variant, size }),\n 'w-60 overflow-hidden rounded-2xl border p-0 shadow-sm'\n )}\n >\n <div className=\"relative h-72 w-full overflow-hidden\">\n <Image\n src={product.image.src}\n alt={product.image.alt ?? product.title}\n fill\n className=\"object-cover\"\n sizes=\"240px\"\n quality={60}\n />\n </div>\n\n <div className=\"flex flex-col gap-1 p-3\">\n <div className=\"flex items-center justify-between\">\n <h3 className=\"truncate text-base font-medium\">\n {product.href ? (\n <a href={product.href} className=\"hover:underline\">\n {product.title}\n </a>\n ) : (\n product.title\n )}\n </h3>\n <p className=\"mt-0 text-lg font-semibold text-gray-900\">\n {currentPrice}\n </p>\n </div>\n <p className=\"text-xs text-gray-500\">7 colors</p>\n </div>\n </div>\n );\n default:\n return (\n <div className={cn(productCardVariants({ variant, size }), className)}>\n {/* Image */}\n <div className=\"relative aspect-[1/1]\">\n <Image\n src={product.image.src}\n alt={product.image.alt ?? product.title}\n fill\n className={cn('object-cover')}\n priority\n quality={60}\n sizes=\"(max-width: 576px) 280px, (max-width: 768px) 360px, (max-width: 992px) 240px, 200px\"\n />\n {badge && (\n <div className=\"absolute left-2 top-2\">\n <Badge variant=\"default\">{badge.label}</Badge>\n </div>\n )}\n </div>\n\n {/* Content */}\n <div className=\"flex flex-col gap-2 p-3\">\n <h3 className=\"truncate text-base font-medium\">\n {product.href ? (\n <a href={product.href} className=\"hover:underline\">\n {product.title}\n </a>\n ) : (\n product.title\n )}\n </h3>\n\n {/* Price */}\n <div className=\"flex items-center gap-2\">\n <p className=\"text-lg font-semibold\">{currentPrice}</p>\n {oldPrice && (\n <p className=\"text-muted-foreground text-sm line-through\">\n {oldPrice}\n </p>\n )}\n </div>\n\n {/* Rating */}\n {rating !== undefined && (\n <div\n data-testid=\"product-card-rating\"\n className=\"flex items-center gap-2\"\n >\n <RatingCount\n average={rating.average}\n ratingCount={rating.count}\n />\n </div>\n )}\n\n {/* Variant Selector */}\n {variants && (\n <VariantSelector\n options={variants.options}\n value={variants.value ?? ''}\n onChange={variants.onChange}\n type=\"color\"\n />\n )}\n\n {/* Add to Cart button */}\n {variant === 'withAddToCart' && (\n <Button variant=\"default\" className=\"w-full cursor-pointer\">\n Add to Cart\n </Button>\n )}\n </div>\n </div>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,sBAAsB,IAC1B,iDACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,eAAe;GACf,SAAS;GACV;EACD,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;GACL;EACF;CACD,iBAAiB;EACf,SAAS;EACT,MAAM;EACP;CACF,CACF;AAiDD,MAAM,eAAe,OAAc,SAAS,SAAS,WAAW,UAAU;CACxE,MAAM,YAAY,IAAI,KAAK,aAAa,QAAQ;EAC9C,OAAO;EACP;EACD,CAAC;AAEF,QAAO;EACL,cAAc,UAAU,OAAO,OAAO,MAAM,QAAQ,CAAC;EACrD,UAAU,MAAM,MAAM,UAAU,OAAO,OAAO,MAAM,IAAI,CAAC,GAAG;EAC7D;;AAGH,SAAgB,YAAY,EAC1B,SACA,QACA,OACA,UACA,SACA,MACA,aACmB;CACnB,MAAM,EAAE,cAAc,aAAa,YACjC,QAAQ,OACR,QAAQ,UAAU,QAClB,QAAQ,UAAU,SACnB;AAED,SAAQ,SAAR;EACE,KAAK,UACH,QACE,qBAAC;GACC,WAAW,GACT,oBAAoB;IAAE;IAAS;IAAM,CAAC,EACtC,wDACD;cAED,oBAAC;IAAI,WAAU;cACb,oBAAC;KACC,KAAK,QAAQ,MAAM;KACnB,KAAK,QAAQ,MAAM,OAAO,QAAQ;KAClC;KACA,WAAU;KACV,OAAM;KACN,SAAS;MACT;KACE,EAEN,qBAAC;IAAI,WAAU;eACb,qBAAC;KAAI,WAAU;gBACb,oBAAC;MAAG,WAAU;gBACX,QAAQ,OACP,oBAAC;OAAE,MAAM,QAAQ;OAAM,WAAU;iBAC9B,QAAQ;QACP,GAEJ,QAAQ;OAEP,EACL,oBAAC;MAAE,WAAU;gBACV;OACC;MACA,EACN,oBAAC;KAAE,WAAU;eAAwB;MAAY;KAC7C;IACF;EAEV,QACE,QACE,qBAAC;GAAI,WAAW,GAAG,oBAAoB;IAAE;IAAS;IAAM,CAAC,EAAE,UAAU;cAEnE,qBAAC;IAAI,WAAU;eACb,oBAAC;KACC,KAAK,QAAQ,MAAM;KACnB,KAAK,QAAQ,MAAM,OAAO,QAAQ;KAClC;KACA,WAAW,GAAG,eAAe;KAC7B;KACA,SAAS;KACT,OAAM;MACN,EACD,SACC,oBAAC;KAAI,WAAU;eACb,oBAAC;MAAM,SAAQ;gBAAW,MAAM;OAAc;MAC1C;KAEJ,EAGN,qBAAC;IAAI,WAAU;;KACb,oBAAC;MAAG,WAAU;gBACX,QAAQ,OACP,oBAAC;OAAE,MAAM,QAAQ;OAAM,WAAU;iBAC9B,QAAQ;QACP,GAEJ,QAAQ;OAEP;KAGL,qBAAC;MAAI,WAAU;iBACb,oBAAC;OAAE,WAAU;iBAAyB;QAAiB,EACtD,YACC,oBAAC;OAAE,WAAU;iBACV;QACC;OAEF;KAGL,WAAW,aACV,oBAAC;MACC,eAAY;MACZ,WAAU;gBAEV,oBAAC;OACC,SAAS,OAAO;OAChB,aAAa,OAAO;QACpB;OACE;KAIP,YACC,oBAAC;MACC,SAAS,SAAS;MAClB,OAAO,SAAS,SAAS;MACzB,UAAU,SAAS;MACnB,MAAK;OACL;KAIH,YAAY,mBACX,oBAAC;MAAO,SAAQ;MAAU,WAAU;gBAAwB;OAEnD;;KAEP;IACF"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { Product } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime10 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/product-preview/index.d.ts
|
|
5
5
|
type ProductPreviewProps = {
|
|
6
6
|
product: Product;
|
|
7
7
|
isFeatured?: boolean;
|
|
8
|
+
imagePriority?: boolean;
|
|
9
|
+
imageFetchPriority?: 'auto' | 'high' | 'low';
|
|
8
10
|
};
|
|
9
11
|
declare function ProductPreview({
|
|
10
12
|
product,
|
|
11
|
-
isFeatured
|
|
12
|
-
|
|
13
|
+
isFeatured,
|
|
14
|
+
imagePriority,
|
|
15
|
+
imageFetchPriority
|
|
16
|
+
}: ProductPreviewProps): react_jsx_runtime10.JSX.Element;
|
|
13
17
|
//#endregion
|
|
14
18
|
export { ProductPreview, ProductPreviewProps };
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/product-preview/index.tsx"],"sourcesContent":[],"mappings":";;;;KASY,mBAAA;WACD;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/product-preview/index.tsx"],"sourcesContent":[],"mappings":";;;;KASY,mBAAA;WACD;;EADC,aAAA,CAAA,EAAA,OAAmB;EAOtB,kBAAc,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,KAAA;CACrB;iBADO,cAAA,CAEP;EAAA,OAAA;EAAA,UAAA;EAAA,aAAA;EAAA;AAAA,CAAA,EAGC,mBAHD,CAAA,EAGoB,mBAAA,CAAA,GAAA,CAAA,OAHpB"}
|
|
@@ -6,7 +6,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import { Text } from "@medusajs/ui";
|
|
7
7
|
|
|
8
8
|
//#region src/components/product-preview/index.tsx
|
|
9
|
-
function ProductPreview({ product, isFeatured }) {
|
|
9
|
+
function ProductPreview({ product, isFeatured, imagePriority = false, imageFetchPriority }) {
|
|
10
10
|
const { cheapestPrice } = getProductPrice({ product });
|
|
11
11
|
return /* @__PURE__ */ jsx(LocalizedClientLink, {
|
|
12
12
|
href: `/products/${product.handle}`,
|
|
@@ -17,7 +17,9 @@ function ProductPreview({ product, isFeatured }) {
|
|
|
17
17
|
thumbnail: product.thumbnail,
|
|
18
18
|
images: product.images,
|
|
19
19
|
size: "full",
|
|
20
|
-
isFeatured
|
|
20
|
+
isFeatured,
|
|
21
|
+
imagePriority,
|
|
22
|
+
imageFetchPriority
|
|
21
23
|
}), /* @__PURE__ */ jsxs("div", {
|
|
22
24
|
className: "txt-compact-medium mt-4 flex justify-between",
|
|
23
25
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/product-preview/index.tsx"],"sourcesContent":["import { Text } from '@medusajs/ui';\n\nimport { getProductPrice } from '@/lib/utils/get-product-price';\nimport { Product } from '@/types/graphql';\n\nimport { LocalizedClientLink } from '../localized-client-link';\nimport { PreviewPrice } from '../preview-price';\nimport { Thumbnail } from '../thumbnail';\n\nexport type ProductPreviewProps = {\n product: Product;\n isFeatured?: boolean;\n};\n\nfunction ProductPreview({
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/product-preview/index.tsx"],"sourcesContent":["import { Text } from '@medusajs/ui';\n\nimport { getProductPrice } from '@/lib/utils/get-product-price';\nimport { Product } from '@/types/graphql';\n\nimport { LocalizedClientLink } from '../localized-client-link';\nimport { PreviewPrice } from '../preview-price';\nimport { Thumbnail } from '../thumbnail';\n\nexport type ProductPreviewProps = {\n product: Product;\n isFeatured?: boolean;\n imagePriority?: boolean;\n imageFetchPriority?: 'auto' | 'high' | 'low';\n};\n\nfunction ProductPreview({\n product,\n isFeatured,\n imagePriority = false,\n imageFetchPriority,\n}: ProductPreviewProps) {\n const { cheapestPrice } = getProductPrice({\n product,\n });\n\n return (\n <LocalizedClientLink href={`/products/${product.handle}`} className=\"group\">\n <div data-testid=\"product-wrapper\">\n <Thumbnail\n thumbnail={product.thumbnail}\n images={product.images}\n size=\"full\"\n isFeatured={isFeatured}\n imagePriority={imagePriority}\n imageFetchPriority={imageFetchPriority}\n />\n <div className=\"txt-compact-medium mt-4 flex justify-between\">\n <Text className=\"text-ui-fg-subtle\" data-testid=\"product-title\">\n {product.title}\n </Text>\n <div className=\"flex items-center gap-x-2\">\n {cheapestPrice && <PreviewPrice price={cheapestPrice} />}\n </div>\n </div>\n </div>\n </LocalizedClientLink>\n );\n}\n\nexport { ProductPreview };\n"],"mappings":";;;;;;;;AAgBA,SAAS,eAAe,EACtB,SACA,YACA,gBAAgB,OAChB,sBACsB;CACtB,MAAM,EAAE,kBAAkB,gBAAgB,EACxC,SACD,CAAC;AAEF,QACE,oBAAC;EAAoB,MAAM,aAAa,QAAQ;EAAU,WAAU;YAClE,qBAAC;GAAI,eAAY;cACf,oBAAC;IACC,WAAW,QAAQ;IACnB,QAAQ,QAAQ;IAChB,MAAK;IACO;IACG;IACK;KACpB,EACF,qBAAC;IAAI,WAAU;eACb,oBAAC;KAAK,WAAU;KAAoB,eAAY;eAC7C,QAAQ;MACJ,EACP,oBAAC;KAAI,WAAU;eACZ,iBAAiB,oBAAC,gBAAa,OAAO,gBAAiB;MACpD;KACF;IACF;GACc"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime15 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/submit-button/index.d.ts
|
|
5
5
|
declare function SubmitButton({
|
|
@@ -14,7 +14,7 @@ declare function SubmitButton({
|
|
|
14
14
|
className?: string;
|
|
15
15
|
'data-testid'?: string;
|
|
16
16
|
isLoading?: boolean;
|
|
17
|
-
}):
|
|
17
|
+
}): react_jsx_runtime15.JSX.Element;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { SubmitButton };
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/thumbnail/index.tsx"],"sourcesContent":[],"mappings":";;;KAOK,cAAA;;EAAA,MAAA,CAAA,EAAA,GAAA,EAAA,GAAc,IAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/thumbnail/index.tsx"],"sourcesContent":[],"mappings":";;;KAOK,cAAA;;EAAA,MAAA,CAAA,EAAA,GAAA,EAAA,GAAc,IAAA;EAYb,IAAA,CAAA,EAAA,OAqCL,GAAA,QArCyB,GAAA,OAAA,GAAA,MAAT,GAAM,QAAE;;;;;;;cAAnB,WAAW,KAAA,CAAM,GAAG"}
|
|
@@ -5,7 +5,7 @@ import Image from "next/image";
|
|
|
5
5
|
import { PlaceholderImage } from "@gfed-medusa/sf-lib-ui/icons/placeholder-image";
|
|
6
6
|
|
|
7
7
|
//#region src/components/thumbnail/index.tsx
|
|
8
|
-
const Thumbnail = ({ thumbnail, images, size = "small", isFeatured, className, "data-testid": dataTestid }) => {
|
|
8
|
+
const Thumbnail = ({ thumbnail, images, size = "small", isFeatured, imagePriority = false, imageFetchPriority, className, "data-testid": dataTestid }) => {
|
|
9
9
|
const initialImage = thumbnail || images?.[0]?.url;
|
|
10
10
|
return /* @__PURE__ */ jsx(Container, {
|
|
11
11
|
className: clx("rounded-large bg-ui-bg-subtle shadow-elevation-card-rest group-hover:shadow-elevation-card-hover relative w-full overflow-hidden p-4 transition-shadow duration-150 ease-in-out", className, {
|
|
@@ -20,16 +20,20 @@ const Thumbnail = ({ thumbnail, images, size = "small", isFeatured, className, "
|
|
|
20
20
|
"data-testid": dataTestid,
|
|
21
21
|
children: /* @__PURE__ */ jsx(ImageOrPlaceholder, {
|
|
22
22
|
image: initialImage,
|
|
23
|
-
size
|
|
23
|
+
size,
|
|
24
|
+
imagePriority,
|
|
25
|
+
imageFetchPriority
|
|
24
26
|
})
|
|
25
27
|
});
|
|
26
28
|
};
|
|
27
|
-
const ImageOrPlaceholder = ({ image, size }) => {
|
|
29
|
+
const ImageOrPlaceholder = ({ image, size, imagePriority, imageFetchPriority }) => {
|
|
28
30
|
return image ? /* @__PURE__ */ jsx(Image, {
|
|
29
31
|
src: image,
|
|
30
32
|
alt: "Thumbnail",
|
|
31
33
|
className: "absolute inset-0 object-cover object-center",
|
|
32
34
|
draggable: false,
|
|
35
|
+
priority: imagePriority,
|
|
36
|
+
...imageFetchPriority ? { fetchPriority: imageFetchPriority } : {},
|
|
33
37
|
quality: 40,
|
|
34
38
|
sizes: "(max-width: 576px) 280px, (max-width: 768px) 360px, (max-width: 992px) 480px, 800px",
|
|
35
39
|
fill: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Thumbnail: React.FC<ThumbnailProps>"],"sources":["../../../src/components/thumbnail/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport Image from 'next/image';\n\nimport { PlaceholderImage } from '@gfed-medusa/sf-lib-ui/icons/placeholder-image';\nimport { Container, clx } from '@medusajs/ui';\n\ntype ThumbnailProps = {\n thumbnail?: string | null;\n // TODO: Fix image typings\n images?: any[] | null;\n size?: 'small' | 'medium' | 'large' | 'full' | 'square';\n isFeatured?: boolean;\n className?: string;\n 'data-testid'?: string;\n};\n\nconst Thumbnail: React.FC<ThumbnailProps> = ({\n thumbnail,\n images,\n size = 'small',\n isFeatured,\n className,\n 'data-testid': dataTestid,\n}) => {\n const initialImage = thumbnail || images?.[0]?.url;\n\n return (\n <Container\n className={clx(\n 'rounded-large bg-ui-bg-subtle shadow-elevation-card-rest group-hover:shadow-elevation-card-hover relative w-full overflow-hidden p-4 transition-shadow duration-150 ease-in-out',\n className,\n {\n 'aspect-[11/14]': isFeatured,\n 'aspect-[9/16]': !isFeatured && size !== 'square',\n 'aspect-[1/1]': size === 'square',\n 'w-[180px]': size === 'small',\n 'w-[290px]': size === 'medium',\n 'w-[440px]': size === 'large',\n 'w-full': size === 'full',\n }\n )}\n data-testid={dataTestid}\n >\n <ImageOrPlaceholder
|
|
1
|
+
{"version":3,"file":"index.js","names":["Thumbnail: React.FC<ThumbnailProps>"],"sources":["../../../src/components/thumbnail/index.tsx"],"sourcesContent":["import React from 'react';\n\nimport Image from 'next/image';\n\nimport { PlaceholderImage } from '@gfed-medusa/sf-lib-ui/icons/placeholder-image';\nimport { Container, clx } from '@medusajs/ui';\n\ntype ThumbnailProps = {\n thumbnail?: string | null;\n // TODO: Fix image typings\n images?: any[] | null;\n size?: 'small' | 'medium' | 'large' | 'full' | 'square';\n isFeatured?: boolean;\n imagePriority?: boolean;\n imageFetchPriority?: 'auto' | 'high' | 'low';\n className?: string;\n 'data-testid'?: string;\n};\n\nconst Thumbnail: React.FC<ThumbnailProps> = ({\n thumbnail,\n images,\n size = 'small',\n isFeatured,\n imagePriority = false,\n imageFetchPriority,\n className,\n 'data-testid': dataTestid,\n}) => {\n const initialImage = thumbnail || images?.[0]?.url;\n\n return (\n <Container\n className={clx(\n 'rounded-large bg-ui-bg-subtle shadow-elevation-card-rest group-hover:shadow-elevation-card-hover relative w-full overflow-hidden p-4 transition-shadow duration-150 ease-in-out',\n className,\n {\n 'aspect-[11/14]': isFeatured,\n 'aspect-[9/16]': !isFeatured && size !== 'square',\n 'aspect-[1/1]': size === 'square',\n 'w-[180px]': size === 'small',\n 'w-[290px]': size === 'medium',\n 'w-[440px]': size === 'large',\n 'w-full': size === 'full',\n }\n )}\n data-testid={dataTestid}\n >\n <ImageOrPlaceholder\n image={initialImage}\n size={size}\n imagePriority={imagePriority}\n imageFetchPriority={imageFetchPriority}\n />\n </Container>\n );\n};\n\nconst ImageOrPlaceholder = ({\n image,\n size,\n imagePriority,\n imageFetchPriority,\n}: Pick<\n ThumbnailProps,\n 'size' | 'imagePriority' | 'imageFetchPriority'\n> & { image?: string }) => {\n return image ? (\n <Image\n src={image}\n alt=\"Thumbnail\"\n className=\"absolute inset-0 object-cover object-center\"\n draggable={false}\n priority={imagePriority}\n {...(imageFetchPriority ? { fetchPriority: imageFetchPriority } : {})}\n quality={40}\n sizes=\"(max-width: 576px) 280px, (max-width: 768px) 360px, (max-width: 992px) 480px, 800px\"\n fill\n />\n ) : (\n <div className=\"absolute inset-0 flex h-full w-full items-center justify-center\">\n <PlaceholderImage size={size === 'small' ? 16 : 24} />\n </div>\n );\n};\n\nexport { Thumbnail };\n"],"mappings":";;;;;;;AAmBA,MAAMA,aAAuC,EAC3C,WACA,QACA,OAAO,SACP,YACA,gBAAgB,OAChB,oBACA,WACA,eAAe,iBACX;CACJ,MAAM,eAAe,aAAa,SAAS,IAAI;AAE/C,QACE,oBAAC;EACC,WAAW,IACT,mLACA,WACA;GACE,kBAAkB;GAClB,iBAAiB,CAAC,cAAc,SAAS;GACzC,gBAAgB,SAAS;GACzB,aAAa,SAAS;GACtB,aAAa,SAAS;GACtB,aAAa,SAAS;GACtB,UAAU,SAAS;GACpB,CACF;EACD,eAAa;YAEb,oBAAC;GACC,OAAO;GACD;GACS;GACK;IACpB;GACQ;;AAIhB,MAAM,sBAAsB,EAC1B,OACA,MACA,eACA,yBAIyB;AACzB,QAAO,QACL,oBAAC;EACC,KAAK;EACL,KAAI;EACJ,WAAU;EACV,WAAW;EACX,UAAU;EACV,GAAK,qBAAqB,EAAE,eAAe,oBAAoB,GAAG,EAAE;EACpE,SAAS;EACT,OAAM;EACN;GACA,GAEF,oBAAC;EAAI,WAAU;YACb,oBAAC,oBAAiB,MAAM,SAAS,UAAU,KAAK,KAAM;GAClD"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import Medusa from "@medusajs/js-sdk";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/config/medusa.ts
|
|
4
|
+
const DEFAULT_MEDUSA_BACKEND_URL = "http://localhost:9000";
|
|
4
5
|
const sdk = new Medusa({
|
|
5
|
-
baseUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL ||
|
|
6
|
-
debug:
|
|
6
|
+
baseUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL || DEFAULT_MEDUSA_BACKEND_URL,
|
|
7
|
+
debug: "development" === "development",
|
|
7
8
|
publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY
|
|
8
9
|
});
|
|
9
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medusa.js","names":[],"sources":["../../../src/lib/config/medusa.ts"],"sourcesContent":["import Medusa from '@medusajs/js-sdk';\n\nconst DEFAULT_MEDUSA_BACKEND_URL = 'http://localhost:9000';\n\nconst sdk = new Medusa({\n baseUrl:\n process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL || DEFAULT_MEDUSA_BACKEND_URL,\n debug: process.env.NODE_ENV === 'development',\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,\n});\n\nexport { sdk };\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"medusa.js","names":[],"sources":["../../../src/lib/config/medusa.ts"],"sourcesContent":["import Medusa from '@medusajs/js-sdk';\n\nconst DEFAULT_MEDUSA_BACKEND_URL = 'http://localhost:9000';\n\nconst sdk = new Medusa({\n baseUrl:\n process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL || DEFAULT_MEDUSA_BACKEND_URL,\n debug: process.env.NODE_ENV === 'development',\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,\n});\n\nexport { sdk };\n"],"mappings":";;;AAEA,MAAM,6BAA6B;AAEnC,MAAM,MAAM,IAAI,OAAO;CACrB,SACE,QAAQ,IAAI,kCAAkC;CAChD,yBAAgC;CAChC,gBAAgB,QAAQ,IAAI;CAC7B,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/context/apollo-context.d.ts
|
|
5
5
|
declare function ApolloClientProvider({
|
|
6
6
|
children
|
|
7
|
-
}: PropsWithChildren):
|
|
7
|
+
}: PropsWithChildren): react_jsx_runtime8.JSX.Element;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ApolloClientProvider };
|
|
10
10
|
//# sourceMappingURL=apollo-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-context.d.ts","names":[],"sources":["../../../src/lib/context/apollo-context.tsx"],"sourcesContent":[],"mappings":";;;;iBAQS,oBAAA;;GAAmC,oBAAiB,
|
|
1
|
+
{"version":3,"file":"apollo-context.d.ts","names":[],"sources":["../../../src/lib/context/apollo-context.tsx"],"sourcesContent":[],"mappings":";;;;iBAQS,oBAAA;;GAAmC,oBAAiB,kBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -6,8 +6,9 @@ import { ApolloProvider } from "@apollo/client/react";
|
|
|
6
6
|
|
|
7
7
|
//#region src/lib/context/apollo-context.tsx
|
|
8
8
|
function ApolloClientProvider({ children }) {
|
|
9
|
+
const storedApolloClient = useApollo();
|
|
9
10
|
return /* @__PURE__ */ jsx(ApolloProvider, {
|
|
10
|
-
client:
|
|
11
|
+
client: storedApolloClient,
|
|
11
12
|
children
|
|
12
13
|
});
|
|
13
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apollo-context.js","names":[],"sources":["../../../src/lib/context/apollo-context.tsx"],"sourcesContent":["'use client';\n\nimport { PropsWithChildren } from 'react';\n\nimport { ApolloProvider } from '@apollo/client/react';\n\nimport { useApollo } from '@/lib/hooks/use-apollo';\n\nfunction ApolloClientProvider({ children }: PropsWithChildren) {\n const storedApolloClient = useApollo();\n\n return (\n <ApolloProvider client={storedApolloClient}>{children}</ApolloProvider>\n );\n}\n\nexport { ApolloClientProvider };\n"],"mappings":";;;;;;;AAQA,SAAS,qBAAqB,EAAE,YAA+B;
|
|
1
|
+
{"version":3,"file":"apollo-context.js","names":[],"sources":["../../../src/lib/context/apollo-context.tsx"],"sourcesContent":["'use client';\n\nimport { PropsWithChildren } from 'react';\n\nimport { ApolloProvider } from '@apollo/client/react';\n\nimport { useApollo } from '@/lib/hooks/use-apollo';\n\nfunction ApolloClientProvider({ children }: PropsWithChildren) {\n const storedApolloClient = useApollo();\n\n return (\n <ApolloProvider client={storedApolloClient}>{children}</ApolloProvider>\n );\n}\n\nexport { ApolloClientProvider };\n"],"mappings":";;;;;;;AAQA,SAAS,qBAAqB,EAAE,YAA+B;CAC7D,MAAM,qBAAqB,WAAW;AAEtC,QACE,oBAAC;EAAe,QAAQ;EAAqB;GAA0B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime13 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/context/modal-context.d.ts
|
|
5
5
|
interface ModalContext {
|
|
@@ -13,7 +13,7 @@ interface ModalProviderProps {
|
|
|
13
13
|
declare const ModalProvider: ({
|
|
14
14
|
children,
|
|
15
15
|
close
|
|
16
|
-
}: ModalProviderProps) =>
|
|
16
|
+
}: ModalProviderProps) => react_jsx_runtime13.JSX.Element;
|
|
17
17
|
declare const useModal: () => ModalContext;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { ModalProvider, useModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-context.d.ts","names":[],"sources":["../../../src/lib/context/modal-context.tsx"],"sourcesContent":[],"mappings":";;;;UAIU,YAAA;;;AAF+C,cAMnD,YAJgB,EAIJ,KAAA,CAAA,OAJI,CAIJ,YAJI,GAAA,IAAA,CAAA;AAAA,UAMZ,kBAAA,CAFmD;EAEnD,QAAA,CAAA,EACG,KAAA,CAAM,SADS;EAKtB,KAAA,EAAA,GAAA,GAAA,IAUL;;cAVK,aAAiB,EAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAqB,kBAArB,EAAA,GAAuC,
|
|
1
|
+
{"version":3,"file":"modal-context.d.ts","names":[],"sources":["../../../src/lib/context/modal-context.tsx"],"sourcesContent":[],"mappings":";;;;UAIU,YAAA;;;AAF+C,cAMnD,YAJgB,EAIJ,KAAA,CAAA,OAJI,CAIJ,YAJI,GAAA,IAAA,CAAA;AAAA,UAMZ,kBAAA,CAFmD;EAEnD,QAAA,CAAA,EACG,KAAA,CAAM,SADS;EAKtB,KAAA,EAAA,GAAA,GAAA,IAUL;;cAVK,aAAiB,EAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAqB,kBAArB,EAAA,GAAuC,mBAAA,CAAA,GAAA,CAAA,OAAvC;cAYjB,QAZsC,EAAA,GAAA,GAY9B,YAZ8B"}
|
|
@@ -13,7 +13,9 @@ const ModalProvider = ({ children, close }) => {
|
|
|
13
13
|
};
|
|
14
14
|
const useModal = () => {
|
|
15
15
|
const context = useContext(ModalContext);
|
|
16
|
-
if (context === null)
|
|
16
|
+
if (context === null) {
|
|
17
|
+
throw new Error("useModal must be used within a ModalProvider");
|
|
18
|
+
}
|
|
17
19
|
return context;
|
|
18
20
|
};
|
|
19
21
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-context.js","names":[],"sources":["../../../src/lib/context/modal-context.tsx"],"sourcesContent":["'use client';\n\nimport React, { createContext, useContext } from 'react';\n\ninterface ModalContext {\n close: () => void;\n}\n\nconst ModalContext = createContext<ModalContext | null>(null);\n\ninterface ModalProviderProps {\n children?: React.ReactNode;\n close: () => void;\n}\n\nconst ModalProvider = ({ children, close }: ModalProviderProps) => {\n return (\n <ModalContext.Provider\n value={{\n close,\n }}\n >\n {children}\n </ModalContext.Provider>\n );\n};\n\nconst useModal = () => {\n const context = useContext(ModalContext);\n if (context === null) {\n throw new Error('useModal must be used within a ModalProvider');\n }\n return context;\n};\n\nexport { ModalProvider, useModal };\n"],"mappings":";;;;;;AAQA,MAAM,eAAe,cAAmC,KAAK;AAO7D,MAAM,iBAAiB,EAAE,UAAU,YAAgC;AACjE,QACE,oBAAC,aAAa;EACZ,OAAO,EACL,OACD;EAEA;GACqB;;AAI5B,MAAM,iBAAiB;CACrB,MAAM,UAAU,WAAW,aAAa;AACxC,KAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"modal-context.js","names":[],"sources":["../../../src/lib/context/modal-context.tsx"],"sourcesContent":["'use client';\n\nimport React, { createContext, useContext } from 'react';\n\ninterface ModalContext {\n close: () => void;\n}\n\nconst ModalContext = createContext<ModalContext | null>(null);\n\ninterface ModalProviderProps {\n children?: React.ReactNode;\n close: () => void;\n}\n\nconst ModalProvider = ({ children, close }: ModalProviderProps) => {\n return (\n <ModalContext.Provider\n value={{\n close,\n }}\n >\n {children}\n </ModalContext.Provider>\n );\n};\n\nconst useModal = () => {\n const context = useContext(ModalContext);\n if (context === null) {\n throw new Error('useModal must be used within a ModalProvider');\n }\n return context;\n};\n\nexport { ModalProvider, useModal };\n"],"mappings":";;;;;;AAQA,MAAM,eAAe,cAAmC,KAAK;AAO7D,MAAM,iBAAiB,EAAE,UAAU,YAAgC;AACjE,QACE,oBAAC,aAAa;EACZ,OAAO,EACL,OACD;EAEA;GACqB;;AAI5B,MAAM,iBAAiB;CACrB,MAAM,UAAU,WAAW,aAAa;AACxC,KAAI,YAAY,MAAM;AACpB,QAAM,IAAI,MAAM,+CAA+C;;AAEjE,QAAO"}
|
package/dist/lib/data/cart.js
CHANGED
|
@@ -9,14 +9,17 @@ import { getCacheTag, getCartId } from "./cookies-utils.js";
|
|
|
9
9
|
//#region src/lib/data/cart.ts
|
|
10
10
|
const retrieveCart = async (ctx) => {
|
|
11
11
|
const id = getCartId(ctx);
|
|
12
|
-
if (!id)
|
|
12
|
+
if (!id) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
13
15
|
const cookieHeader = ctx.cookieHeader;
|
|
14
16
|
const apolloClient = createServerApolloClient(cookieHeader);
|
|
15
17
|
try {
|
|
16
|
-
|
|
18
|
+
const data = await graphqlFetch({
|
|
17
19
|
query: GET_CART_QUERY,
|
|
18
20
|
variables: { id }
|
|
19
|
-
}, apolloClient)
|
|
21
|
+
}, apolloClient);
|
|
22
|
+
return data?.cart ?? null;
|
|
20
23
|
} catch (error) {
|
|
21
24
|
console.error("Failed to fetch cart:", error);
|
|
22
25
|
return null;
|
|
@@ -24,21 +27,26 @@ const retrieveCart = async (ctx) => {
|
|
|
24
27
|
};
|
|
25
28
|
const updateCart = async (data, ctx) => {
|
|
26
29
|
const cartId = getCartId(ctx);
|
|
27
|
-
if (!cartId)
|
|
30
|
+
if (!cartId) {
|
|
31
|
+
throw new Error("No existing cart found, please create one before updating");
|
|
32
|
+
}
|
|
28
33
|
try {
|
|
29
|
-
const
|
|
34
|
+
const result = await graphqlMutation({
|
|
30
35
|
mutation: UPDATE_CART_MUTATION,
|
|
31
36
|
variables: {
|
|
32
37
|
id: cartId,
|
|
33
38
|
data
|
|
34
39
|
}
|
|
35
|
-
})
|
|
40
|
+
});
|
|
41
|
+
const cart = result?.updateCart ?? null;
|
|
36
42
|
if (cart) {
|
|
37
43
|
await mutateCart();
|
|
38
44
|
try {
|
|
39
45
|
const { revalidateTag } = await import("next/cache");
|
|
40
|
-
|
|
41
|
-
revalidateTag(
|
|
46
|
+
const cartCacheTag = getCacheTag("carts", ctx);
|
|
47
|
+
revalidateTag(cartCacheTag);
|
|
48
|
+
const fulfillmentCacheTag = getCacheTag("fulfillment", ctx);
|
|
49
|
+
revalidateTag(fulfillmentCacheTag);
|
|
42
50
|
} catch {}
|
|
43
51
|
}
|
|
44
52
|
return cart;
|
|
@@ -47,23 +55,30 @@ const updateCart = async (data, ctx) => {
|
|
|
47
55
|
}
|
|
48
56
|
};
|
|
49
57
|
const deleteLineItem = async (lineId, ctx) => {
|
|
50
|
-
if (!lineId)
|
|
58
|
+
if (!lineId) {
|
|
59
|
+
throw new Error("Missing lineItem ID when deleting line item");
|
|
60
|
+
}
|
|
51
61
|
const cartId = getCartId(ctx);
|
|
52
|
-
if (!cartId)
|
|
62
|
+
if (!cartId) {
|
|
63
|
+
throw new Error("Missing cart ID when deleting line item");
|
|
64
|
+
}
|
|
53
65
|
try {
|
|
54
|
-
const
|
|
66
|
+
const result = await graphqlMutation({
|
|
55
67
|
mutation: DELETE_LINE_ITEM_MUTATION,
|
|
56
68
|
variables: {
|
|
57
69
|
cartId,
|
|
58
70
|
lineItemId: lineId
|
|
59
71
|
}
|
|
60
|
-
})
|
|
72
|
+
});
|
|
73
|
+
const deletedLineItem = result?.deleteLineItem ?? null;
|
|
61
74
|
if (deletedLineItem) {
|
|
62
75
|
await mutateCart();
|
|
63
76
|
try {
|
|
64
77
|
const { revalidateTag } = await import("next/cache");
|
|
65
|
-
|
|
66
|
-
revalidateTag(
|
|
78
|
+
const cartCacheTag = getCacheTag("carts", ctx);
|
|
79
|
+
revalidateTag(cartCacheTag);
|
|
80
|
+
const fulfillmentCacheTag = getCacheTag("fulfillment", ctx);
|
|
81
|
+
revalidateTag(fulfillmentCacheTag);
|
|
67
82
|
} catch {}
|
|
68
83
|
}
|
|
69
84
|
return deletedLineItem;
|
|
@@ -74,13 +89,16 @@ const deleteLineItem = async (lineId, ctx) => {
|
|
|
74
89
|
};
|
|
75
90
|
async function listCartOptions(ctx) {
|
|
76
91
|
const cartId = getCartId(ctx);
|
|
77
|
-
if (!cartId)
|
|
92
|
+
if (!cartId) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
78
95
|
const apolloClient = createServerApolloClient(ctx.cookieHeader);
|
|
79
96
|
try {
|
|
80
|
-
|
|
97
|
+
const data = await graphqlFetch({
|
|
81
98
|
query: GET_SHIPPING_OPTIONS_QUERY,
|
|
82
99
|
variables: { cartId }
|
|
83
|
-
}, apolloClient)
|
|
100
|
+
}, apolloClient);
|
|
101
|
+
return data?.shippingOptions?.filter(Boolean) ?? null;
|
|
84
102
|
} catch {
|
|
85
103
|
return null;
|
|
86
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.js","names":["error: any"],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":["import {\n Cart,\n DeleteLineItemMutation,\n DeleteLineItemMutationVariables,\n GetCartQuery,\n GetCartQueryVariables,\n GetShippingOptionsQuery,\n GetShippingOptionsQueryVariables,\n ShippingOption,\n UpdateCartMutation,\n UpdateCartMutationVariables,\n} from '../../types/graphql';\nimport {\n createServerApolloClient,\n graphqlFetch,\n graphqlMutation,\n} from '../gql/apollo-client';\nimport {\n DELETE_LINE_ITEM_MUTATION,\n UPDATE_CART_MUTATION,\n} from '../gql/mutations/cart';\nimport { GET_CART_QUERY } from '../gql/queries/cart';\nimport { GET_SHIPPING_OPTIONS_QUERY } from '../gql/queries/shipping';\nimport { mutateCart } from '../hooks/use-cart';\nimport { medusaError } from '../utils/medusa-error';\nimport type { StorefrontContext } from './context';\nimport { getCacheTag, getCartId } from './cookies-utils';\n\nexport const retrieveCart = async (\n ctx: StorefrontContext\n): Promise<Cart | null> => {\n const id = getCartId(ctx);\n if (!id) {\n return null;\n }\n\n const cookieHeader = ctx.cookieHeader;\n const apolloClient = createServerApolloClient(cookieHeader);\n\n try {\n const data = await graphqlFetch<GetCartQuery, GetCartQueryVariables>(\n {\n query: GET_CART_QUERY,\n variables: { id },\n },\n apolloClient\n );\n\n return data?.cart ?? null;\n } catch (error) {\n console.error('Failed to fetch cart:', error);\n return null;\n }\n};\n\nexport const updateCart = async (\n data: UpdateCartMutationVariables['data'],\n ctx: StorefrontContext\n): Promise<UpdateCartMutation['updateCart'] | null> => {\n const cartId = getCartId(ctx);\n\n if (!cartId) {\n throw new Error(\n 'No existing cart found, please create one before updating'\n );\n }\n\n try {\n const result = await graphqlMutation<\n UpdateCartMutation,\n UpdateCartMutationVariables\n >({\n mutation: UPDATE_CART_MUTATION,\n variables: {\n id: cartId,\n data,\n },\n });\n\n const cart = result?.updateCart ?? null;\n\n if (cart) {\n await mutateCart();\n try {\n const { revalidateTag } = await import('next/cache');\n const cartCacheTag = getCacheTag('carts', ctx);\n revalidateTag(cartCacheTag);\n\n const fulfillmentCacheTag = getCacheTag('fulfillment', ctx);\n revalidateTag(fulfillmentCacheTag);\n } catch {\n // Not in Next.js environment\n }\n }\n\n return cart;\n } catch (err) {\n medusaError(err);\n }\n};\n\nexport const deleteLineItem = async (\n lineId: string,\n ctx: StorefrontContext\n): Promise<DeleteLineItemMutation['deleteLineItem'] | null> => {\n if (!lineId) {\n throw new Error('Missing lineItem ID when deleting line item');\n }\n\n const cartId = getCartId(ctx);\n\n if (!cartId) {\n throw new Error('Missing cart ID when deleting line item');\n }\n\n try {\n const result = await graphqlMutation<\n DeleteLineItemMutation,\n DeleteLineItemMutationVariables\n >({\n mutation: DELETE_LINE_ITEM_MUTATION,\n variables: {\n cartId,\n lineItemId: lineId,\n },\n });\n\n const deletedLineItem = result?.deleteLineItem ?? null;\n\n if (deletedLineItem) {\n await mutateCart();\n try {\n const { revalidateTag } = await import('next/cache');\n const cartCacheTag = getCacheTag('carts', ctx);\n revalidateTag(cartCacheTag);\n\n const fulfillmentCacheTag = getCacheTag('fulfillment', ctx);\n revalidateTag(fulfillmentCacheTag);\n } catch {\n // Not in Next.js environment\n }\n }\n\n return deletedLineItem;\n } catch (error: any) {\n console.error('GraphQL deleteLineItem error:', error.message);\n throw error;\n }\n};\n\nexport async function listCartOptions(\n ctx: StorefrontContext\n): Promise<ShippingOption[] | null> {\n const cartId = getCartId(ctx);\n if (!cartId) {\n return null;\n }\n const apolloClient = createServerApolloClient(ctx.cookieHeader);\n try {\n const data = await graphqlFetch<\n GetShippingOptionsQuery,\n GetShippingOptionsQueryVariables\n >(\n { query: GET_SHIPPING_OPTIONS_QUERY, variables: { cartId } },\n apolloClient\n );\n return (data?.shippingOptions?.filter(Boolean) as ShippingOption[]) ?? null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AA4BA,MAAa,eAAe,OAC1B,QACyB;CACzB,MAAM,KAAK,UAAU,IAAI;AACzB,KAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"cart.js","names":["error: any"],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":["import {\n Cart,\n DeleteLineItemMutation,\n DeleteLineItemMutationVariables,\n GetCartQuery,\n GetCartQueryVariables,\n GetShippingOptionsQuery,\n GetShippingOptionsQueryVariables,\n ShippingOption,\n UpdateCartMutation,\n UpdateCartMutationVariables,\n} from '../../types/graphql';\nimport {\n createServerApolloClient,\n graphqlFetch,\n graphqlMutation,\n} from '../gql/apollo-client';\nimport {\n DELETE_LINE_ITEM_MUTATION,\n UPDATE_CART_MUTATION,\n} from '../gql/mutations/cart';\nimport { GET_CART_QUERY } from '../gql/queries/cart';\nimport { GET_SHIPPING_OPTIONS_QUERY } from '../gql/queries/shipping';\nimport { mutateCart } from '../hooks/use-cart';\nimport { medusaError } from '../utils/medusa-error';\nimport type { StorefrontContext } from './context';\nimport { getCacheTag, getCartId } from './cookies-utils';\n\nexport const retrieveCart = async (\n ctx: StorefrontContext\n): Promise<Cart | null> => {\n const id = getCartId(ctx);\n if (!id) {\n return null;\n }\n\n const cookieHeader = ctx.cookieHeader;\n const apolloClient = createServerApolloClient(cookieHeader);\n\n try {\n const data = await graphqlFetch<GetCartQuery, GetCartQueryVariables>(\n {\n query: GET_CART_QUERY,\n variables: { id },\n },\n apolloClient\n );\n\n return data?.cart ?? null;\n } catch (error) {\n console.error('Failed to fetch cart:', error);\n return null;\n }\n};\n\nexport const updateCart = async (\n data: UpdateCartMutationVariables['data'],\n ctx: StorefrontContext\n): Promise<UpdateCartMutation['updateCart'] | null> => {\n const cartId = getCartId(ctx);\n\n if (!cartId) {\n throw new Error(\n 'No existing cart found, please create one before updating'\n );\n }\n\n try {\n const result = await graphqlMutation<\n UpdateCartMutation,\n UpdateCartMutationVariables\n >({\n mutation: UPDATE_CART_MUTATION,\n variables: {\n id: cartId,\n data,\n },\n });\n\n const cart = result?.updateCart ?? null;\n\n if (cart) {\n await mutateCart();\n try {\n const { revalidateTag } = await import('next/cache');\n const cartCacheTag = getCacheTag('carts', ctx);\n revalidateTag(cartCacheTag);\n\n const fulfillmentCacheTag = getCacheTag('fulfillment', ctx);\n revalidateTag(fulfillmentCacheTag);\n } catch {\n // Not in Next.js environment\n }\n }\n\n return cart;\n } catch (err) {\n medusaError(err);\n }\n};\n\nexport const deleteLineItem = async (\n lineId: string,\n ctx: StorefrontContext\n): Promise<DeleteLineItemMutation['deleteLineItem'] | null> => {\n if (!lineId) {\n throw new Error('Missing lineItem ID when deleting line item');\n }\n\n const cartId = getCartId(ctx);\n\n if (!cartId) {\n throw new Error('Missing cart ID when deleting line item');\n }\n\n try {\n const result = await graphqlMutation<\n DeleteLineItemMutation,\n DeleteLineItemMutationVariables\n >({\n mutation: DELETE_LINE_ITEM_MUTATION,\n variables: {\n cartId,\n lineItemId: lineId,\n },\n });\n\n const deletedLineItem = result?.deleteLineItem ?? null;\n\n if (deletedLineItem) {\n await mutateCart();\n try {\n const { revalidateTag } = await import('next/cache');\n const cartCacheTag = getCacheTag('carts', ctx);\n revalidateTag(cartCacheTag);\n\n const fulfillmentCacheTag = getCacheTag('fulfillment', ctx);\n revalidateTag(fulfillmentCacheTag);\n } catch {\n // Not in Next.js environment\n }\n }\n\n return deletedLineItem;\n } catch (error: any) {\n console.error('GraphQL deleteLineItem error:', error.message);\n throw error;\n }\n};\n\nexport async function listCartOptions(\n ctx: StorefrontContext\n): Promise<ShippingOption[] | null> {\n const cartId = getCartId(ctx);\n if (!cartId) {\n return null;\n }\n const apolloClient = createServerApolloClient(ctx.cookieHeader);\n try {\n const data = await graphqlFetch<\n GetShippingOptionsQuery,\n GetShippingOptionsQueryVariables\n >(\n { query: GET_SHIPPING_OPTIONS_QUERY, variables: { cartId } },\n apolloClient\n );\n return (data?.shippingOptions?.filter(Boolean) as ShippingOption[]) ?? null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AA4BA,MAAa,eAAe,OAC1B,QACyB;CACzB,MAAM,KAAK,UAAU,IAAI;AACzB,KAAI,CAAC,IAAI;AACP,SAAO;;CAGT,MAAM,eAAe,IAAI;CACzB,MAAM,eAAe,yBAAyB,aAAa;AAE3D,KAAI;EACF,MAAM,OAAO,MAAM,aACjB;GACE,OAAO;GACP,WAAW,EAAE,IAAI;GAClB,EACD,aACD;AAED,SAAO,MAAM,QAAQ;UACd,OAAO;AACd,UAAQ,MAAM,yBAAyB,MAAM;AAC7C,SAAO;;;AAIX,MAAa,aAAa,OACxB,MACA,QACqD;CACrD,MAAM,SAAS,UAAU,IAAI;AAE7B,KAAI,CAAC,QAAQ;AACX,QAAM,IAAI,MACR,4DACD;;AAGH,KAAI;EACF,MAAM,SAAS,MAAM,gBAGnB;GACA,UAAU;GACV,WAAW;IACT,IAAI;IACJ;IACD;GACF,CAAC;EAEF,MAAM,OAAO,QAAQ,cAAc;AAEnC,MAAI,MAAM;AACR,SAAM,YAAY;AAClB,OAAI;IACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;IACvC,MAAM,eAAe,YAAY,SAAS,IAAI;AAC9C,kBAAc,aAAa;IAE3B,MAAM,sBAAsB,YAAY,eAAe,IAAI;AAC3D,kBAAc,oBAAoB;WAC5B;;AAKV,SAAO;UACA,KAAK;AACZ,cAAY,IAAI;;;AAIpB,MAAa,iBAAiB,OAC5B,QACA,QAC6D;AAC7D,KAAI,CAAC,QAAQ;AACX,QAAM,IAAI,MAAM,8CAA8C;;CAGhE,MAAM,SAAS,UAAU,IAAI;AAE7B,KAAI,CAAC,QAAQ;AACX,QAAM,IAAI,MAAM,0CAA0C;;AAG5D,KAAI;EACF,MAAM,SAAS,MAAM,gBAGnB;GACA,UAAU;GACV,WAAW;IACT;IACA,YAAY;IACb;GACF,CAAC;EAEF,MAAM,kBAAkB,QAAQ,kBAAkB;AAElD,MAAI,iBAAiB;AACnB,SAAM,YAAY;AAClB,OAAI;IACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;IACvC,MAAM,eAAe,YAAY,SAAS,IAAI;AAC9C,kBAAc,aAAa;IAE3B,MAAM,sBAAsB,YAAY,eAAe,IAAI;AAC3D,kBAAc,oBAAoB;WAC5B;;AAKV,SAAO;UACAA,OAAY;AACnB,UAAQ,MAAM,iCAAiC,MAAM,QAAQ;AAC7D,QAAM;;;AAIV,eAAsB,gBACpB,KACkC;CAClC,MAAM,SAAS,UAAU,IAAI;AAC7B,KAAI,CAAC,QAAQ;AACX,SAAO;;CAET,MAAM,eAAe,yBAAyB,IAAI,aAAa;AAC/D,KAAI;EACF,MAAM,OAAO,MAAM,aAIjB;GAAE,OAAO;GAA4B,WAAW,EAAE,QAAQ;GAAE,EAC5D,aACD;AACD,SAAQ,MAAM,iBAAiB,OAAO,QAAQ,IAAyB;SACjE;AACN,SAAO"}
|
|
@@ -4,7 +4,8 @@ import { GET_PRODUCT_CATEGORIES_QUERY } from "../gql/queries/product.js";
|
|
|
4
4
|
//#region src/lib/data/categories.ts
|
|
5
5
|
const listCategories = async () => {
|
|
6
6
|
try {
|
|
7
|
-
|
|
7
|
+
const data = await graphqlFetch({ query: GET_PRODUCT_CATEGORIES_QUERY });
|
|
8
|
+
return data?.productCategories || [];
|
|
8
9
|
} catch (error) {
|
|
9
10
|
console.error("Error fetching categories from BFF:", error);
|
|
10
11
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"categories.js","names":[],"sources":["../../../src/lib/data/categories.ts"],"sourcesContent":["import { graphqlFetch } from '@/lib/gql/apollo-client';\nimport { GET_PRODUCT_CATEGORIES_QUERY } from '@/lib/gql/queries/product';\nimport {\n GetProductCategoriesQuery,\n GetProductCategoriesQueryVariables,\n} from '@/types/graphql';\n\nexport const listCategories = async () => {\n try {\n const data = await graphqlFetch<\n GetProductCategoriesQuery,\n GetProductCategoriesQueryVariables\n >({\n query: GET_PRODUCT_CATEGORIES_QUERY,\n });\n\n return data?.productCategories || [];\n } catch (error) {\n console.error('Error fetching categories from BFF:', error);\n return [];\n }\n};\n"],"mappings":";;;;AAOA,MAAa,iBAAiB,YAAY;AACxC,KAAI;
|
|
1
|
+
{"version":3,"file":"categories.js","names":[],"sources":["../../../src/lib/data/categories.ts"],"sourcesContent":["import { graphqlFetch } from '@/lib/gql/apollo-client';\nimport { GET_PRODUCT_CATEGORIES_QUERY } from '@/lib/gql/queries/product';\nimport {\n GetProductCategoriesQuery,\n GetProductCategoriesQueryVariables,\n} from '@/types/graphql';\n\nexport const listCategories = async () => {\n try {\n const data = await graphqlFetch<\n GetProductCategoriesQuery,\n GetProductCategoriesQueryVariables\n >({\n query: GET_PRODUCT_CATEGORIES_QUERY,\n });\n\n return data?.productCategories || [];\n } catch (error) {\n console.error('Error fetching categories from BFF:', error);\n return [];\n }\n};\n"],"mappings":";;;;AAOA,MAAa,iBAAiB,YAAY;AACxC,KAAI;EACF,MAAM,OAAO,MAAM,aAGjB,EACA,OAAO,8BACR,CAAC;AAEF,SAAO,MAAM,qBAAqB,EAAE;UAC7B,OAAO;AACd,UAAQ,MAAM,uCAAuC,MAAM;AAC3D,SAAO,EAAE"}
|
|
@@ -8,8 +8,13 @@ import { getRegion } from "./regions.js";
|
|
|
8
8
|
//#region src/lib/data/client-actions.tsx
|
|
9
9
|
async function updateRegion(countryCode, currentPath, ctx) {
|
|
10
10
|
const region = await getRegion(countryCode, ctx);
|
|
11
|
-
if (!region)
|
|
12
|
-
|
|
11
|
+
if (!region) {
|
|
12
|
+
throw new Error(`Region not found for country code: ${countryCode}`);
|
|
13
|
+
}
|
|
14
|
+
const cartId = getCartId(ctx);
|
|
15
|
+
if (cartId) {
|
|
16
|
+
await updateCart({ regionId: region.id }, ctx);
|
|
17
|
+
}
|
|
13
18
|
window.location.href = `/${countryCode}${currentPath}`;
|
|
14
19
|
}
|
|
15
20
|
const useStorefrontActions = (ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-actions.js","names":[],"sources":["../../../src/lib/data/client-actions.tsx"],"sourcesContent":["'use client';\n\nimport { updateCart } from './cart';\nimport { StorefrontContext } from './context';\nimport {\n removeAuthTokenAction,\n removeCartIdAction,\n setAuthTokenAction,\n setCartIdAction,\n} from './cookies-actions';\nimport { getCartId } from './cookies-utils';\nimport { getRegion } from './regions';\n\nasync function updateRegion(\n countryCode: string,\n currentPath: string,\n ctx: StorefrontContext\n) {\n const region = await getRegion(countryCode, ctx);\n\n if (!region) {\n throw new Error(`Region not found for country code: ${countryCode}`);\n }\n\n const cartId = getCartId(ctx);\n if (cartId) {\n await updateCart({ regionId: region.id }, ctx);\n }\n\n window.location.href = `/${countryCode}${currentPath}`;\n}\n\nexport const useStorefrontActions = (ctx?: StorefrontContext) => {\n return {\n setCartId: setCartIdAction,\n removeCartId: removeCartIdAction,\n setAuthToken: setAuthTokenAction,\n removeAuthToken: removeAuthTokenAction,\n updateRegion: ((countryCode: string, currentPath: string) =>\n updateRegion(countryCode, currentPath, ctx!)) as (\n countryCode: string,\n currentPath: string\n ) => Promise<void>,\n };\n};\n"],"mappings":";;;;;;;;AAaA,eAAe,aACb,aACA,aACA,KACA;CACA,MAAM,SAAS,MAAM,UAAU,aAAa,IAAI;AAEhD,KAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"client-actions.js","names":[],"sources":["../../../src/lib/data/client-actions.tsx"],"sourcesContent":["'use client';\n\nimport { updateCart } from './cart';\nimport { StorefrontContext } from './context';\nimport {\n removeAuthTokenAction,\n removeCartIdAction,\n setAuthTokenAction,\n setCartIdAction,\n} from './cookies-actions';\nimport { getCartId } from './cookies-utils';\nimport { getRegion } from './regions';\n\nasync function updateRegion(\n countryCode: string,\n currentPath: string,\n ctx: StorefrontContext\n) {\n const region = await getRegion(countryCode, ctx);\n\n if (!region) {\n throw new Error(`Region not found for country code: ${countryCode}`);\n }\n\n const cartId = getCartId(ctx);\n if (cartId) {\n await updateCart({ regionId: region.id }, ctx);\n }\n\n window.location.href = `/${countryCode}${currentPath}`;\n}\n\nexport const useStorefrontActions = (ctx?: StorefrontContext) => {\n return {\n setCartId: setCartIdAction,\n removeCartId: removeCartIdAction,\n setAuthToken: setAuthTokenAction,\n removeAuthToken: removeAuthTokenAction,\n updateRegion: ((countryCode: string, currentPath: string) =>\n updateRegion(countryCode, currentPath, ctx!)) as (\n countryCode: string,\n currentPath: string\n ) => Promise<void>,\n };\n};\n"],"mappings":";;;;;;;;AAaA,eAAe,aACb,aACA,aACA,KACA;CACA,MAAM,SAAS,MAAM,UAAU,aAAa,IAAI;AAEhD,KAAI,CAAC,QAAQ;AACX,QAAM,IAAI,MAAM,sCAAsC,cAAc;;CAGtE,MAAM,SAAS,UAAU,IAAI;AAC7B,KAAI,QAAQ;AACV,QAAM,WAAW,EAAE,UAAU,OAAO,IAAI,EAAE,IAAI;;AAGhD,QAAO,SAAS,OAAO,IAAI,cAAc;;AAG3C,MAAa,wBAAwB,QAA4B;AAC/D,QAAO;EACL,WAAW;EACX,cAAc;EACd,cAAc;EACd,iBAAiB;EACjB,gBAAgB,aAAqB,gBACnC,aAAa,aAAa,aAAa,IAAK;EAI/C"}
|
|
@@ -6,13 +6,16 @@ import { GET_COLLECTIONS_HOME_QUERY } from "../gql/queries/collections.js";
|
|
|
6
6
|
//#region src/lib/data/collections.ts
|
|
7
7
|
const listCollections = async (queryParams = {}) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
const limit = parseInt(queryParams.limit || "50");
|
|
10
|
+
const offset = parseInt(queryParams.offset || "0");
|
|
11
|
+
const data = await graphqlFetch({
|
|
10
12
|
query: GET_COLLECTIONS_HOME_QUERY,
|
|
11
13
|
variables: {
|
|
12
|
-
limit
|
|
13
|
-
offset
|
|
14
|
+
limit,
|
|
15
|
+
offset
|
|
14
16
|
}
|
|
15
|
-
})
|
|
17
|
+
});
|
|
18
|
+
return { collections: data?.collections };
|
|
16
19
|
} catch (error) {
|
|
17
20
|
console.error("Error fetching collections from BFF:", error);
|
|
18
21
|
return { collections: [] };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","names":[],"sources":["../../../src/lib/data/collections.ts"],"sourcesContent":["'use server';\n\nimport { graphqlFetch } from '@/lib/gql/apollo-client';\nimport { GET_COLLECTIONS_HOME_QUERY } from '@/lib/gql/queries/collections';\nimport {\n GetCollectionsQuery,\n GetCollectionsQueryVariables,\n} from '@/types/graphql';\n\nexport const listCollections = async (\n queryParams: Record<string, string> = {}\n) => {\n try {\n const limit = parseInt(queryParams.limit || '50');\n const offset = parseInt(queryParams.offset || '0');\n\n const data = await graphqlFetch<\n GetCollectionsQuery,\n GetCollectionsQueryVariables\n >({\n query: GET_COLLECTIONS_HOME_QUERY,\n variables: { limit, offset },\n });\n\n return {\n collections: data?.collections,\n };\n } catch (error) {\n console.error('Error fetching collections from BFF:', error);\n return { collections: [] };\n }\n};\n"],"mappings":";;;;;;AASA,MAAa,kBAAkB,OAC7B,cAAsC,EAAE,KACrC;AACH,KAAI;
|
|
1
|
+
{"version":3,"file":"collections.js","names":[],"sources":["../../../src/lib/data/collections.ts"],"sourcesContent":["'use server';\n\nimport { graphqlFetch } from '@/lib/gql/apollo-client';\nimport { GET_COLLECTIONS_HOME_QUERY } from '@/lib/gql/queries/collections';\nimport {\n GetCollectionsQuery,\n GetCollectionsQueryVariables,\n} from '@/types/graphql';\n\nexport const listCollections = async (\n queryParams: Record<string, string> = {}\n) => {\n try {\n const limit = parseInt(queryParams.limit || '50');\n const offset = parseInt(queryParams.offset || '0');\n\n const data = await graphqlFetch<\n GetCollectionsQuery,\n GetCollectionsQueryVariables\n >({\n query: GET_COLLECTIONS_HOME_QUERY,\n variables: { limit, offset },\n });\n\n return {\n collections: data?.collections,\n };\n } catch (error) {\n console.error('Error fetching collections from BFF:', error);\n return { collections: [] };\n }\n};\n"],"mappings":";;;;;;AASA,MAAa,kBAAkB,OAC7B,cAAsC,EAAE,KACrC;AACH,KAAI;EACF,MAAM,QAAQ,SAAS,YAAY,SAAS,KAAK;EACjD,MAAM,SAAS,SAAS,YAAY,UAAU,IAAI;EAElD,MAAM,OAAO,MAAM,aAGjB;GACA,OAAO;GACP,WAAW;IAAE;IAAO;IAAQ;GAC7B,CAAC;AAEF,SAAO,EACL,aAAa,MAAM,aACpB;UACM,OAAO;AACd,UAAQ,MAAM,wCAAwC,MAAM;AAC5D,SAAO,EAAE,aAAa,EAAE,EAAE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useStorefrontActions } from "./client-actions.js";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/data/context.d.ts
|
|
6
6
|
interface StorefrontContext {
|
|
@@ -15,7 +15,7 @@ interface StorefrontProviderProps {
|
|
|
15
15
|
declare const StorefrontProvider: ({
|
|
16
16
|
children,
|
|
17
17
|
value
|
|
18
|
-
}: StorefrontProviderProps) =>
|
|
18
|
+
}: StorefrontProviderProps) => react_jsx_runtime6.JSX.Element;
|
|
19
19
|
declare const useStorefrontContext: () => StorefrontContext;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { StorefrontContext, StorefrontProvider, useStorefrontActions, useStorefrontContext };
|
package/dist/lib/data/context.js
CHANGED
|
@@ -12,7 +12,9 @@ const StorefrontReactContext = createContext({
|
|
|
12
12
|
});
|
|
13
13
|
const fetchContext = async () => {
|
|
14
14
|
const response = await fetch("/api/horz/context", { credentials: "include" });
|
|
15
|
-
if (!response.ok)
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error("Failed to fetch context");
|
|
17
|
+
}
|
|
16
18
|
return response.json();
|
|
17
19
|
};
|
|
18
20
|
const StorefrontProvider = ({ children, value }) => {
|