@raxonltd/raxon-core 1.0.9 → 1.1.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/README.md +758 -0
- package/dist/core/interface/context.interface.d.ts +9 -0
- package/dist/core/interface/context.interface.d.ts.map +1 -0
- package/dist/core/interface/context.interface.js +1 -0
- package/dist/core/raxon.context.d.ts +7 -6
- package/dist/core/raxon.context.d.ts.map +1 -1
- package/dist/core/raxon.context.js +16 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.interface.d.ts","sourceRoot":"","sources":["../../../core/interface/context.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Article, BankAccount, Branch,
|
|
2
|
-
import { Product as CustomProduct } from
|
|
3
|
-
import { ModalAuthRef } from
|
|
4
|
-
import { ModalNewsletterVariantProductRef } from
|
|
5
|
-
import { CartState } from
|
|
1
|
+
import { Article, BankAccount, Branch, Campaign, Category, Collection, DeliveryMethod, DynamicData, Faq, Feed, Holiday, Material, PaymentMethod, Review, User } from "./interface/prisma.interface";
|
|
2
|
+
import { Product as CustomProduct } from "./interface/product.interface";
|
|
3
|
+
import { ModalAuthRef } from "./feature/auth/modal/modal.auth";
|
|
4
|
+
import { ModalNewsletterVariantProductRef } from "./feature/newsletter/modal/modal.newsletter.product";
|
|
5
|
+
import { CartState } from "./context/cart.context";
|
|
6
|
+
import { RaxonContextBrand } from "./interface/context.interface";
|
|
6
7
|
export declare const RaxonContext: import("react").Context<RaxonContextType>;
|
|
7
8
|
interface RaxonBootstrapData {
|
|
8
9
|
campaign: Campaign[];
|
|
@@ -26,7 +27,7 @@ interface RaxonBootstrapData {
|
|
|
26
27
|
deliveryMethod: DeliveryMethod[];
|
|
27
28
|
paymentMethod: PaymentMethod[];
|
|
28
29
|
defaultDeliveryMethod: DeliveryMethod | null;
|
|
29
|
-
brand:
|
|
30
|
+
brand: RaxonContextBrand[];
|
|
30
31
|
modalAuthRef: React.RefObject<ModalAuthRef | null>;
|
|
31
32
|
modalNewsletterVariantProductRef: React.RefObject<ModalNewsletterVariantProductRef | null>;
|
|
32
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raxon.context.d.ts","sourceRoot":"","sources":["../../core/raxon.context.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACP,WAAW,EACX,MAAM,
|
|
1
|
+
{"version":3,"file":"raxon.context.d.ts","sourceRoot":"","sources":["../../core/raxon.context.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACP,WAAW,EACX,MAAM,EAEN,QAAQ,EAER,QAAQ,EACR,UAAU,EACV,cAAc,EACd,WAAW,EACX,GAAG,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,aAAa,EACb,MAAM,EACN,IAAI,EACL,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAa,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAiC,gCAAgC,EAAE,MAAM,0DAA0D,CAAC;AAG3I,OAAO,EAAgB,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,eAAO,MAAM,YAAY,2CAAyD,CAAC;AAGnF,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,cAAc,EAAE,QAAQ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,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,gCAUA,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAO,gBAM3B,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { CampaignType, } from
|
|
4
|
-
import { createContext, useContext, useEffect, useMemo, useRef, useState } from
|
|
5
|
-
import { nexineAxios } from
|
|
6
|
-
import { ModalAuth } from
|
|
7
|
-
import { ModalNewsletterVariantProduct } from
|
|
8
|
-
import { QueryClient, QueryClientProvider } from
|
|
9
|
-
import { useSecurityState } from
|
|
10
|
-
import { useCartState } from
|
|
11
|
-
import { AnalyticEventProvider } from
|
|
3
|
+
import { CampaignType, } from "./interface/prisma.interface";
|
|
4
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { nexineAxios } from "./util/nexine.axios";
|
|
6
|
+
import { ModalAuth } from "./feature/auth/modal/modal.auth";
|
|
7
|
+
import { ModalNewsletterVariantProduct } from "./feature/newsletter/modal/modal.newsletter.product";
|
|
8
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
9
|
+
import { useSecurityState } from "./context/security.context";
|
|
10
|
+
import { useCartState } from "./context/cart.context";
|
|
11
|
+
import { AnalyticEventProvider } from "./feature/analytic-event/analytic.event.context";
|
|
12
12
|
export const RaxonContext = createContext(undefined);
|
|
13
13
|
const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analyticAutoTrack, }) => {
|
|
14
14
|
const [raxon, setRaxon] = useState(null);
|
|
@@ -16,11 +16,11 @@ const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analy
|
|
|
16
16
|
const [hasFetched, setHasFetched] = useState(false);
|
|
17
17
|
const modalAuthRef = useRef(null);
|
|
18
18
|
const modalNewsletterVariantProductRef = useRef(null);
|
|
19
|
-
if (typeof window !==
|
|
19
|
+
if (typeof window !== "undefined") {
|
|
20
20
|
window.__RAXON_API_KEY__ = apiKey;
|
|
21
21
|
window.__RAXON_API_URL__ = apiUrl;
|
|
22
22
|
nexineAxios.defaults.baseURL = apiUrl;
|
|
23
|
-
nexineAxios.defaults.headers.common[
|
|
23
|
+
nexineAxios.defaults.headers.common["x-api-key"] = apiKey;
|
|
24
24
|
}
|
|
25
25
|
const { profile, authLoading, isAuthenticated, isGuest } = useSecurityState();
|
|
26
26
|
const cartState = useCartState(isAuthenticated);
|
|
@@ -30,7 +30,7 @@ const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analy
|
|
|
30
30
|
setHasFetched(true);
|
|
31
31
|
fetch(`${apiUrl}/customer/bootstrap`, {
|
|
32
32
|
headers: {
|
|
33
|
-
|
|
33
|
+
"x-api-key": apiKey,
|
|
34
34
|
},
|
|
35
35
|
})
|
|
36
36
|
.then((res) => res.json())
|
|
@@ -39,7 +39,7 @@ const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analy
|
|
|
39
39
|
setIsLoading(false);
|
|
40
40
|
})
|
|
41
41
|
.catch((err) => {
|
|
42
|
-
console.error(
|
|
42
|
+
console.error("[RAXON] ERROR:", err);
|
|
43
43
|
setIsLoading(false);
|
|
44
44
|
});
|
|
45
45
|
}, [hasFetched, apiUrl, apiKey]);
|
|
@@ -55,7 +55,7 @@ const RaxonProviderInner = ({ children, apiKey, apiUrl, productPathPrefix, analy
|
|
|
55
55
|
branch: raxon?.branch ?? null,
|
|
56
56
|
collection: raxon?.collection ?? [],
|
|
57
57
|
subHeroCollection: raxon?.subHeroCollection ?? [],
|
|
58
|
-
banner: raxon?.collection?.filter((it) => it.tags.includes(
|
|
58
|
+
banner: raxon?.collection?.filter((it) => it.tags.includes("banner")) ?? [],
|
|
59
59
|
category: Array.isArray(raxon?.category) ? raxon.category : [],
|
|
60
60
|
flatCategory,
|
|
61
61
|
faq: raxon?.faq ?? [],
|
|
@@ -90,7 +90,7 @@ export const RaxonProvider = ({ children, apiKey, apiUrl, productPathPrefix, ana
|
|
|
90
90
|
export const useRaxon = () => {
|
|
91
91
|
const context = useContext(RaxonContext);
|
|
92
92
|
if (context === undefined) {
|
|
93
|
-
throw new Error(
|
|
93
|
+
throw new Error("useRaxon must be used within a RaxonProvider");
|
|
94
94
|
}
|
|
95
95
|
return context;
|
|
96
96
|
};
|