@nosto/nosto-react 0.1.0 → 0.1.4
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 +6 -2
- package/dist/index.es.client.js +180 -119
- package/dist/index.umd.client.js +2 -2
- package/package.json +1 -1
- package/src/components/Category/index.client.tsx +37 -0
- package/src/components/Checkout/index.client.tsx +34 -0
- package/src/components/Fohofo/index.client.tsx +34 -0
- package/src/components/Home/index.client.tsx +37 -0
- package/src/components/Order/index.client.tsx +43 -0
- package/src/components/Other/index.client.tsx +34 -0
- package/src/components/Placement/{index.tsx → index.client.tsx} +0 -0
- package/src/components/Product/{index.tsx → index.client.tsx} +53 -52
- package/src/components/Provider/context.client.ts +25 -0
- package/src/components/Provider/index.client.tsx +58 -0
- package/src/components/Search/index.client.tsx +37 -0
- package/src/components/Session/{index.tsx → index.client.tsx} +0 -0
- package/src/index.client.ts +17 -11
- package/src/components/Category/index.tsx +0 -32
- package/src/components/Checkout/index.tsx +0 -29
- package/src/components/Fohofo/index.tsx +0 -29
- package/src/components/Home/index.tsx +0 -29
- package/src/components/Order/index.tsx +0 -38
- package/src/components/Other/index.tsx +0 -29
- package/src/components/Provider/context.ts +0 -12
- package/src/components/Provider/index.tsx +0 -35
- package/src/components/Search/index.tsx +0 -32
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
const NostoOther: React.FC = () => {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
window.nostojs((api) => {
|
|
7
|
-
api
|
|
8
|
-
.defaultSession()
|
|
9
|
-
.setResponseMode("HTML")
|
|
10
|
-
.viewOther()
|
|
11
|
-
.setPlacements(api.placements.getPlacements())
|
|
12
|
-
.load()
|
|
13
|
-
.then((data: object) => {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
api.placements.injectCampaigns(data.recommendations);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
<div className="nosto_page_type" style={{ display: "none" }}>
|
|
23
|
-
other
|
|
24
|
-
</div>
|
|
25
|
-
</>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export default NostoOther;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
|
|
3
|
-
export interface NostoInterface {
|
|
4
|
-
account: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/* tslint:disable:no-empty */
|
|
8
|
-
export const NostoContext = createContext<NostoInterface>({
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
account: undefined
|
|
11
|
-
});
|
|
12
|
-
/* tslint:enable:no-empty */
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
import { NostoContext } from "./context";
|
|
3
|
-
|
|
4
|
-
interface NostoProviderProps {
|
|
5
|
-
account: string;
|
|
6
|
-
host: string;
|
|
7
|
-
children: React.ReactElement;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const NostoProvider: React.FC<NostoProviderProps> = ({
|
|
11
|
-
account,
|
|
12
|
-
host,
|
|
13
|
-
children,
|
|
14
|
-
}) => {
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const script = document.createElement("script");
|
|
17
|
-
script.type = "text/javascript";
|
|
18
|
-
script.src = "//" + (host || "connect.nosto.com") + "/include/" + account;
|
|
19
|
-
script.async = true;
|
|
20
|
-
document.head.appendChild(script);
|
|
21
|
-
|
|
22
|
-
window.nostojs = (cb: Function) =>
|
|
23
|
-
(window.nostojs.q = window.nostojs.q || []).push(cb);
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
window.nostojs((api) => api.setAutoLoad(false));
|
|
26
|
-
}, []);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<NostoContext.Provider value={{ account }}>
|
|
30
|
-
{children}
|
|
31
|
-
</NostoContext.Provider>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default NostoProvider;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
const NostoSearch: React.FC<{ query: string }> = ({ query }) => {
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
window.nostojs((api) => {
|
|
7
|
-
api
|
|
8
|
-
.defaultSession()
|
|
9
|
-
.setResponseMode("HTML")
|
|
10
|
-
.viewSearch(query)
|
|
11
|
-
.setPlacements(api.placements.getPlacements())
|
|
12
|
-
.load()
|
|
13
|
-
.then((data: object) => {
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
api.placements.injectCampaigns(data.recommendations);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}, []);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<>
|
|
22
|
-
<div className="nosto_page_type" style={{ display: "none" }}>
|
|
23
|
-
search
|
|
24
|
-
</div>
|
|
25
|
-
<div className="nosto_search" style={{ display: "none" }}>
|
|
26
|
-
{query}
|
|
27
|
-
</div>
|
|
28
|
-
</>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default NostoSearch;
|