@gfed-medusa/sf-lib-common 2.2.1 → 2.3.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.
- 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/delete-button/index.d.ts.map +1 -1
- package/dist/components/delete-button/index.js +4 -1
- package/dist/components/delete-button/index.js.map +1 -1
- 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 +2 -2
- 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/localized-client-link/index.d.ts.map +1 -1
- package/dist/components/modal/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.map +1 -1
- package/dist/lib/data/cart.js +5 -5
- package/dist/lib/data/cart.js.map +1 -1
- package/dist/lib/data/client-actions.d.ts +4 -4
- package/dist/lib/data/client-actions.d.ts.map +1 -1
- package/dist/lib/data/client-actions.js +12 -4
- package/dist/lib/data/client-actions.js.map +1 -1
- package/dist/lib/data/context.d.ts +2 -3
- package/dist/lib/data/context.d.ts.map +1 -1
- package/dist/lib/data/context.js.map +1 -1
- package/dist/lib/data/cookies-actions.d.ts +8 -0
- package/dist/lib/data/cookies-actions.d.ts.map +1 -0
- package/dist/lib/data/{cookies.js → cookies-actions.js} +3 -22
- package/dist/lib/data/cookies-actions.js.map +1 -0
- package/dist/lib/data/{cookies.d.ts → cookies-utils.d.ts} +3 -7
- package/dist/lib/data/cookies-utils.d.ts.map +1 -0
- package/dist/lib/data/cookies-utils.js +24 -0
- package/dist/lib/data/cookies-utils.js.map +1 -0
- package/dist/lib/data/customer.d.ts.map +1 -1
- package/dist/lib/data/customer.js +6 -4
- package/dist/lib/data/customer.js.map +1 -1
- package/dist/lib/data/next-context.d.ts +1 -2
- package/dist/lib/data/next-context.d.ts.map +1 -1
- package/dist/lib/data/next-context.js +1 -19
- package/dist/lib/data/next-context.js.map +1 -1
- package/dist/lib/data/orders.js +1 -1
- package/dist/lib/data/orders.js.map +1 -1
- package/dist/lib/data/regions.js +1 -1
- package/dist/lib/data/regions.js.map +1 -1
- package/dist/lib/globals/expose-globals.d.ts +8 -0
- package/dist/lib/globals/expose-globals.d.ts.map +1 -0
- package/dist/lib/globals/expose-globals.js +32 -0
- package/dist/lib/globals/expose-globals.js.map +1 -0
- package/dist/lib/gql/apollo-client.d.ts.map +1 -1
- package/dist/lib/gql/apollo-client.js.map +1 -1
- package/dist/lib/gql/fragments/cart.d.ts +9 -9
- package/dist/lib/gql/fragments/cart.d.ts.map +1 -1
- package/dist/lib/gql/fragments/customer.d.ts +3 -3
- package/dist/lib/gql/fragments/customer.d.ts.map +1 -1
- package/dist/lib/gql/fragments/product.d.ts +8 -8
- package/dist/lib/gql/mutations/cart.d.ts +4 -4
- 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/product.d.ts +3 -3
- package/dist/lib/gql/queries/product.d.ts.map +1 -1
- package/dist/lib/hooks/use-apollo.d.ts +2 -2
- package/dist/lib/hooks/use-apollo.d.ts.map +1 -1
- package/dist/lib/hooks/use-cart.d.ts +15 -0
- package/dist/lib/hooks/use-cart.d.ts.map +1 -0
- package/dist/lib/hooks/use-cart.js +26 -0
- package/dist/lib/hooks/use-cart.js.map +1 -0
- package/dist/types/graphql.d.ts.map +1 -1
- package/package.json +6 -5
- package/dist/lib/data/cookies.d.ts.map +0 -1
- package/dist/lib/data/cookies.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 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_runtime2.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_runtime0 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_runtime0.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_runtime0 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_runtime0.JSX.Element;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { DeleteButton };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":[],"mappings":";;;cASM;;;;;;aAMO,KAAA,CAAM;EANb,SAAA,CAAA,EAAA,MAuCL;CAvCqB,EAAA,GAQrB,kBAAA,CAAA,GAAA,CAAA,OARqB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { deleteLineItem } from "../../lib/data/cart.js";
|
|
2
2
|
import { useStorefrontContext } from "../../lib/data/context.js";
|
|
3
|
+
import { mutateCart } from "../../lib/hooks/use-cart.js";
|
|
3
4
|
import { useState } from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
import { Spinner, Trash } from "@medusajs/icons";
|
|
@@ -11,7 +12,9 @@ const DeleteButton = ({ id, children, className }) => {
|
|
|
11
12
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
12
13
|
const handleDelete = async (id$1) => {
|
|
13
14
|
setIsDeleting(true);
|
|
14
|
-
await deleteLineItem(id$1, ctx).
|
|
15
|
+
await deleteLineItem(id$1, ctx).then(() => {
|
|
16
|
+
mutateCart();
|
|
17
|
+
}).catch((err) => {
|
|
15
18
|
setIsDeleting(false);
|
|
16
19
|
});
|
|
17
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["id"],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Spinner, Trash } from '@medusajs/icons';\nimport { clx } from '@medusajs/ui';\n\nimport { deleteLineItem } from '@/lib/data/cart';\nimport { useStorefrontContext } from '@/lib/data/context';\n\nconst DeleteButton = ({\n id,\n children,\n className,\n}: {\n id: string;\n children?: React.ReactNode;\n className?: string;\n}) => {\n const ctx = useStorefrontContext();\n const [isDeleting, setIsDeleting] = useState(false);\n\n const handleDelete = async (id: string) => {\n setIsDeleting(true);\n await deleteLineItem(id, ctx).catch((err) => {\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["id"],"sources":["../../../src/components/delete-button/index.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Spinner, Trash } from '@medusajs/icons';\nimport { clx } from '@medusajs/ui';\n\nimport { deleteLineItem } from '@/lib/data/cart';\nimport { useStorefrontContext } from '@/lib/data/context';\nimport { mutateCart } from '@/lib/hooks/use-cart';\n\nconst DeleteButton = ({\n id,\n children,\n className,\n}: {\n id: string;\n children?: React.ReactNode;\n className?: string;\n}) => {\n const ctx = useStorefrontContext();\n const [isDeleting, setIsDeleting] = useState(false);\n\n const handleDelete = async (id: string) => {\n setIsDeleting(true);\n await deleteLineItem(id, ctx)\n .then(() => {\n mutateCart();\n })\n .catch((err) => {\n setIsDeleting(false);\n });\n };\n\n return (\n <div\n className={clx(\n 'text-small-regular flex items-center justify-between',\n className\n )}\n >\n <button\n className=\"text-ui-fg-subtle hover:text-ui-fg-base flex cursor-pointer gap-x-1\"\n onClick={() => handleDelete(id)}\n >\n {isDeleting ? <Spinner className=\"animate-spin\" /> : <Trash />}\n <span>{children}</span>\n </button>\n </div>\n );\n};\n\nexport { DeleteButton };\n"],"mappings":";;;;;;;;;AASA,MAAM,gBAAgB,EACpB,IACA,UACA,gBAKI;CACJ,MAAM,MAAM,sBAAsB;CAClC,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CAEnD,MAAM,eAAe,OAAO,SAAe;AACzC,gBAAc,KAAK;AACnB,QAAM,eAAeA,MAAI,IAAI,CAC1B,WAAW;AACV,eAAY;IACZ,CACD,OAAO,QAAQ;AACd,iBAAc,MAAM;IACpB;;AAGN,QACE,oBAAC;EACC,WAAW,IACT,wDACA,UACD;YAED,qBAAC;GACC,WAAU;GACV,eAAe,aAAa,GAAG;cAE9B,aAAa,oBAAC,WAAQ,WAAU,iBAAiB,GAAG,oBAAC,UAAQ,EAC9D,oBAAC,UAAM,WAAgB;IAChB;GACL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime3 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_runtime3.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,kBAAA,CAAA,GAAA,CAAA,OAAA,GAaA,IAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cart } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime14 from "react/jsx-runtime";
|
|
3
3
|
import { StoreCartShippingOption } from "@medusajs/types";
|
|
4
4
|
|
|
5
5
|
//#region src/components/free-shipping-price-nudge/index.d.ts
|
|
@@ -11,7 +11,7 @@ declare function ShippingPriceNudge({
|
|
|
11
11
|
variant?: 'popup' | 'inline';
|
|
12
12
|
cart: Cart;
|
|
13
13
|
shippingOptions: StoreCartShippingOption[];
|
|
14
|
-
}):
|
|
14
|
+
}): react_jsx_runtime14.JSX.Element | undefined;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { ShippingPriceNudge };
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 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_runtime4.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,kBAAA,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_runtime5 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_runtime5.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,kBAAA,CAAA,GAAA,CAAA,OATX"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LineItem } from "../../types/graphql.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime13 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_runtime13.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_runtime15 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_runtime15.JSX.Element;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { LocalizedClientLink };
|
|
17
17
|
//# 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,
|
|
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,mBAAA,CAAA,GAAA,CAAA,OAZzB"}
|
|
@@ -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/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):
|
|
23
|
+
}: ModalProps): react_jsx_runtime1.JSX.Element;
|
|
24
24
|
Title: React.FC<{
|
|
25
25
|
children: React.ReactNode;
|
|
26
26
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime7 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_runtime7.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_runtime8 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_runtime8.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_runtime9 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_runtime9.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_runtime10 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_runtime10.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,mBAAA,CAAA,GAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime11 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_runtime11.JSX.Element;
|
|
17
17
|
declare const useModal: () => ModalContext;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { ModalProvider, useModal };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-context.d.ts","names":[],"sources":["../../../src/lib/context/modal-context.tsx"],"sourcesContent":[],"mappings":";;;;UAIU,YAAA;;;AAF+C,cAMnD,YAJgB,EAIJ,KAAA,CAAA,OAJI,CAIJ,YAJI,GAAA,IAAA,CAAA;AAAA,UAMZ,kBAAA,CAFmD;EAEnD,QAAA,CAAA,EACG,KAAA,CAAM,SADS;EAKtB,KAAA,EAAA,GAAA,GAAA,IAUL;;cAVK,aAAiB,EAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAqB,kBAArB,EAAA,GAAuC,
|
|
1
|
+
{"version":3,"file":"modal-context.d.ts","names":[],"sources":["../../../src/lib/context/modal-context.tsx"],"sourcesContent":[],"mappings":";;;;UAIU,YAAA;;;AAF+C,cAMnD,YAJgB,EAIJ,KAAA,CAAA,OAJI,CAIJ,YAJI,GAAA,IAAA,CAAA;AAAA,UAMZ,kBAAA,CAFmD;EAEnD,QAAA,CAAA,EACG,KAAA,CAAM,SADS;EAKtB,KAAA,EAAA,GAAA,GAAA,IAUL;;cAVK,aAAiB,EAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAAqB,kBAArB,EAAA,GAAuC,mBAAA,CAAA,GAAA,CAAA,OAAvC;cAYjB,QAZsC,EAAA,GAAA,GAY9B,YAZ8B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.d.ts","names":[],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":[],"mappings":";;;;;cA2Ba,oBACN,sBACJ,QAAQ;cAmBE,mBACL,0CACD,sBACJ,QAAQ;AAxBE,
|
|
1
|
+
{"version":3,"file":"cart.d.ts","names":[],"sources":["../../../src/lib/data/cart.ts"],"sourcesContent":[],"mappings":";;;;;cA2Ba,oBACN,sBACJ,QAAQ;cAmBE,mBACL,0CACD,sBACJ,QAAQ;AAxBE,cAkEA,cA/CZ,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,GAAA,EAiDM,iBAjDN,EAAA,GAkDE,OAlDF,CAkDU,sBAlDV,CAAA,gBAAA,CAAA,GAAA,IAAA,CAAA;AAlBM,iBAiHe,eAAA,CAjHf,GAAA,EAiHoC,iBAjHpC,CAAA,EAiHqD,OAjHrD,CAAA;EACI,gBAAA,EA0HW,SAAA,CAAU,uBA1HrB,EAAA;CAAR,CAAA"}
|
package/dist/lib/data/cart.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getAuthHeaders, getCacheOptions, getCacheTag, getCartId } from "./cookies.js";
|
|
2
1
|
import { sdk } from "../config/medusa.js";
|
|
3
2
|
import { graphqlFetch, graphqlMutation } from "../gql/apollo-client.js";
|
|
4
3
|
import { DELETE_LINE_ITEM_MUTATION, UPDATE_CART_MUTATION } from "../gql/mutations/cart.js";
|
|
5
4
|
import { GET_CART_QUERY } from "../gql/queries/cart.js";
|
|
6
5
|
import { medusaError } from "../utils/medusa-error.js";
|
|
6
|
+
import { getAuthHeaders, getCacheOptions, getCacheTag, getCartId } from "./cookies-utils.js";
|
|
7
7
|
|
|
8
8
|
//#region src/lib/data/cart.ts
|
|
9
9
|
const retrieveCart = async (ctx) => {
|
|
@@ -30,11 +30,11 @@ const updateCart = async (data, ctx) => {
|
|
|
30
30
|
data
|
|
31
31
|
}
|
|
32
32
|
}))?.updateCart ?? null;
|
|
33
|
-
if (cart) {
|
|
33
|
+
if (cart) try {
|
|
34
34
|
const { revalidateTag } = await import("next/cache");
|
|
35
35
|
revalidateTag(getCacheTag("carts", ctx));
|
|
36
36
|
revalidateTag(getCacheTag("fulfillment", ctx));
|
|
37
|
-
}
|
|
37
|
+
} catch {}
|
|
38
38
|
return cart;
|
|
39
39
|
} catch (err) {
|
|
40
40
|
medusaError(err);
|
|
@@ -52,11 +52,11 @@ const deleteLineItem = async (lineId, ctx) => {
|
|
|
52
52
|
lineItemId: lineId
|
|
53
53
|
}
|
|
54
54
|
}))?.deleteLineItem ?? null;
|
|
55
|
-
if (deletedLineItem) {
|
|
55
|
+
if (deletedLineItem) try {
|
|
56
56
|
const { revalidateTag } = await import("next/cache");
|
|
57
57
|
revalidateTag(getCacheTag("carts", ctx));
|
|
58
58
|
revalidateTag(getCacheTag("fulfillment", ctx));
|
|
59
|
-
}
|
|
59
|
+
} catch {}
|
|
60
60
|
return deletedLineItem;
|
|
61
61
|
} catch (error) {
|
|
62
62
|
console.error("GraphQL deleteLineItem error:", error.message);
|
|
@@ -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 { graphqlFetch, graphqlMutation } 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 { medusaError } from '../utils/medusa-error';\nimport type { StorefrontContext } from './context';\nimport {\n getAuthHeaders,\n getCacheOptions,\n getCacheTag,\n getCartId,\n} from './cookies';\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 try {\n const data = await graphqlFetch<GetCartQuery, GetCartQueryVariables>({\n query: GET_CART_QUERY,\n variables: { id },\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 const { revalidateTag } = await import('next/cache');\n
|
|
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 { graphqlFetch, graphqlMutation } 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 { medusaError } from '../utils/medusa-error';\nimport type { StorefrontContext } from './context';\nimport {\n getAuthHeaders,\n getCacheOptions,\n getCacheTag,\n getCartId,\n} 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 try {\n const data = await graphqlFetch<GetCartQuery, GetCartQueryVariables>({\n query: GET_CART_QUERY,\n variables: { id },\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 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 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 headers = {\n ...getAuthHeaders(ctx),\n };\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 headers,\n cache: 'force-cache',\n });\n}\n"],"mappings":";;;;;;;;AA2BA,MAAa,eAAe,OAC1B,QACyB;CACzB,MAAM,KAAK,UAAU,IAAI;AACzB,KAAI,CAAC,GACH,QAAO;AAGT,KAAI;AAMF,UALa,MAAM,aAAkD;GACnE,OAAO;GACP,WAAW,EAAE,IAAI;GAClB,CAAC,GAEW,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,KACF,KAAI;GACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,iBADqB,YAAY,SAAS,IAAI,CACnB;AAG3B,iBAD4B,YAAY,eAAe,IAAI,CACzB;UAC5B;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,gBACF,KAAI;GACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAEvC,iBADqB,YAAY,SAAS,IAAI,CACnB;AAG3B,iBAD4B,YAAY,eAAe,IAAI,CACzB;UAC5B;AAKV,SAAO;UACAA,OAAY;AACnB,UAAQ,MAAM,iCAAiC,MAAM,QAAQ;AAC7D,QAAM;;;AAIV,eAAsB,gBAAgB,KAAwB;CAC5D,MAAM,SAAS,UAAU,IAAI;CAC7B,MAAM,UAAU,EACd,GAAG,eAAe,IAAI,EACvB;CACD,MAAM,OAAO,EACX,GAAG,gBAAgB,mBAAmB,IAAI,EAC3C;AAED,QAAO,MAAM,IAAI,OAAO,MAErB,2BAA2B;EAC5B,OAAO,EAAE,SAAS,QAAQ;EAC1B;EACA;EACA,OAAO;EACR,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { removeAuthTokenAction, removeCartIdAction, setAuthTokenAction, setCartIdAction } from "./cookies.js";
|
|
2
|
-
import {
|
|
1
|
+
import { removeAuthTokenAction, removeCartIdAction, setAuthTokenAction, setCartIdAction } from "./cookies-actions.js";
|
|
2
|
+
import { StorefrontContext } from "./context.js";
|
|
3
3
|
|
|
4
4
|
//#region src/lib/data/client-actions.d.ts
|
|
5
|
-
declare const useStorefrontActions: () => {
|
|
5
|
+
declare const useStorefrontActions: (ctx?: StorefrontContext) => {
|
|
6
6
|
setCartId: typeof setCartIdAction;
|
|
7
7
|
removeCartId: typeof removeCartIdAction;
|
|
8
8
|
setAuthToken: typeof setAuthTokenAction;
|
|
9
9
|
removeAuthToken: typeof removeAuthTokenAction;
|
|
10
|
-
updateRegion:
|
|
10
|
+
updateRegion: (countryCode: string, currentPath: string) => Promise<void>;
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
export { useStorefrontActions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-actions.d.ts","names":[],"sources":["../../../src/lib/data/client-actions.tsx"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"client-actions.d.ts","names":[],"sources":["../../../src/lib/data/client-actions.tsx"],"sourcesContent":[],"mappings":";;;;cAgCa,6BAA8B;;EAA9B,YAAA,EAAA,yBAYZ;EAZ0C,YAAA,EAAA,yBAAA;;8DAUlC"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { getCartId } from "./cookies-utils.js";
|
|
4
|
+
import { updateCart } from "./cart.js";
|
|
5
|
+
import { removeAuthTokenAction, removeCartIdAction, setAuthTokenAction, setCartIdAction } from "./cookies-actions.js";
|
|
6
|
+
import { getRegion } from "./regions.js";
|
|
5
7
|
|
|
6
8
|
//#region src/lib/data/client-actions.tsx
|
|
7
|
-
|
|
9
|
+
async function updateRegion(countryCode, currentPath, ctx) {
|
|
10
|
+
const region = await getRegion(countryCode, ctx);
|
|
11
|
+
if (!region) throw new Error(`Region not found for country code: ${countryCode}`);
|
|
12
|
+
if (getCartId(ctx)) await updateCart({ regionId: region.id }, ctx);
|
|
13
|
+
window.location.href = `/${countryCode}${currentPath}`;
|
|
14
|
+
}
|
|
15
|
+
const useStorefrontActions = (ctx) => {
|
|
8
16
|
return {
|
|
9
17
|
setCartId: setCartIdAction,
|
|
10
18
|
removeCartId: removeCartIdAction,
|
|
11
19
|
setAuthToken: setAuthTokenAction,
|
|
12
20
|
removeAuthToken: removeAuthTokenAction,
|
|
13
|
-
updateRegion:
|
|
21
|
+
updateRegion: ((countryCode, currentPath) => updateRegion(countryCode, currentPath, ctx))
|
|
14
22
|
};
|
|
15
23
|
};
|
|
16
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-actions.js","names":[],"sources":["../../../src/lib/data/client-actions.tsx"],"sourcesContent":["'use client';\n\nimport {\n removeAuthTokenAction,\n removeCartIdAction,\n setAuthTokenAction,\n setCartIdAction,\n} from './cookies';\nimport {
|
|
1
|
+
{"version":3,"file":"client-actions.js","names":[],"sources":["../../../src/lib/data/client-actions.tsx"],"sourcesContent":["'use client';\n\nimport { updateCart } from './cart';\nimport { StorefrontContext } from './context';\nimport {\n removeAuthTokenAction,\n removeCartIdAction,\n setAuthTokenAction,\n setCartIdAction,\n} from './cookies-actions';\nimport { getCartId } from './cookies-utils';\nimport { getRegion } from './regions';\n\nasync function updateRegion(\n countryCode: string,\n currentPath: string,\n ctx: StorefrontContext\n) {\n const region = await getRegion(countryCode, ctx);\n\n if (!region) {\n throw new Error(`Region not found for country code: ${countryCode}`);\n }\n\n const cartId = getCartId(ctx);\n if (cartId) {\n await updateCart({ regionId: region.id }, ctx);\n }\n\n window.location.href = `/${countryCode}${currentPath}`;\n}\n\nexport const useStorefrontActions = (ctx?: StorefrontContext) => {\n return {\n setCartId: setCartIdAction,\n removeCartId: removeCartIdAction,\n setAuthToken: setAuthTokenAction,\n removeAuthToken: removeAuthTokenAction,\n updateRegion: ((countryCode: string, currentPath: string) =>\n updateRegion(countryCode, currentPath, ctx!)) as (\n countryCode: string,\n currentPath: string\n ) => Promise<void>,\n };\n};\n"],"mappings":";;;;;;;;AAaA,eAAe,aACb,aACA,aACA,KACA;CACA,MAAM,SAAS,MAAM,UAAU,aAAa,IAAI;AAEhD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,sCAAsC,cAAc;AAItE,KADe,UAAU,IAAI,CAE3B,OAAM,WAAW,EAAE,UAAU,OAAO,IAAI,EAAE,IAAI;AAGhD,QAAO,SAAS,OAAO,IAAI,cAAc;;AAG3C,MAAa,wBAAwB,QAA4B;AAC/D,QAAO;EACL,WAAW;EACX,cAAc;EACd,cAAc;EACd,iBAAiB;EACjB,gBAAgB,aAAqB,gBACnC,aAAa,aAAa,aAAa,IAAK;EAI/C"}
|
|
@@ -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_runtime12 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/data/context.d.ts
|
|
6
6
|
interface StorefrontContext {
|
|
@@ -8,7 +8,6 @@ interface StorefrontContext {
|
|
|
8
8
|
customerToken: string;
|
|
9
9
|
cacheId: string;
|
|
10
10
|
cookieHeader: string;
|
|
11
|
-
revalidate?: (tag: string) => void;
|
|
12
11
|
}
|
|
13
12
|
declare const StorefrontProvider: ({
|
|
14
13
|
children,
|
|
@@ -16,7 +15,7 @@ declare const StorefrontProvider: ({
|
|
|
16
15
|
}: {
|
|
17
16
|
children: ReactNode;
|
|
18
17
|
value: StorefrontContext;
|
|
19
|
-
}) =>
|
|
18
|
+
}) => react_jsx_runtime12.JSX.Element;
|
|
20
19
|
declare const useStorefrontContext: () => StorefrontContext;
|
|
21
20
|
//#endregion
|
|
22
21
|
export { StorefrontContext, StorefrontProvider, useStorefrontActions, useStorefrontContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":[],"mappings":";;;;;UAIiB,iBAAA;;;;EAAA,YAAA,EAAA,MAAiB;
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":[],"mappings":";;;;;UAIiB,iBAAA;;;;EAAA,YAAA,EAAA,MAAiB;AAWlC;AAAmC,cAAtB,kBAAsB,EAAA,CAAA;EAAA,QAAA;EAAA;CAAA,EAAA;EAAA,QAAA,EAIvB,SAJuB;EAIvB,KAAA,EACH,iBADG;CACH,EAAA,GACR,mBAAA,CAAA,GAAA,CAAA,OADQ;AACR,cAQY,oBARZ,EAAA,GAAA,GAQgC,iBARhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, createContext, useContext } from 'react';\n\nexport interface StorefrontContext {\n cartId: string;\n customerToken: string;\n cacheId: string;\n cookieHeader: string;\n
|
|
1
|
+
{"version":3,"file":"context.js","names":[],"sources":["../../../src/lib/data/context.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode, createContext, useContext } from 'react';\n\nexport interface StorefrontContext {\n cartId: string;\n customerToken: string;\n cacheId: string;\n cookieHeader: string;\n}\n\nconst StorefrontReactContext = createContext<StorefrontContext>(\n {} as StorefrontContext\n);\n\nexport const StorefrontProvider = ({\n children,\n value,\n}: {\n children: ReactNode;\n value: StorefrontContext;\n}) => {\n return (\n <StorefrontReactContext.Provider value={value}>\n {children}\n </StorefrontReactContext.Provider>\n );\n};\n\nexport const useStorefrontContext = () => useContext(StorefrontReactContext);\nexport { useStorefrontActions } from './client-actions';\n"],"mappings":";;;;;;;AAWA,MAAM,yBAAyB,cAC7B,EAAE,CACH;AAED,MAAa,sBAAsB,EACjC,UACA,YAII;AACJ,QACE,oBAAC,uBAAuB;EAAgB;EACrC;GAC+B;;AAItC,MAAa,6BAA6B,WAAW,uBAAuB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/lib/data/cookies-actions.d.ts
|
|
2
|
+
declare function setCartIdAction(id: string): Promise<void>;
|
|
3
|
+
declare function removeCartIdAction(): Promise<void>;
|
|
4
|
+
declare function setAuthTokenAction(token: string): Promise<void>;
|
|
5
|
+
declare function removeAuthTokenAction(): Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { removeAuthTokenAction, removeCartIdAction, setAuthTokenAction, setCartIdAction };
|
|
8
|
+
//# sourceMappingURL=cookies-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies-actions.d.ts","names":[],"sources":["../../../src/lib/data/cookies-actions.ts"],"sourcesContent":[],"mappings":";iBAEsB,eAAA,cAA0B;AAA1B,iBAWA,kBAAA,CAAA,CAX0B,EAWR,OAXQ,CAAA,IAAA,CAAA;AAW1B,iBAMA,kBAAA,CANkB,KAAA,EAAA,MAAA,CAAA,EAMc,OANd,CAAA,IAAA,CAAA;AAMlB,iBAWA,qBAAA,CAAA,CAXgC,EAWX,OAXW,CAAA,IAAA,CAAA"}
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
'use server';
|
|
2
2
|
|
|
3
|
-
//#region src/lib/data/cookies.ts
|
|
4
|
-
const getAuthHeaders = (ctx) => {
|
|
5
|
-
const token = ctx.customerToken;
|
|
6
|
-
if (!token) return {};
|
|
7
|
-
return { authorization: `Bearer ${token}` };
|
|
8
|
-
};
|
|
9
|
-
const getCacheTag = (tag, ctx) => {
|
|
10
|
-
const cacheId = ctx.cacheId;
|
|
11
|
-
if (!cacheId) return "";
|
|
12
|
-
return `${tag}-${cacheId}`;
|
|
13
|
-
};
|
|
14
|
-
const getCacheOptions = (tag, ctx) => {
|
|
15
|
-
if (typeof window !== "undefined") return {};
|
|
16
|
-
const cacheTag = getCacheTag(tag, ctx);
|
|
17
|
-
if (!cacheTag) return {};
|
|
18
|
-
return { tags: [`${cacheTag}`] };
|
|
19
|
-
};
|
|
20
|
-
const getCartId = (ctx) => {
|
|
21
|
-
return ctx.cartId;
|
|
22
|
-
};
|
|
3
|
+
//#region src/lib/data/cookies-actions.ts
|
|
23
4
|
async function setCartIdAction(id) {
|
|
24
5
|
const { cookies } = await import("next/headers");
|
|
25
6
|
(await cookies()).set("_medusa_cart_id", id, {
|
|
@@ -48,5 +29,5 @@ async function removeAuthTokenAction() {
|
|
|
48
29
|
}
|
|
49
30
|
|
|
50
31
|
//#endregion
|
|
51
|
-
export {
|
|
52
|
-
//# sourceMappingURL=cookies.js.map
|
|
32
|
+
export { removeAuthTokenAction, removeCartIdAction, setAuthTokenAction, setCartIdAction };
|
|
33
|
+
//# sourceMappingURL=cookies-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies-actions.js","names":[],"sources":["../../../src/lib/data/cookies-actions.ts"],"sourcesContent":["'use server';\n\nexport async function setCartIdAction(id: string) {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_cart_id', id, {\n maxAge: 60 * 60 * 24 * 7,\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n });\n}\n\nexport async function removeCartIdAction() {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_cart_id', '', { maxAge: -1 });\n}\n\nexport async function setAuthTokenAction(token: string) {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_jwt', token, {\n maxAge: 60 * 60 * 24 * 7,\n httpOnly: true,\n sameSite: 'strict',\n secure: process.env.NODE_ENV === 'production',\n });\n}\n\nexport async function removeAuthTokenAction() {\n const { cookies } = await import('next/headers');\n const c = await cookies();\n c.set('_medusa_jwt', '', { maxAge: -1 });\n}\n"],"mappings":";;;AAEA,eAAsB,gBAAgB,IAAY;CAChD,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,mBAAmB,IAAI;EAC3B,QAAQ,OAAU,KAAK;EACvB,UAAU;EACV,UAAU;EACV,QAAQ;EACT,CAAC;;AAGJ,eAAsB,qBAAqB;CACzC,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,mBAAmB,IAAI,EAAE,QAAQ,IAAI,CAAC;;AAG9C,eAAsB,mBAAmB,OAAe;CACtD,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,eAAe,OAAO;EAC1B,QAAQ,OAAU,KAAK;EACvB,UAAU;EACV,UAAU;EACV,QAAQ;EACT,CAAC;;AAGJ,eAAsB,wBAAwB;CAC5C,MAAM,EAAE,YAAY,MAAM,OAAO;AAEjC,EADU,MAAM,SAAS,EACvB,IAAI,eAAe,IAAI,EAAE,QAAQ,IAAI,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorefrontContext } from "./context.js";
|
|
2
2
|
|
|
3
|
-
//#region src/lib/data/cookies.d.ts
|
|
3
|
+
//#region src/lib/data/cookies-utils.d.ts
|
|
4
4
|
declare const getAuthHeaders: (ctx: StorefrontContext) => {
|
|
5
5
|
authorization: string;
|
|
6
6
|
} | {};
|
|
@@ -9,10 +9,6 @@ declare const getCacheOptions: (tag: string, ctx: StorefrontContext) => {
|
|
|
9
9
|
tags: string[];
|
|
10
10
|
} | {};
|
|
11
11
|
declare const getCartId: (ctx: StorefrontContext) => string;
|
|
12
|
-
declare function setCartIdAction(id: string): Promise<void>;
|
|
13
|
-
declare function removeCartIdAction(): Promise<void>;
|
|
14
|
-
declare function setAuthTokenAction(token: string): Promise<void>;
|
|
15
|
-
declare function removeAuthTokenAction(): Promise<void>;
|
|
16
12
|
//#endregion
|
|
17
|
-
export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId
|
|
18
|
-
//# sourceMappingURL=cookies.d.ts.map
|
|
13
|
+
export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId };
|
|
14
|
+
//# sourceMappingURL=cookies-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies-utils.d.ts","names":[],"sources":["../../../src/lib/data/cookies-utils.ts"],"sourcesContent":[],"mappings":";;;cAEa,sBACN;;AADP,CAAA,GAAa,CAAA,CAAA;AAYA,cAAA,WAAiC,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,EAAjB,iBAAiB,EAAA,GAAA,MAAA;AAUlD,cAAA,eAEN,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,EAAjB,iBAAiB,EAAA,GAAA;EAeX,IAAA,EAAA,MAEZ,EAAA;;cAFY,iBAAkB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/lib/data/cookies-utils.ts
|
|
2
|
+
const getAuthHeaders = (ctx) => {
|
|
3
|
+
const token = ctx.customerToken;
|
|
4
|
+
if (!token) return {};
|
|
5
|
+
return { authorization: `Bearer ${token}` };
|
|
6
|
+
};
|
|
7
|
+
const getCacheTag = (tag, ctx) => {
|
|
8
|
+
const cacheId = ctx.cacheId;
|
|
9
|
+
if (!cacheId) return "";
|
|
10
|
+
return `${tag}-${cacheId}`;
|
|
11
|
+
};
|
|
12
|
+
const getCacheOptions = (tag, ctx) => {
|
|
13
|
+
if (typeof window !== "undefined") return {};
|
|
14
|
+
const cacheTag = getCacheTag(tag, ctx);
|
|
15
|
+
if (!cacheTag) return {};
|
|
16
|
+
return { tags: [`${cacheTag}`] };
|
|
17
|
+
};
|
|
18
|
+
const getCartId = (ctx) => {
|
|
19
|
+
return ctx.cartId;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { getAuthHeaders, getCacheOptions, getCacheTag, getCartId };
|
|
24
|
+
//# sourceMappingURL=cookies-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies-utils.js","names":[],"sources":["../../../src/lib/data/cookies-utils.ts"],"sourcesContent":["import type { StorefrontContext } from './context';\n\nexport const getAuthHeaders = (\n ctx: StorefrontContext\n): { authorization: string } | {} => {\n const token = ctx.customerToken;\n\n if (!token) {\n return {};\n }\n\n return { authorization: `Bearer ${token}` };\n};\n\nexport const getCacheTag = (tag: string, ctx: StorefrontContext): string => {\n const cacheId = ctx.cacheId;\n\n if (!cacheId) {\n return '';\n }\n\n return `${tag}-${cacheId}`;\n};\n\nexport const getCacheOptions = (\n tag: string,\n ctx: StorefrontContext\n): { tags: string[] } | {} => {\n if (typeof window !== 'undefined') {\n return {};\n }\n\n const cacheTag = getCacheTag(tag, ctx);\n\n if (!cacheTag) {\n return {};\n }\n\n return { tags: [`${cacheTag}`] };\n};\n\nexport const getCartId = (ctx: StorefrontContext) => {\n return ctx.cartId;\n};\n"],"mappings":";AAEA,MAAa,kBACX,QACmC;CACnC,MAAM,QAAQ,IAAI;AAElB,KAAI,CAAC,MACH,QAAO,EAAE;AAGX,QAAO,EAAE,eAAe,UAAU,SAAS;;AAG7C,MAAa,eAAe,KAAa,QAAmC;CAC1E,MAAM,UAAU,IAAI;AAEpB,KAAI,CAAC,QACH,QAAO;AAGT,QAAO,GAAG,IAAI,GAAG;;AAGnB,MAAa,mBACX,KACA,QAC4B;AAC5B,KAAI,OAAO,WAAW,YACpB,QAAO,EAAE;CAGX,MAAM,WAAW,YAAY,KAAK,IAAI;AAEtC,KAAI,CAAC,SACH,QAAO,EAAE;AAGX,QAAO,EAAE,MAAM,CAAC,GAAG,WAAW,EAAE;;AAGlC,MAAa,aAAa,QAA2B;AACnD,QAAO,IAAI"}
|