@gfed-medusa/sf-lib-common 2.4.0 → 3.0.1

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.
Files changed (73) hide show
  1. package/dist/components/breadcrumbs/index.d.ts +2 -2
  2. package/dist/components/breadcrumbs/index.d.ts.map +1 -1
  3. package/dist/components/cart-mismatch-banner/index.d.ts +2 -2
  4. package/dist/components/cart-mismatch-banner/index.d.ts.map +1 -1
  5. package/dist/components/delete-button/index.d.ts +2 -2
  6. package/dist/components/error-message/index.d.ts +2 -2
  7. package/dist/components/free-shipping-price-nudge/index.d.ts +4 -5
  8. package/dist/components/free-shipping-price-nudge/index.d.ts.map +1 -1
  9. package/dist/components/free-shipping-price-nudge/index.js +3 -3
  10. package/dist/components/free-shipping-price-nudge/index.js.map +1 -1
  11. package/dist/components/interactive-link/index.d.ts +2 -2
  12. package/dist/components/interactive-link/index.d.ts.map +1 -1
  13. package/dist/components/line-item-options/index.d.ts +2 -2
  14. package/dist/components/localized-client-link/index.d.ts +6 -7
  15. package/dist/components/localized-client-link/index.d.ts.map +1 -1
  16. package/dist/components/localized-client-link/index.js +26 -6
  17. package/dist/components/localized-client-link/index.js.map +1 -1
  18. package/dist/components/modal/index.d.ts +2 -2
  19. package/dist/components/modal/index.d.ts.map +1 -1
  20. package/dist/lib/data/cart.d.ts +2 -5
  21. package/dist/lib/data/cart.d.ts.map +1 -1
  22. package/dist/lib/data/cart.js +12 -8
  23. package/dist/lib/data/cart.js.map +1 -1
  24. package/dist/lib/data/context.d.ts +2 -2
  25. package/dist/lib/data/footer.d.ts +2 -59
  26. package/dist/lib/data/footer.d.ts.map +1 -1
  27. package/dist/lib/data/orders.d.ts +1 -1
  28. package/dist/lib/data/orders.d.ts.map +1 -1
  29. package/dist/lib/data/orders.js +12 -11
  30. package/dist/lib/data/orders.js.map +1 -1
  31. package/dist/lib/data/regions.d.ts +2 -1
  32. package/dist/lib/data/regions.d.ts.map +1 -1
  33. package/dist/lib/data/regions.js +17 -11
  34. package/dist/lib/data/regions.js.map +1 -1
  35. package/dist/lib/globals/expose-globals.js +1 -1
  36. package/dist/lib/gql/fragments/cart.d.ts +9 -9
  37. package/dist/lib/gql/fragments/cart.d.ts.map +1 -1
  38. package/dist/lib/gql/fragments/customer.d.ts +3 -3
  39. package/dist/lib/gql/fragments/customer.d.ts.map +1 -1
  40. package/dist/lib/gql/fragments/product.d.ts +8 -8
  41. package/dist/lib/gql/fragments/product.d.ts.map +1 -1
  42. package/dist/lib/gql/mutations/cart.d.ts +7 -5
  43. package/dist/lib/gql/mutations/cart.d.ts.map +1 -1
  44. package/dist/lib/gql/mutations/cart.js +22 -2
  45. package/dist/lib/gql/mutations/cart.js.map +1 -1
  46. package/dist/lib/gql/queries/cart.d.ts +2 -2
  47. package/dist/lib/gql/queries/collections.d.ts +2 -2
  48. package/dist/lib/gql/queries/collections.d.ts.map +1 -1
  49. package/dist/lib/gql/queries/customer.d.ts +2 -2
  50. package/dist/lib/gql/queries/footer.d.ts +2 -2
  51. package/dist/lib/gql/queries/order.d.ts +9 -0
  52. package/dist/lib/gql/queries/order.d.ts.map +1 -0
  53. package/dist/lib/gql/queries/order.js +103 -0
  54. package/dist/lib/gql/queries/order.js.map +1 -0
  55. package/dist/lib/gql/queries/product.d.ts +3 -3
  56. package/dist/lib/gql/queries/regions.d.ts +8 -0
  57. package/dist/lib/gql/queries/regions.d.ts.map +1 -0
  58. package/dist/lib/gql/queries/regions.js +39 -0
  59. package/dist/lib/gql/queries/regions.js.map +1 -0
  60. package/dist/lib/gql/queries/shipping.d.ts +8 -0
  61. package/dist/lib/gql/queries/shipping.d.ts.map +1 -0
  62. package/dist/lib/gql/queries/shipping.js +48 -0
  63. package/dist/lib/gql/queries/shipping.js.map +1 -0
  64. package/dist/lib/hooks/use-apollo.d.ts +2 -2
  65. package/dist/types/cms.d.ts +85 -0
  66. package/dist/types/cms.d.ts.map +1 -0
  67. package/dist/types/cms.js +0 -0
  68. package/dist/types/graphql.d.ts +466 -481
  69. package/dist/types/graphql.d.ts.map +1 -1
  70. package/dist/types/graphql.js +3736 -7495
  71. package/dist/types/graphql.js.map +1 -1
  72. package/dist/types/prices.d.ts +5 -2
  73. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime0 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime12 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): react_jsx_runtime0.JSX.Element;
17
+ }: BreadcrumbsProps): react_jsx_runtime12.JSX.Element;
18
18
  //#endregion
19
19
  export { Breadcrumbs };
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":[],"mappings":";;;cAiBM,iBAAiB,eAErB,KAAA,CAAM;;;AAyCW,CAAA,CAAA,CAAA;AA3CU,UAQnB,gBAAA,CAAgB;EA+BjB,aAAA,CAAW,EAAA,MAAA,OA9BW,eA8BX;EAClB,QAAA,CAAA,EAAA,MAAA;EACA,aAAA,CAAA,EAAA,MAAA;;iBAFO,WAAA,CAIN;EAAA,aAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAA,gBAAA,CAAA,EAAgB,kBAAA,CAAA,GAAA,CAAA,OAAhB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":[],"mappings":";;;cAiBM,iBAAiB,eAErB,KAAA,CAAM;;;AAyCW,CAAA,CAAA,CAAA;AA3CU,UAQnB,gBAAA,CAAgB;EA+BjB,aAAA,CAAW,EAAA,MAAA,OA9BW,eA8BX;EAClB,QAAA,CAAA,EAAA,MAAA;EACA,aAAA,CAAA,EAAA,MAAA;;iBAFO,WAAA,CAIN;EAAA,aAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAA,gBAAA,CAAA,EAAgB,mBAAA,CAAA,GAAA,CAAA,OAAhB"}
@@ -1,11 +1,11 @@
1
1
  import { Cart, Customer } from "../../types/graphql.js";
2
- import * as react_jsx_runtime14 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime2 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
- }): react_jsx_runtime14.JSX.Element | undefined;
8
+ }): react_jsx_runtime2.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,mBAAA,CAAA,GAAA,CAAA,OAAA,GAAtB,SAAA"}
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 react_jsx_runtime13 from "react/jsx-runtime";
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
- }) => react_jsx_runtime13.JSX.Element;
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 react_jsx_runtime1 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime0 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
- }) => react_jsx_runtime1.JSX.Element | null;
10
+ }) => react_jsx_runtime0.JSX.Element | null;
11
11
  //#endregion
12
12
  export { ErrorMessage };
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,5 @@
1
- import { Cart } from "../../types/graphql.js";
2
- import * as react_jsx_runtime12 from "react/jsx-runtime";
3
- import { StoreCartShippingOption } from "@medusajs/types";
1
+ import { Cart, ShippingOption } from "../../types/graphql.js";
2
+ import * as react_jsx_runtime1 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: StoreCartShippingOption[];
14
- }): react_jsx_runtime12.JSX.Element | undefined;
12
+ shippingOptions: ShippingOption[];
13
+ }): react_jsx_runtime1.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":";;;;;iBA0ES,kBAAA;;;;;;QAMD;EANC,eAAA,EAOU,uBAPQ,EAAA;CACzB,CAAA,EAOD,mBAAA,CAAA,GAAA,CAAA,OAAA,GAPC,SAAA"}
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,kBAAA,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.price_rules || []).find((pr) => pr.attribute === "item_total");
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.calculated_price) return;
55
- return shippingOption.prices.filter((price) => price.currency_code === cart.currencyCode && (price.price_rules || []).some((priceRule) => priceRule.attribute === "item_total")).map((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":"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"}
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":"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"}
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime2 from "react/jsx-runtime";
1
+ import * as react_jsx_runtime14 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) => react_jsx_runtime2.JSX.Element;
14
+ }: InteractiveLinkProps) => react_jsx_runtime14.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,kBAAA,CAAA,GAAA,CAAA,OALE"}
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 react_jsx_runtime3 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime0 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) => react_jsx_runtime3.JSX.Element;
14
+ }: LineItemOptionsProps) => react_jsx_runtime0.JSX.Element;
15
15
  //#endregion
16
16
  export { LineItemOptions };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,17 +1,16 @@
1
1
  import { AnchorHTMLAttributes, DetailedHTMLProps } from "react";
2
- import * as react_jsx_runtime5 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime3 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/localized-client-link/index.d.ts
5
- type LocalizedClientLinkProps = DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
6
- /**
7
- * Use this component to create an anchor link that persists the current country code in the url,
8
- * without having to explicitly pass it as a prop.
9
- */
5
+ type LocalizedClientLinkProps = DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> & {
6
+ locale?: string;
7
+ };
10
8
  declare const LocalizedClientLink: ({
11
9
  children,
12
10
  href,
11
+ locale,
13
12
  ...props
14
- }: LocalizedClientLinkProps) => react_jsx_runtime5.JSX.Element;
13
+ }: LocalizedClientLinkProps) => react_jsx_runtime3.JSX.Element;
15
14
  //#endregion
16
15
  export { LocalizedClientLink };
17
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/localized-client-link/index.tsx"],"sourcesContent":[],"mappings":";;;;KAEK,wBAAA,GAA2B,kBAC9B,qBAAqB,oBACrB;;;AAJ8D;;cAW1D,mBARJ,EAAA,CAAA;EAAA,QAAA;EAAA,IAAA;EAAA,GAAA;AAAA,CAAA,EAYC,wBAZD,EAAA,GAYyB,kBAAA,CAAA,GAAA,CAAA,OAZzB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/localized-client-link/index.tsx"],"sourcesContent":[],"mappings":";;;;KAWK,wBAAA,GAA2B,kBAC9B,qBAAqB,oBACrB;;;AANa,cAWT,mBAPuB,EAAA,CAAA;EAAA,QAAA;EAAA,IAAA;EAAA,MAAA;EAAA,GAAA;AAAA,CAAA,EAY1B,wBAZ0B,EAAA,GAYF,kBAAA,CAAA,GAAA,CAAA,OAZE"}
@@ -1,13 +1,33 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState } from "react";
1
4
  import { jsx } from "react/jsx-runtime";
2
5
 
3
6
  //#region src/components/localized-client-link/index.tsx
4
- /**
5
- * Use this component to create an anchor link that persists the current country code in the url,
6
- * without having to explicitly pass it as a prop.
7
- */
8
- const LocalizedClientLink = ({ children, href, ...props }) => {
7
+ const LOCALE_REGEX = /^[a-z]{2}(?:-[A-Z]{2})?$/;
8
+ const LocalizedClientLink = ({ children, href, locale, ...props }) => {
9
+ const [pathname, setPathname] = useState("");
10
+ useEffect(() => {
11
+ setPathname(window.location.pathname);
12
+ }, []);
13
+ const getLocaleFromPathname = (pathname$1) => {
14
+ const pathLocale = pathname$1.split("/")[1];
15
+ if (pathLocale && LOCALE_REGEX.test(pathLocale)) return pathLocale;
16
+ return "dk";
17
+ };
18
+ const activeLocale = locale || getLocaleFromPathname(pathname);
19
+ const normalizeHref = (href$1) => {
20
+ if (!href$1) return "";
21
+ return href$1.startsWith("/") ? href$1 : `/${href$1}`;
22
+ };
23
+ if (href?.startsWith("http") || href?.startsWith("//")) return /* @__PURE__ */ jsx("a", {
24
+ href,
25
+ ...props,
26
+ children
27
+ });
9
28
  return /* @__PURE__ */ jsx("a", {
10
- href: `/dk${href}`,
29
+ href: `/${activeLocale}${normalizeHref(href)}`,
30
+ suppressHydrationWarning: true,
11
31
  ...props,
12
32
  children
13
33
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/components/localized-client-link/index.tsx"],"sourcesContent":["import { AnchorHTMLAttributes, DetailedHTMLProps } from 'react';\n\ntype LocalizedClientLinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n>;\n\n/**\n * Use this component to create an anchor link that persists the current country code in the url,\n * without having to explicitly pass it as a prop.\n */\nconst LocalizedClientLink = ({\n children,\n href,\n ...props\n}: LocalizedClientLinkProps) => {\n return (\n <a href={`/dk${href}`} {...props}>\n {children}\n </a>\n );\n};\n\nexport { LocalizedClientLink };\n"],"mappings":";;;;;;;AAWA,MAAM,uBAAuB,EAC3B,UACA,MACA,GAAG,YAC2B;AAC9B,QACE,oBAAC;EAAE,MAAM,MAAM;EAAQ,GAAI;EACxB;GACC"}
1
+ {"version":3,"file":"index.js","names":["pathname","href"],"sources":["../../../src/components/localized-client-link/index.tsx"],"sourcesContent":["'use client';\n\nimport {\n AnchorHTMLAttributes,\n DetailedHTMLProps,\n useEffect,\n useState,\n} from 'react';\n\nconst LOCALE_REGEX = /^[a-z]{2}(?:-[A-Z]{2})?$/;\n\ntype LocalizedClientLinkProps = DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> & {\n locale?: string;\n};\n\nconst LocalizedClientLink = ({\n children,\n href,\n locale,\n ...props\n}: LocalizedClientLinkProps) => {\n const [pathname, setPathname] = useState('');\n\n useEffect(() => {\n setPathname(window.location.pathname);\n }, []);\n\n const getLocaleFromPathname = (pathname: string): string => {\n const pathLocale = pathname.split('/')[1];\n if (pathLocale && LOCALE_REGEX.test(pathLocale)) {\n return pathLocale;\n }\n return 'dk';\n };\n\n const activeLocale = locale || getLocaleFromPathname(pathname);\n\n const normalizeHref = (href?: string) => {\n if (!href) return '';\n return href.startsWith('/') ? href : `/${href}`;\n };\n\n if (href?.startsWith('http') || href?.startsWith('//')) {\n return (\n <a href={href} {...props}>\n {children}\n </a>\n );\n }\n\n return (\n <a\n href={`/${activeLocale}${normalizeHref(href)}`}\n suppressHydrationWarning\n {...props}\n >\n {children}\n </a>\n );\n};\n\nexport { LocalizedClientLink };\n"],"mappings":";;;;;;AASA,MAAM,eAAe;AASrB,MAAM,uBAAuB,EAC3B,UACA,MACA,QACA,GAAG,YAC2B;CAC9B,MAAM,CAAC,UAAU,eAAe,SAAS,GAAG;AAE5C,iBAAgB;AACd,cAAY,OAAO,SAAS,SAAS;IACpC,EAAE,CAAC;CAEN,MAAM,yBAAyB,eAA6B;EAC1D,MAAM,aAAaA,WAAS,MAAM,IAAI,CAAC;AACvC,MAAI,cAAc,aAAa,KAAK,WAAW,CAC7C,QAAO;AAET,SAAO;;CAGT,MAAM,eAAe,UAAU,sBAAsB,SAAS;CAE9D,MAAM,iBAAiB,WAAkB;AACvC,MAAI,CAACC,OAAM,QAAO;AAClB,SAAOA,OAAK,WAAW,IAAI,GAAGA,SAAO,IAAIA;;AAG3C,KAAI,MAAM,WAAW,OAAO,IAAI,MAAM,WAAW,KAAK,CACpD,QACE,oBAAC;EAAQ;EAAM,GAAI;EAChB;GACC;AAIR,QACE,oBAAC;EACC,MAAM,IAAI,eAAe,cAAc,KAAK;EAC5C;EACA,GAAI;EAEH;GACC"}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime5 from "react/jsx-runtime";
3
3
 
4
4
  //#region src/components/modal/index.d.ts
5
5
  type ModalProps = {
@@ -20,7 +20,7 @@ declare const Modal: {
20
20
  children,
21
21
  "data-testid": dataTestId,
22
22
  "aria-label": ariaLabel
23
- }: ModalProps): react_jsx_runtime0.JSX.Element;
23
+ }: ModalProps): react_jsx_runtime5.JSX.Element;
24
24
  Title: React.FC<{
25
25
  children: React.ReactNode;
26
26
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/modal/index.tsx"],"sourcesContent":[],"mappings":";;;;KAQK,UAAA;;;EAAA,IAAA,CAAA,EAAA,OAAU,GAAA,QAAA,GAKH,OAAM;EAKZ,MAAA,CAAA,EAqEL,OAAA;YA1EW,KAAA,CAAM;;;;cAKZ;;;;;;;;;KAQH,aAAU,kBAAA,CAAA,GAAA,CAAA;;IAAV,QAAA,EA+D+B,KAAA,CAAM,SA/DrC;EAAU,CAAA,CAAA;EA+DqB,WAAM,UAAA,CAAA;cAeA,KAAA,CAAM;EAAN,CAAA,CAAA;;IAQD,QAAA,EAAN,KAAA,CAAM,SAAA;;EAIJ,MAAM,UAAA,CAAA;cAAN,KAAA,CAAM"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/modal/index.tsx"],"sourcesContent":[],"mappings":";;;;KAQK,UAAA;;;EAAA,IAAA,CAAA,EAAA,OAAU,GAAA,QAKH,GAAA,OAAM;EAKZ,MAAA,CAAA,EAqEL,OAAA;YA1EW,KAAA,CAAM;;;;cAKZ;;;;;;;;;KAQH,aAAU,kBAAA,CAAA,GAAA,CAAA;;IAAV,QAAA,EA+D+B,KAAA,CAAM,SA/DrC;EAAU,CAAA,CAAA;EA+DqB,WAAM,UAAA,CAAA;cAeA,KAAA,CAAM;EAAN,CAAA,CAAA;;IAQD,QAAA,EAAN,KAAA,CAAM,SAAA;;EAIJ,MAAM,UAAA,CAAA;cAAN,KAAA,CAAM"}
@@ -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":";;;;;cA2Ba,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,EAyHoC,iBAzHpC,CAAA,EAyHqD,OAzHrD,CAAA;EACI,gBAAA,EA+HW,SAAA,CAAU,uBA/HrB,EAAA;CAAR,CAAA"}
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"}
@@ -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 { getCacheOptions, getCacheTag, getCartId } from "./cookies-utils.js";
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
- const next = { ...getCacheOptions("shippingOptions", ctx) };
78
- return await sdk.client.fetch("/store/shipping-options", {
79
- query: { cart_id: cartId },
80
- next,
81
- cache: "force-cache"
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 { HttpTypes } from '@medusajs/types';\n\nimport {\n Cart,\n DeleteLineItemMutation,\n DeleteLineItemMutationVariables,\n GetCartQuery,\n GetCartQueryVariables,\n UpdateCartMutation,\n UpdateCartMutationVariables,\n} from '../../types/graphql';\nimport { sdk } from '../config/medusa';\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 { mutateCart } from '../hooks/use-cart';\nimport { medusaError } from '../utils/medusa-error';\nimport type { StorefrontContext } from './context';\nimport { getCacheOptions, 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(ctx: StorefrontContext) {\n const cartId = getCartId(ctx);\n const next = {\n ...getCacheOptions('shippingOptions', ctx),\n };\n\n return await sdk.client.fetch<{\n shipping_options: HttpTypes.StoreCartShippingOption[];\n }>('/store/shipping-options', {\n query: { cart_id: cartId },\n next,\n cache: 'force-cache',\n });\n}\n"],"mappings":";;;;;;;;;AA2BA,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,gBAAgB,KAAwB;CAC5D,MAAM,SAAS,UAAU,IAAI;CAC7B,MAAM,OAAO,EACX,GAAG,gBAAgB,mBAAmB,IAAI,EAC3C;AAED,QAAO,MAAM,IAAI,OAAO,MAErB,2BAA2B;EAC5B,OAAO,EAAE,SAAS,QAAQ;EAC1B;EACA,OAAO;EACR,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,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 react_jsx_runtime15 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime13 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) => react_jsx_runtime15.JSX.Element;
18
+ }: StorefrontProviderProps) => react_jsx_runtime13.JSX.Element;
19
19
  declare const useStorefrontContext: () => StorefrontContext;
20
20
  //#endregion
21
21
  export { StorefrontContext, StorefrontProvider, useStorefrontActions, useStorefrontContext };
@@ -9,65 +9,8 @@ declare const getFooterContent: () => Promise<{
9
9
  url: string;
10
10
  }> | null;
11
11
  poweredByCta?: {
12
- __typename?: "RichText";
13
- text: Array<{
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;;EACo3kC,SAAA,CAAA,EAAA,MAAA,GAAA,IAAA;;IAA6D,UAAA,CAAA,EAAA,YAAA;;IAXr5kC,GAAA,EAAA,MAAA;EAAA,CAAA,CAAA,GAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAWw1kC;;iBAA6D"}
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":";;;;cAQa,iCAAwC,sBAAiB,QAAA,KAAA"}
1
+ {"version":3,"file":"orders.d.ts","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":[],"mappings":";;;;cAUa,iCAEN,sBACJ,QAAQ"}
@@ -1,17 +1,18 @@
1
- import { sdk } from "../config/medusa.js";
2
- import { medusaError } from "../utils/medusa-error.js";
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 next = { ...getCacheOptions("orders", ctx) };
9
- return sdk.client.fetch(`/store/orders/${id}`, {
10
- method: "GET",
11
- query: { fields: "*payment_collections.payments,*items,*items.metadata,*items.variant,*items.product" },
12
- next,
13
- cache: "force-cache"
14
- }).then(({ order }) => order && normalizeOrder(order)).catch((err) => medusaError(err));
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
@@ -1 +1 @@
1
- {"version":3,"file":"orders.js","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":["import { HttpTypes } from '@medusajs/types';\n\nimport { sdk } from '../config/medusa';\nimport { medusaError } from '../utils/medusa-error';\nimport { normalizeOrder } from '../utils/normalize-functions';\nimport { StorefrontContext } from './context';\nimport { getCacheOptions } from './cookies-utils';\n\nexport const retrieveOrder = async (id: string, ctx: StorefrontContext) => {\n const next = {\n ...getCacheOptions('orders', ctx),\n };\n\n return sdk.client\n .fetch<HttpTypes.StoreOrderResponse>(`/store/orders/${id}`, {\n method: 'GET',\n query: {\n fields:\n '*payment_collections.payments,*items,*items.metadata,*items.variant,*items.product',\n },\n next,\n cache: 'force-cache',\n })\n .then(({ order }) => order && normalizeOrder(order))\n .catch((err) => medusaError(err));\n};\n"],"mappings":";;;;;;AAQA,MAAa,gBAAgB,OAAO,IAAY,QAA2B;CACzE,MAAM,OAAO,EACX,GAAG,gBAAgB,UAAU,IAAI,EAClC;AAED,QAAO,IAAI,OACR,MAAoC,iBAAiB,MAAM;EAC1D,QAAQ;EACR,OAAO,EACL,QACE,sFACH;EACD;EACA,OAAO;EACR,CAAC,CACD,MAAM,EAAE,YAAY,SAAS,eAAe,MAAM,CAAC,CACnD,OAAO,QAAQ,YAAY,IAAI,CAAC"}
1
+ {"version":3,"file":"orders.js","names":[],"sources":["../../../src/lib/data/orders.ts"],"sourcesContent":["import {\n GetOrderQuery,\n GetOrderQueryVariables,\n Order,\n} from '@/types/graphql';\n\nimport { createServerApolloClient, graphqlFetch } from '../gql/apollo-client';\nimport { GET_ORDER_QUERY } from '../gql/queries/order';\nimport { StorefrontContext } from './context';\n\nexport const retrieveOrder = async (\n id: string,\n ctx: StorefrontContext\n): Promise<Order | null> => {\n const apolloClient = createServerApolloClient(ctx.cookieHeader ?? '');\n try {\n const data = await graphqlFetch<GetOrderQuery, GetOrderQueryVariables>(\n { query: GET_ORDER_QUERY, variables: { id } },\n apolloClient\n );\n return data?.order ?? null;\n } catch (err) {\n console.error('Failed to fetch order:', err);\n return null;\n }\n};\n"],"mappings":";;;;AAUA,MAAa,gBAAgB,OAC3B,IACA,QAC0B;CAC1B,MAAM,eAAe,yBAAyB,IAAI,gBAAgB,GAAG;AACrE,KAAI;AAKF,UAJa,MAAM,aACjB;GAAE,OAAO;GAAiB,WAAW,EAAE,IAAI;GAAE,EAC7C,aACD,GACY,SAAS;UACf,KAAK;AACZ,UAAQ,MAAM,0BAA0B,IAAI;AAC5C,SAAO"}
@@ -3,7 +3,8 @@ import { StorefrontContext } from "./context.js";
3
3
 
4
4
  //#region src/lib/data/regions.d.ts
5
5
  declare const listRegions: (ctx: StorefrontContext) => Promise<Region[]>;
6
+ declare const retrieveRegion: (id: string, ctx: StorefrontContext) => Promise<Region | null>;
6
7
  declare const getRegion: (countryCode: string, ctx: StorefrontContext) => Promise<Region | null>;
7
8
  //#endregion
8
- export { getRegion, listRegions };
9
+ export { getRegion, listRegions, retrieveRegion };
9
10
  //# sourceMappingURL=regions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"regions.d.ts","names":[],"sources":["../../../src/lib/data/regions.ts"],"sourcesContent":[],"mappings":";;;;cAWa,mBAA0B,sBAAiB,QAAA;cAe3C,sCAEN,sBACJ,QAAQ"}
1
+ {"version":3,"file":"regions.d.ts","names":[],"sources":["../../../src/lib/data/regions.ts"],"sourcesContent":[],"mappings":";;;;cAea,mBAA0B,sBAAiB,QAAA;cAW3C,kCAAyC,sBAAiB,QAAA;AAX1D,cAsBA,SAbZ,EAAA,CAAA,WAAA,EAAA,MAAA,EAAA,GAAA,EAeM,iBAfN,EAAA,GAgBE,OAhBF,CAgBU,MAhBV,GAAA,IAAA,CAAA"}