@gfed-medusa/sf-lib-common 2.4.0 → 3.0.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/dist/components/breadcrumbs/index.d.ts +2 -2
- 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/delete-button/index.d.ts +2 -2
- package/dist/components/error-message/index.d.ts +2 -2
- package/dist/components/error-message/index.d.ts.map +1 -1
- package/dist/components/free-shipping-price-nudge/index.d.ts +4 -5
- package/dist/components/free-shipping-price-nudge/index.d.ts.map +1 -1
- package/dist/components/free-shipping-price-nudge/index.js +3 -3
- package/dist/components/free-shipping-price-nudge/index.js.map +1 -1
- package/dist/components/interactive-link/index.d.ts +2 -2
- package/dist/components/interactive-link/index.d.ts.map +1 -1
- package/dist/components/line-item-options/index.d.ts +2 -2
- package/dist/components/line-item-options/index.d.ts.map +1 -1
- package/dist/components/line-item-price/index.d.ts +2 -2
- package/dist/components/line-item-price/index.d.ts.map +1 -1
- package/dist/components/localized-client-link/index.d.ts +2 -2
- package/dist/components/preview-price/index.d.ts +2 -2
- package/dist/components/product-card/index.d.ts +2 -2
- package/dist/components/product-preview/index.d.ts +2 -2
- package/dist/components/submit-button/index.d.ts +2 -2
- 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/modal-context.d.ts +2 -2
- package/dist/lib/context/modal-context.d.ts.map +1 -1
- package/dist/lib/data/cart.d.ts +2 -5
- package/dist/lib/data/cart.d.ts.map +1 -1
- package/dist/lib/data/cart.js +12 -8
- package/dist/lib/data/cart.js.map +1 -1
- package/dist/lib/data/context.d.ts +2 -2
- package/dist/lib/data/context.d.ts.map +1 -1
- package/dist/lib/data/footer.d.ts +2 -59
- package/dist/lib/data/footer.d.ts.map +1 -1
- package/dist/lib/data/orders.d.ts +1 -1
- package/dist/lib/data/orders.d.ts.map +1 -1
- package/dist/lib/data/orders.js +12 -11
- package/dist/lib/data/orders.js.map +1 -1
- package/dist/lib/data/regions.d.ts +2 -1
- package/dist/lib/data/regions.d.ts.map +1 -1
- package/dist/lib/data/regions.js +17 -11
- package/dist/lib/data/regions.js.map +1 -1
- package/dist/lib/globals/expose-globals.js +1 -1
- package/dist/lib/gql/fragments/cart.d.ts +9 -9
- package/dist/lib/gql/fragments/cart.d.ts.map +1 -1
- package/dist/lib/gql/fragments/customer.d.ts +3 -3
- package/dist/lib/gql/fragments/product.d.ts +8 -8
- package/dist/lib/gql/mutations/cart.d.ts +7 -5
- package/dist/lib/gql/mutations/cart.d.ts.map +1 -1
- package/dist/lib/gql/mutations/cart.js +22 -2
- package/dist/lib/gql/mutations/cart.js.map +1 -1
- package/dist/lib/gql/queries/cart.d.ts +2 -2
- package/dist/lib/gql/queries/collections.d.ts +2 -2
- package/dist/lib/gql/queries/customer.d.ts +2 -2
- package/dist/lib/gql/queries/footer.d.ts +2 -2
- package/dist/lib/gql/queries/footer.d.ts.map +1 -1
- package/dist/lib/gql/queries/order.d.ts +9 -0
- package/dist/lib/gql/queries/order.d.ts.map +1 -0
- package/dist/lib/gql/queries/order.js +103 -0
- package/dist/lib/gql/queries/order.js.map +1 -0
- package/dist/lib/gql/queries/product.d.ts +3 -3
- package/dist/lib/gql/queries/regions.d.ts +8 -0
- package/dist/lib/gql/queries/regions.d.ts.map +1 -0
- package/dist/lib/gql/queries/regions.js +39 -0
- package/dist/lib/gql/queries/regions.js.map +1 -0
- package/dist/lib/gql/queries/shipping.d.ts +8 -0
- package/dist/lib/gql/queries/shipping.d.ts.map +1 -0
- package/dist/lib/gql/queries/shipping.js +48 -0
- package/dist/lib/gql/queries/shipping.js.map +1 -0
- package/dist/types/cms.d.ts +85 -0
- package/dist/types/cms.d.ts.map +1 -0
- package/dist/types/cms.js +0 -0
- package/dist/types/graphql.d.ts +466 -481
- package/dist/types/graphql.d.ts.map +1 -1
- package/dist/types/graphql.js +3736 -7495
- package/dist/types/graphql.js.map +1 -1
- package/dist/types/prices.d.ts +5 -2
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/breadcrumbs/index.d.ts
|
|
4
4
|
declare const SEPARATOR_ICONS: Record<string, React.ComponentType<{
|
|
@@ -14,7 +14,7 @@ declare function Breadcrumbs({
|
|
|
14
14
|
iconClassName,
|
|
15
15
|
iconSize,
|
|
16
16
|
separatorIcon
|
|
17
|
-
}: BreadcrumbsProps):
|
|
17
|
+
}: BreadcrumbsProps): react_jsx_runtime8.JSX.Element;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { Breadcrumbs };
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Cart, Customer } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime9 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/cart-mismatch-banner/index.d.ts
|
|
5
5
|
declare function CartMismatchBanner(props: {
|
|
6
6
|
customer: Customer;
|
|
7
7
|
cart: Cart;
|
|
8
|
-
}):
|
|
8
|
+
}): react_jsx_runtime9.JSX.Element | undefined;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { CartMismatchBanner };
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAYS,kBAAA;YAAsC;EAAtC,IAAA,EAAsD,IAAtD;CAAsC,CAAA,EAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/cart-mismatch-banner/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAYS,kBAAA;YAAsC;EAAtC,IAAA,EAAsD,IAAtD;CAAsC,CAAA,EAAsB,kBAAA,CAAA,GAAA,CAAA,OAAA,GAAtB,SAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime15 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/delete-button/index.d.ts
|
|
4
4
|
declare const DeleteButton: ({
|
|
@@ -9,7 +9,7 @@ declare const DeleteButton: ({
|
|
|
9
9
|
id: string;
|
|
10
10
|
children?: React.ReactNode;
|
|
11
11
|
className?: string;
|
|
12
|
-
}) =>
|
|
12
|
+
}) => react_jsx_runtime15.JSX.Element;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { DeleteButton };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime12 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/error-message/index.d.ts
|
|
4
4
|
declare const ErrorMessage: ({
|
|
@@ -7,7 +7,7 @@ declare const ErrorMessage: ({
|
|
|
7
7
|
}: {
|
|
8
8
|
error?: string | null;
|
|
9
9
|
"data-testid"?: string;
|
|
10
|
-
}) =>
|
|
10
|
+
}) => react_jsx_runtime12.JSX.Element | null;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { ErrorMessage };
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":[],"mappings":";;;cAAM;;iBAAgB;AAMrB;;;AAAA,CAAA,EAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/error-message/index.tsx"],"sourcesContent":[],"mappings":";;;cAAM;;iBAAgB;AAMrB;;;AAAA,CAAA,EAAA,GAAA,mBAAA,CAAA,GAAA,CAAA,OAAA,GAaA,IAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Cart } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
3
|
-
import { StoreCartShippingOption } from "@medusajs/types";
|
|
1
|
+
import { Cart, ShippingOption } from "../../types/graphql.js";
|
|
2
|
+
import * as react_jsx_runtime13 from "react/jsx-runtime";
|
|
4
3
|
|
|
5
4
|
//#region src/components/free-shipping-price-nudge/index.d.ts
|
|
6
5
|
declare function ShippingPriceNudge({
|
|
@@ -10,8 +9,8 @@ declare function ShippingPriceNudge({
|
|
|
10
9
|
}: {
|
|
11
10
|
variant?: 'popup' | 'inline';
|
|
12
11
|
cart: Cart;
|
|
13
|
-
shippingOptions:
|
|
14
|
-
}):
|
|
12
|
+
shippingOptions: ShippingOption[];
|
|
13
|
+
}): react_jsx_runtime13.JSX.Element | undefined;
|
|
15
14
|
//#endregion
|
|
16
15
|
export { ShippingPriceNudge };
|
|
17
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/free-shipping-price-nudge/index.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/free-shipping-price-nudge/index.tsx"],"sourcesContent":[],"mappings":";;;;iBAqES,kBAAA;;;;;;QAMD;EANC,eAAA,EAOU,cAPQ,EAAA;CACzB,CAAA,EAOD,mBAAA,CAAA,GAAA,CAAA,OAAA,GAPC,SAAA"}
|
|
@@ -9,7 +9,7 @@ import { Button, clx } from "@medusajs/ui";
|
|
|
9
9
|
|
|
10
10
|
//#region src/components/free-shipping-price-nudge/index.tsx
|
|
11
11
|
const computeTarget = (cart, price) => {
|
|
12
|
-
const priceRule = (price.
|
|
12
|
+
const priceRule = (price.priceRules || []).find((pr) => pr?.attribute === "item_total");
|
|
13
13
|
const currentAmount = cart.itemTotal;
|
|
14
14
|
const targetAmount = parseFloat(priceRule.value);
|
|
15
15
|
if (priceRule.operator === "gt") return {
|
|
@@ -51,8 +51,8 @@ const computeTarget = (cart, price) => {
|
|
|
51
51
|
function ShippingPriceNudge({ variant = "inline", cart, shippingOptions }) {
|
|
52
52
|
if (!cart || !shippingOptions?.length) return;
|
|
53
53
|
const freeShippingPrice = shippingOptions.map((shippingOption) => {
|
|
54
|
-
if (!shippingOption.
|
|
55
|
-
return shippingOption.prices.filter((price) => price.
|
|
54
|
+
if (!shippingOption.calculatedPrice) return;
|
|
55
|
+
return (shippingOption.prices ?? []).filter((price) => price !== null && price !== void 0 && price.currencyCode === cart.currencyCode && (price.priceRules || []).some((priceRule) => priceRule?.attribute === "item_total")).map((price) => {
|
|
56
56
|
return {
|
|
57
57
|
...price,
|
|
58
58
|
shipping_option_id: shippingOption.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/free-shipping-price-nudge/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { CheckCircleSolid, XMark } from '@medusajs/icons';\nimport {\n HttpTypes,\n StoreCartShippingOption,\n StorePrice,\n} from '@medusajs/types';\nimport { Button, clx } from '@medusajs/ui';\n\nimport { convertToLocale } from '@/lib/utils/money';\nimport { Cart } from '@/types/graphql';\nimport { StoreFreeShippingPrice } from '@/types/prices';\n\nimport { LocalizedClientLink } from '../localized-client-link';\n\nconst computeTarget = (cart: Cart, price: HttpTypes.StorePrice) => {\n const priceRule = (price.price_rules || []).find(\n (pr) => pr.attribute === 'item_total'\n )!;\n\n const currentAmount = cart.itemTotal;\n const targetAmount = parseFloat(priceRule.value);\n\n if (priceRule.operator === 'gt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount + 1 - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'gte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount + 1 - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount === targetAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n }\n};\n\nfunction ShippingPriceNudge({\n variant = 'inline',\n cart,\n shippingOptions,\n}: {\n variant?: 'popup' | 'inline';\n cart: Cart;\n shippingOptions: StoreCartShippingOption[];\n}) {\n if (!cart || !shippingOptions?.length) {\n return;\n }\n\n // Check if any shipping options have a conditional price based on item_total\n const freeShippingPrice = shippingOptions\n .map((shippingOption) => {\n const calculatedPrice = shippingOption.calculated_price;\n\n if (!calculatedPrice) {\n return;\n }\n\n // Get all prices that are:\n // 1. Currency code is same as the cart's\n // 2. Have a rule that is set on item_total\n const validCurrencyPrices = shippingOption.prices.filter(\n (price) =>\n price.currency_code === cart.currencyCode &&\n (price.price_rules || []).some(\n (priceRule) => priceRule.attribute === 'item_total'\n )\n );\n\n return validCurrencyPrices.map((price) => {\n return {\n ...price,\n shipping_option_id: shippingOption.id,\n ...computeTarget(cart, price),\n };\n });\n })\n .flat(1)\n .filter(Boolean)\n // We focus here entirely on free shipping, but this can be edited to handle multiple layers\n // of reduced shipping prices.\n .find((price) => price?.amount === 0);\n\n if (!freeShippingPrice) {\n return;\n }\n\n if (variant === 'popup') {\n return <FreeShippingPopup cart={cart} price={freeShippingPrice} />;\n } else {\n return <FreeShippingInline cart={cart} price={freeShippingPrice} />;\n }\n}\n\nfunction FreeShippingInline({\n cart,\n price,\n}: {\n cart: Cart;\n price: StorePrice & {\n target_reached: boolean;\n target_remaining: number;\n remaining_percentage: number;\n };\n}) {\n return (\n <div className=\"rounded-lg border bg-neutral-100 p-2\">\n <div className=\"space-y-1.5\">\n <div className=\"flex justify-between text-xs text-neutral-600\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-neutral-950\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1 w-fit flex-grow rounded-full bg-neutral-300\"></div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction FreeShippingPopup({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n const [isClosed, setIsClosed] = useState(false);\n\n return (\n <div\n className={clx(\n 'fixed bottom-5 right-5 z-10 flex flex-col items-end gap-2 transition-all duration-500 ease-in-out',\n {\n 'invisible opacity-0 delay-1000': price.target_reached,\n 'invisible opacity-0': isClosed,\n 'visible opacity-100': !price.target_reached && !isClosed,\n }\n )}\n >\n <div>\n <Button\n className=\"rounded-full border-none bg-neutral-900 p-2 text-[15px] shadow-none outline-none\"\n onClick={() => setIsClosed(true)}\n >\n <XMark />\n </Button>\n </div>\n\n <div className=\"w-[400px] rounded-lg bg-black p-6 text-white\">\n <div className=\"pb-4\">\n <div className=\"space-y-3\">\n <div className=\"flex justify-between text-[15px] text-neutral-400\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-white\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1.5 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1.5 w-fit flex-grow rounded-full bg-zinc-600\"></div>\n </div>\n </div>\n </div>\n\n <div className=\"flex gap-3\">\n <LocalizedClientLink\n className=\"rounded-2xl border-[1px] border-white bg-transparent px-4 py-2.5 text-[15px] shadow-none outline-none\"\n href=\"/cart\"\n >\n View cart\n </LocalizedClientLink>\n\n <LocalizedClientLink\n className=\"flex-grow rounded-2xl border-[1px] border-white bg-white px-4 py-2.5 text-center text-[15px] text-neutral-950 shadow-none outline-none\"\n href=\"/store\"\n >\n View products\n </LocalizedClientLink>\n </div>\n </div>\n </div>\n );\n}\n\nexport { ShippingPriceNudge };\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,iBAAiB,MAAY,UAAgC;CACjE,MAAM,aAAa,MAAM,eAAe,EAAE,EAAE,MACzC,OAAO,GAAG,cAAc,aAC1B;CAED,MAAM,gBAAgB,KAAK;CAC3B,MAAM,eAAe,WAAW,UAAU,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oBAAiB,WAAU,gCAAgC;QAAC;QAAI;;QAE7D,GAEN,yBAEE,EAEN,qBAAC;OACC,WAAW,IAAI,WAAW,EACxB,uBAAuB,MAAM,gBAC9B,CAAC;;QACH;QACM;QACL,oBAAC;SAAK,WAAU;mBACb,gBAAgB;UACf,QAAQ,MAAM;UACd,eAAe,KAAK;UACrB,CAAC;UACG;QAAC;QAAI;;QAER;OACF,EACN,qBAAC;MAAI,WAAU;iBACb,oBAAC;OACC,WAAW,IACT,qGACA,EACE,+BAA+B,MAAM,gBACtC,CACF;OACD,OAAO,EAAE,OAAO,GAAG,MAAM,qBAAqB,IAAI;QAC7C,EACP,oBAAC,SAAI,WAAU,mDAAuD;OAClE;MACF;KACF,EAEN,qBAAC;IAAI,WAAU;eACb,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB,EAEtB,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB;KAClB;IACF;GACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/free-shipping-price-nudge/index.tsx"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\n\nimport { CheckCircleSolid, XMark } from '@medusajs/icons';\nimport { Button, clx } from '@medusajs/ui';\n\nimport { convertToLocale } from '@/lib/utils/money';\nimport { Cart, ShippingOption, ShippingOptionPrice } from '@/types/graphql';\nimport { StoreFreeShippingPrice } from '@/types/prices';\n\nimport { LocalizedClientLink } from '../localized-client-link';\n\nconst computeTarget = (cart: Cart, price: ShippingOptionPrice) => {\n const priceRule = (price.priceRules || []).find(\n (pr) => pr?.attribute === 'item_total'\n )!;\n\n const currentAmount = cart.itemTotal;\n const targetAmount = parseFloat(priceRule.value);\n\n if (priceRule.operator === 'gt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount + 1 - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'gte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount > targetAmount,\n target_remaining:\n currentAmount > targetAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lt') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount + 1 - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else if (priceRule.operator === 'lte') {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: targetAmount > currentAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : currentAmount - targetAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n } else {\n return {\n current_amount: currentAmount,\n target_amount: targetAmount,\n target_reached: currentAmount === targetAmount,\n target_remaining:\n targetAmount > currentAmount ? 0 : targetAmount - currentAmount,\n remaining_percentage: (currentAmount / targetAmount) * 100,\n };\n }\n};\n\nfunction ShippingPriceNudge({\n variant = 'inline',\n cart,\n shippingOptions,\n}: {\n variant?: 'popup' | 'inline';\n cart: Cart;\n shippingOptions: ShippingOption[];\n}) {\n if (!cart || !shippingOptions?.length) {\n return;\n }\n\n // Check if any shipping options have a conditional price based on item_total\n const freeShippingPrice = shippingOptions\n .map((shippingOption) => {\n const calculatedPrice = shippingOption.calculatedPrice;\n\n if (!calculatedPrice) {\n return;\n }\n\n // Get all prices that are:\n // 1. Currency code is same as the cart's\n // 2. Have a rule that is set on item_total\n const validCurrencyPrices = (shippingOption.prices ?? []).filter(\n (price): price is NonNullable<typeof price> =>\n price !== null &&\n price !== undefined &&\n price.currencyCode === cart.currencyCode &&\n (price.priceRules || []).some(\n (priceRule) => priceRule?.attribute === 'item_total'\n )\n );\n\n return validCurrencyPrices.map((price) => {\n return {\n ...price,\n shipping_option_id: shippingOption.id,\n ...computeTarget(cart, price),\n };\n });\n })\n .flat(1)\n .filter(Boolean)\n // We focus here entirely on free shipping, but this can be edited to handle multiple layers\n // of reduced shipping prices.\n .find((price) => price?.amount === 0);\n\n if (!freeShippingPrice) {\n return;\n }\n\n if (variant === 'popup') {\n return <FreeShippingPopup cart={cart} price={freeShippingPrice} />;\n } else {\n return <FreeShippingInline cart={cart} price={freeShippingPrice} />;\n }\n}\n\nfunction FreeShippingInline({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n return (\n <div className=\"rounded-lg border bg-neutral-100 p-2\">\n <div className=\"space-y-1.5\">\n <div className=\"flex justify-between text-xs text-neutral-600\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-neutral-950\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1 w-fit flex-grow rounded-full bg-neutral-300\"></div>\n </div>\n </div>\n </div>\n );\n}\n\nfunction FreeShippingPopup({\n cart,\n price,\n}: {\n cart: Cart;\n price: StoreFreeShippingPrice;\n}) {\n const [isClosed, setIsClosed] = useState(false);\n\n return (\n <div\n className={clx(\n 'fixed bottom-5 right-5 z-10 flex flex-col items-end gap-2 transition-all duration-500 ease-in-out',\n {\n 'invisible opacity-0 delay-1000': price.target_reached,\n 'invisible opacity-0': isClosed,\n 'visible opacity-100': !price.target_reached && !isClosed,\n }\n )}\n >\n <div>\n <Button\n className=\"rounded-full border-none bg-neutral-900 p-2 text-[15px] shadow-none outline-none\"\n onClick={() => setIsClosed(true)}\n >\n <XMark />\n </Button>\n </div>\n\n <div className=\"w-[400px] rounded-lg bg-black p-6 text-white\">\n <div className=\"pb-4\">\n <div className=\"space-y-3\">\n <div className=\"flex justify-between text-[15px] text-neutral-400\">\n <div>\n {price.target_reached ? (\n <div className=\"flex items-center gap-1.5\">\n <CheckCircleSolid className=\"inline-block text-green-500\" />{' '}\n Free Shipping unlocked!\n </div>\n ) : (\n `Unlock Free Shipping`\n )}\n </div>\n\n <div\n className={clx('visible', {\n 'invisible opacity-0': price.target_reached,\n })}\n >\n Only{' '}\n <span className=\"text-white\">\n {convertToLocale({\n amount: price.target_remaining,\n currency_code: cart.currencyCode,\n })}\n </span>{' '}\n away\n </div>\n </div>\n <div className=\"flex justify-between gap-1\">\n <div\n className={clx(\n 'h-1.5 max-w-full rounded-full bg-gradient-to-r from-zinc-400 to-zinc-500 duration-500 ease-in-out',\n {\n 'from-green-400 to-green-500': price.target_reached,\n }\n )}\n style={{ width: `${price.remaining_percentage}%` }}\n ></div>\n <div className=\"h-1.5 w-fit flex-grow rounded-full bg-zinc-600\"></div>\n </div>\n </div>\n </div>\n\n <div className=\"flex gap-3\">\n <LocalizedClientLink\n className=\"rounded-2xl border-[1px] border-white bg-transparent px-4 py-2.5 text-[15px] shadow-none outline-none\"\n href=\"/cart\"\n >\n View cart\n </LocalizedClientLink>\n\n <LocalizedClientLink\n className=\"flex-grow rounded-2xl border-[1px] border-white bg-white px-4 py-2.5 text-center text-[15px] text-neutral-950 shadow-none outline-none\"\n href=\"/store\"\n >\n View products\n </LocalizedClientLink>\n </div>\n </div>\n </div>\n );\n}\n\nexport { ShippingPriceNudge };\n"],"mappings":";;;;;;;;;;AAaA,MAAM,iBAAiB,MAAY,UAA+B;CAChE,MAAM,aAAa,MAAM,cAAc,EAAE,EAAE,MACxC,OAAO,IAAI,cAAc,aAC3B;CAED,MAAM,gBAAgB,KA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AAU;iBACb,oBAAC,mBACE,MAAM,iBACL,qBAAC;OAAI,WAAU;;QACb,oBAAC,oBAAiB,WAAU,gCAAgC;QAAC;QAAI;;QAE7D,GAEN,yBAEE,EAEN,qBAAC;OACC,WAAW,IAAI,WAAW,EACxB,uBAAuB,MAAM,gBAC9B,CAAC;;QACH;QACM;QACL,oBAAC;SAAK,WAAU;mBACb,gBAAgB;UACf,QAAQ,MAAM;UACd,eAAe,KAAK;UACrB,CAAC;UACG;QAAC;QAAI;;QAER;OACF,EACN,qBAAC;MAAI,WAAU;iBACb,oBAAC;OACC,WAAW,IACT,qGACA,EACE,+BAA+B,MAAM,gBACtC,CACF;OACD,OAAO,EAAE,OAAO,GAAG,MAAM,qBAAqB,IAAI;QAC7C,EACP,oBAAC,SAAI,WAAU,mDAAuD;OAClE;MACF;KACF,EAEN,qBAAC;IAAI,WAAU;eACb,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB,EAEtB,oBAAC;KACC,WAAU;KACV,MAAK;eACN;MAEqB;KAClB;IACF;GACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime10 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/interactive-link/index.d.ts
|
|
4
4
|
type InteractiveLinkProps = {
|
|
@@ -11,7 +11,7 @@ declare const InteractiveLink: ({
|
|
|
11
11
|
children,
|
|
12
12
|
onClick,
|
|
13
13
|
...props
|
|
14
|
-
}: InteractiveLinkProps) =>
|
|
14
|
+
}: InteractiveLinkProps) => react_jsx_runtime10.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { InteractiveLink };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/interactive-link/index.tsx"],"sourcesContent":[],"mappings":";;;KAKK,oBAAA;;aAEQ,KAAA,CAAM;EAFd,OAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAEuB,CAAA;cAItB,eAAmB,EAAA,CAAA;EAAA,IAAA;EAAA,QAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAKtB,oBALsB,EAAA,GAKF,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/interactive-link/index.tsx"],"sourcesContent":[],"mappings":";;;KAKK,oBAAA;;aAEQ,KAAA,CAAM;EAFd,OAAA,CAAA,EAAA,GAAA,GAAA,IAAA;AAEuB,CAAA;cAItB,eAAmB,EAAA,CAAA;EAAA,IAAA;EAAA,QAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAKtB,oBALsB,EAAA,GAKF,mBAAA,CAAA,GAAA,CAAA,OALE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Maybe, ProductVariant } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime14 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/line-item-options/index.d.ts
|
|
5
5
|
type LineItemOptionsProps = {
|
|
@@ -11,7 +11,7 @@ declare const LineItemOptions: ({
|
|
|
11
11
|
variant,
|
|
12
12
|
"data-testid": dataTestid,
|
|
13
13
|
"data-value": dataValue
|
|
14
|
-
}: LineItemOptionsProps) =>
|
|
14
|
+
}: LineItemOptionsProps) => react_jsx_runtime14.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LineItemOptions };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/line-item-options/index.tsx"],"sourcesContent":[],"mappings":";;;;KAIK,oBAAA;YACO,MAAM;;EADb,YAAA,CAAA,EAGY,KAHZ,CAGkB,cAHE,CAAA;CACP;cAKZ,eALM,EAAA,CAAA;EAAA,OAAA;EAAA,aAAA,EAKa,UALb;EAAA,YAAA,EAKa;AALb,CAAA,EAST,oBATS,EAAA,GASW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/line-item-options/index.tsx"],"sourcesContent":[],"mappings":";;;;KAIK,oBAAA;YACO,MAAM;;EADb,YAAA,CAAA,EAGY,KAHZ,CAGkB,cAHE,CAAA;CACP;cAKZ,eALM,EAAA,CAAA;EAAA,OAAA;EAAA,aAAA,EAKa,UALb;EAAA,YAAA,EAKa;AALb,CAAA,EAST,oBATS,EAAA,GASW,mBAAA,CAAA,GAAA,CAAA,OATX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LineItem } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/line-item-price/index.d.ts
|
|
5
5
|
type LineItemPriceProps = {
|
|
@@ -11,7 +11,7 @@ declare const LineItemPrice: ({
|
|
|
11
11
|
item,
|
|
12
12
|
style,
|
|
13
13
|
currencyCode
|
|
14
|
-
}: LineItemPriceProps) =>
|
|
14
|
+
}: LineItemPriceProps) => react_jsx_runtime11.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LineItemPrice };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/line-item-price/index.tsx"],"sourcesContent":[],"mappings":";;;;KAMK,kBAAA;QACG;;EADH,YAAA,EAAA,MAAA;AACW,CAAA;cAKV,aAAiB,EAAA,CAAA;EAAA,IAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EAIpB,kBAJoB,EAAA,GAIF,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/line-item-price/index.tsx"],"sourcesContent":[],"mappings":";;;;KAMK,kBAAA;QACG;;EADH,YAAA,EAAA,MAAA;AACW,CAAA;cAKV,aAAiB,EAAA,CAAA;EAAA,IAAA;EAAA,KAAA;EAAA;AAAA,CAAA,EAIpB,kBAJoB,EAAA,GAIF,mBAAA,CAAA,GAAA,CAAA,OAJE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, DetailedHTMLProps } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/localized-client-link/index.d.ts
|
|
5
5
|
type LocalizedClientLinkProps = DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
@@ -11,7 +11,7 @@ declare const LocalizedClientLink: ({
|
|
|
11
11
|
children,
|
|
12
12
|
href,
|
|
13
13
|
...props
|
|
14
|
-
}: LocalizedClientLinkProps) =>
|
|
14
|
+
}: LocalizedClientLinkProps) => react_jsx_runtime6.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LocalizedClientLink };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { VariantPrice } from "../../types/prices.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/preview-price/index.d.ts
|
|
5
5
|
declare function PreviewPrice({
|
|
6
6
|
price
|
|
7
7
|
}: {
|
|
8
8
|
price: VariantPrice;
|
|
9
|
-
}):
|
|
9
|
+
}): react_jsx_runtime0.JSX.Element | null;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { PreviewPrice };
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 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_runtime4.JSX.Element;
|
|
63
63
|
//#endregion
|
|
64
64
|
export { ProductCard };
|
|
65
65
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Product } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/product-preview/index.d.ts
|
|
5
5
|
type ProductPreviewProps = {
|
|
@@ -9,7 +9,7 @@ type ProductPreviewProps = {
|
|
|
9
9
|
declare function ProductPreview({
|
|
10
10
|
product,
|
|
11
11
|
isFeatured
|
|
12
|
-
}: ProductPreviewProps):
|
|
12
|
+
}: ProductPreviewProps): react_jsx_runtime7.JSX.Element;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { ProductPreview, ProductPreviewProps };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime1 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_runtime1.JSX.Element;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { SubmitButton };
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 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_runtime2.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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime3 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_runtime3.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,kBAAA,CAAA,GAAA,CAAA,OAAvC;cAYjB,QAZsC,EAAA,GAAA,GAY9B,YAZ8B"}
|
package/dist/lib/data/cart.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { Cart, DeleteLineItemMutation, UpdateCartMutation, UpdateCartMutationVariables } from "../../types/graphql.js";
|
|
1
|
+
import { Cart, DeleteLineItemMutation, ShippingOption, UpdateCartMutation, UpdateCartMutationVariables } from "../../types/graphql.js";
|
|
2
2
|
import { StorefrontContext } from "./context.js";
|
|
3
|
-
import { HttpTypes } from "@medusajs/types";
|
|
4
3
|
|
|
5
4
|
//#region src/lib/data/cart.d.ts
|
|
6
5
|
declare const retrieveCart: (ctx: StorefrontContext) => Promise<Cart | null>;
|
|
7
6
|
declare const updateCart: (data: UpdateCartMutationVariables["data"], ctx: StorefrontContext) => Promise<UpdateCartMutation["updateCart"] | null>;
|
|
8
7
|
declare const deleteLineItem: (lineId: string, ctx: StorefrontContext) => Promise<DeleteLineItemMutation["deleteLineItem"] | null>;
|
|
9
|
-
declare function listCartOptions(ctx: StorefrontContext): Promise<
|
|
10
|
-
shipping_options: HttpTypes.StoreCartShippingOption[];
|
|
11
|
-
}>;
|
|
8
|
+
declare function listCartOptions(ctx: StorefrontContext): Promise<ShippingOption[] | null>;
|
|
12
9
|
//#endregion
|
|
13
10
|
export { deleteLineItem, listCartOptions, retrieveCart, updateCart };
|
|
14
11
|
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","names":[],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cart.d.ts","names":[],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":[],"mappings":";;;;cA4Ba,oBACN,sBACJ,QAAQ;cAyBE,mBACL,0CACD,sBACJ,QAAQ;AA9BE,cAyEA,cAhDZ,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,GAAA,EAkDM,iBAlDN,EAAA,GAmDE,OAnDF,CAmDU,sBAnDV,CAAA,gBAAA,CAAA,GAAA,IAAA,CAAA;AAxBM,iBAyHe,eAAA,CAzHf,GAAA,EA0HA,iBA1HA,CAAA,EA2HJ,OA3HI,CA2HI,cA3HJ,EAAA,GAAA,IAAA,CAAA"}
|
package/dist/lib/data/cart.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { sdk } from "../config/medusa.js";
|
|
2
1
|
import { createServerApolloClient, graphqlFetch, graphqlMutation } from "../gql/apollo-client.js";
|
|
3
2
|
import { DELETE_LINE_ITEM_MUTATION, UPDATE_CART_MUTATION } from "../gql/mutations/cart.js";
|
|
4
3
|
import { GET_CART_QUERY } from "../gql/queries/cart.js";
|
|
4
|
+
import { GET_SHIPPING_OPTIONS_QUERY } from "../gql/queries/shipping.js";
|
|
5
5
|
import { mutateCart } from "../hooks/use-cart.js";
|
|
6
6
|
import { medusaError } from "../utils/medusa-error.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getCacheTag, getCartId } from "./cookies-utils.js";
|
|
8
8
|
|
|
9
9
|
//#region src/lib/data/cart.ts
|
|
10
10
|
const retrieveCart = async (ctx) => {
|
|
@@ -74,12 +74,16 @@ const deleteLineItem = async (lineId, ctx) => {
|
|
|
74
74
|
};
|
|
75
75
|
async function listCartOptions(ctx) {
|
|
76
76
|
const cartId = getCartId(ctx);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
if (!cartId) return null;
|
|
78
|
+
const apolloClient = createServerApolloClient(ctx.cookieHeader);
|
|
79
|
+
try {
|
|
80
|
+
return (await graphqlFetch({
|
|
81
|
+
query: GET_SHIPPING_OPTIONS_QUERY,
|
|
82
|
+
variables: { cartId }
|
|
83
|
+
}, apolloClient))?.shippingOptions?.filter(Boolean) ?? null;
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.js","names":["error: any"],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":["import {
|
|
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,GACH,QAAO;CAGT,MAAM,eAAe,IAAI;CACzB,MAAM,eAAe,yBAAyB,aAAa;AAE3D,KAAI;AASF,UARa,MAAM,aACjB;GACE,OAAO;GACP,WAAW,EAAE,IAAI;GAClB,EACD,aACD,GAEY,QAAQ;UACd,OAAO;AACd,UAAQ,MAAM,yBAAyB,MAAM;AAC7C,SAAO;;;AAIX,MAAa,aAAa,OACxB,MACA,QACqD;CACrD,MAAM,SAAS,UAAU,IAAI;AAE7B,KAAI,CAAC,OACH,OAAM,IAAI,MACR,4DACD;AAGH,KAAI;EAYF,MAAM,QAXS,MAAM,gBAGnB;GACA,UAAU;GACV,WAAW;IACT,IAAI;IACJ;IACD;GACF,CAAC,GAEmB,cAAc;AAEnC,MAAI,MAAM;AACR,SAAM,YAAY;AAClB,OAAI;IACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,kBADqB,YAAY,SAAS,IAAI,CACnB;AAG3B,kBAD4B,YAAY,eAAe,IAAI,CACzB;WAC5B;;AAKV,SAAO;UACA,KAAK;AACZ,cAAY,IAAI;;;AAIpB,MAAa,iBAAiB,OAC5B,QACA,QAC6D;AAC7D,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,8CAA8C;CAGhE,MAAM,SAAS,UAAU,IAAI;AAE7B,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,0CAA0C;AAG5D,KAAI;EAYF,MAAM,mBAXS,MAAM,gBAGnB;GACA,UAAU;GACV,WAAW;IACT;IACA,YAAY;IACb;GACF,CAAC,GAE8B,kBAAkB;AAElD,MAAI,iBAAiB;AACnB,SAAM,YAAY;AAClB,OAAI;IACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,kBADqB,YAAY,SAAS,IAAI,CACnB;AAG3B,kBAD4B,YAAY,eAAe,IAAI,CACzB;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,OACH,QAAO;CAET,MAAM,eAAe,yBAAyB,IAAI,aAAa;AAC/D,KAAI;AAQF,UAPa,MAAM,aAIjB;GAAE,OAAO;GAA4B,WAAW,EAAE,QAAQ;GAAE,EAC5D,aACD,GACa,iBAAiB,OAAO,QAAQ,IAAyB;SACjE;AACN,SAAO"}
|
|
@@ -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_runtime5 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_runtime5.JSX.Element;
|
|
19
19
|
declare const useStorefrontContext: () => StorefrontContext;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { StorefrontContext, StorefrontProvider, useStorefrontActions, useStorefrontContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":[],"mappings":";;;;;UAMiB,iBAAA;;;;AAAjB;AAIC,UAwBS,uBAAA,CAAuB;EAKpB,QAAA,EAJD,SAIC;EAAsB,KAAA,CAAA,EAHzB,iBAGyB;;AAGhC,cAHU,kBAGV,EAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAA,uBAAA,EAAA,GAAuB,
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":[],"mappings":";;;;;UAMiB,iBAAA;;;;AAAjB;AAIC,UAwBS,uBAAA,CAAuB;EAKpB,QAAA,EAJD,SAIC;EAAsB,KAAA,CAAA,EAHzB,iBAGyB;;AAGhC,cAHU,kBAGV,EAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAA,uBAAA,EAAA,GAAuB,kBAAA,CAAA,GAAA,CAAA,OAAvB;AAAuB,cAwBb,oBAxBa,EAAA,GAAA,GAwBO,iBAxBP"}
|
|
@@ -9,65 +9,8 @@ declare const getFooterContent: () => Promise<{
|
|
|
9
9
|
url: string;
|
|
10
10
|
}> | null;
|
|
11
11
|
poweredByCta?: {
|
|
12
|
-
__typename?: "
|
|
13
|
-
text
|
|
14
|
-
__typename?: "FileBlock";
|
|
15
|
-
_key: string;
|
|
16
|
-
_type: string;
|
|
17
|
-
asset?: {
|
|
18
|
-
__typename?: "SanityFileAsset";
|
|
19
|
-
url: string;
|
|
20
|
-
originalFilename?: string | null;
|
|
21
|
-
size?: number | null;
|
|
22
|
-
mimeType?: string | null;
|
|
23
|
-
} | null;
|
|
24
|
-
} | {
|
|
25
|
-
__typename?: "ImageBlock";
|
|
26
|
-
_key: string;
|
|
27
|
-
_type: string;
|
|
28
|
-
alt?: string | null;
|
|
29
|
-
asset?: {
|
|
30
|
-
__typename?: "SanityImageAsset";
|
|
31
|
-
url: string;
|
|
32
|
-
} | null;
|
|
33
|
-
} | {
|
|
34
|
-
__typename?: "TextBlock";
|
|
35
|
-
_key: string;
|
|
36
|
-
_type: string;
|
|
37
|
-
style?: string | null;
|
|
38
|
-
children: Array<{
|
|
39
|
-
__typename?: "Span";
|
|
40
|
-
_key: string;
|
|
41
|
-
text: string;
|
|
42
|
-
marks?: Array<string> | null;
|
|
43
|
-
}>;
|
|
44
|
-
markDefs?: Array<{
|
|
45
|
-
__typename?: "IconLinkMark";
|
|
46
|
-
_key: string;
|
|
47
|
-
_type: string;
|
|
48
|
-
href: string;
|
|
49
|
-
iconType: string;
|
|
50
|
-
iconClass?: string | null;
|
|
51
|
-
iconFill?: string | null;
|
|
52
|
-
iconComponent?: string | null;
|
|
53
|
-
iconUrl?: string | null;
|
|
54
|
-
target?: string | null;
|
|
55
|
-
iconImage?: {
|
|
56
|
-
__typename?: "SanityImage";
|
|
57
|
-
alt?: string | null;
|
|
58
|
-
asset?: {
|
|
59
|
-
__typename?: "SanityImageAsset";
|
|
60
|
-
url: string;
|
|
61
|
-
} | null;
|
|
62
|
-
} | null;
|
|
63
|
-
} | {
|
|
64
|
-
__typename?: "LinkMark";
|
|
65
|
-
_key: string;
|
|
66
|
-
_type: string;
|
|
67
|
-
href: string;
|
|
68
|
-
target?: string | null;
|
|
69
|
-
}> | null;
|
|
70
|
-
}>;
|
|
12
|
+
__typename?: "PartialRichText";
|
|
13
|
+
text?: any | null;
|
|
71
14
|
} | null;
|
|
72
15
|
} | null>;
|
|
73
16
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.d.ts","names":[],"sources":["../../../src/lib/data/footer.ts"],"sourcesContent":[],"mappings":";cAIa,wBAAgB;EAAhB,UAAA,CAAA,EAAA,QAUZ
|
|
1
|
+
{"version":3,"file":"footer.d.ts","names":[],"sources":["../../../src/lib/data/footer.ts"],"sourcesContent":[],"mappings":";cAIa,wBAAgB;EAAhB,UAAA,CAAA,EAAA,QAUZ;;;WAAA"}
|
|
@@ -2,7 +2,7 @@ import { Order } from "../../types/graphql.js";
|
|
|
2
2
|
import { StorefrontContext } from "./context.js";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/data/orders.d.ts
|
|
5
|
-
declare const retrieveOrder: (id: string, ctx: StorefrontContext) => Promise<Order>;
|
|
5
|
+
declare const retrieveOrder: (id: string, ctx: StorefrontContext) => Promise<Order | null>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { retrieveOrder };
|
|
8
8
|
//# sourceMappingURL=orders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.d.ts","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"orders.d.ts","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":[],"mappings":";;;;cAUa,iCAEN,sBACJ,QAAQ"}
|
package/dist/lib/data/orders.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getCacheOptions } from "./cookies-utils.js";
|
|
4
|
-
import { normalizeOrder } from "../utils/normalize-functions.js";
|
|
1
|
+
import { createServerApolloClient, graphqlFetch } from "../gql/apollo-client.js";
|
|
2
|
+
import { GET_ORDER_QUERY } from "../gql/queries/order.js";
|
|
5
3
|
|
|
6
4
|
//#region src/lib/data/orders.ts
|
|
7
5
|
const retrieveOrder = async (id, ctx) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
6
|
+
const apolloClient = createServerApolloClient(ctx.cookieHeader ?? "");
|
|
7
|
+
try {
|
|
8
|
+
return (await graphqlFetch({
|
|
9
|
+
query: GET_ORDER_QUERY,
|
|
10
|
+
variables: { id }
|
|
11
|
+
}, apolloClient))?.order ?? null;
|
|
12
|
+
} catch (err) {
|
|
13
|
+
console.error("Failed to fetch order:", err);
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
//#endregion
|