@nosto/nosto-react 0.1.2 → 0.1.5

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.
@@ -1,29 +0,0 @@
1
- import React, { useEffect } from "react";
2
-
3
- const NostoFohofo: React.FC = () => {
4
- useEffect(() => {
5
- // @ts-ignore
6
- window.nostojs((api) => {
7
- api
8
- .defaultSession()
9
- .setResponseMode("HTML")
10
- .viewNotFound()
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
- notfound
24
- </div>
25
- </>
26
- );
27
- };
28
-
29
- export default NostoFohofo;
@@ -1,29 +0,0 @@
1
- import React, { useEffect } from "react";
2
-
3
- const NostoHome: React.FC = () => {
4
- useEffect(() => {
5
- // @ts-ignore
6
- window.nostojs((api) => {
7
- api
8
- .defaultSession()
9
- .setResponseMode("HTML")
10
- .viewFrontPage()
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
- front
24
- </div>
25
- </>
26
- );
27
- };
28
-
29
- export default NostoHome;
@@ -1,38 +0,0 @@
1
- import { Purchase } from "../../types";
2
- import React, { useEffect } from "react";
3
- import snakeize from "snakeize";
4
-
5
- export interface OrderProps {
6
- purchase: Purchase;
7
- }
8
-
9
- const NostoOrder: React.FC<{ order: OrderProps }> = ({ order }) => {
10
- useEffect(() => {
11
- // @ts-ignore
12
- window.nostojs((api) => {
13
- api
14
- .defaultSession()
15
- .setResponseMode("HTML")
16
- .addOrder(snakeize(order))
17
- .setPlacements(api.placements.getPlacements())
18
- .load()
19
- .then((data: object) => {
20
- // @ts-ignore
21
- api.placements.injectCampaigns(data.recommendations);
22
- });
23
- });
24
- }, []);
25
-
26
- return (
27
- <>
28
- <div className="nosto_page_type" style={{ display: "none" }}>
29
- order
30
- </div>
31
- <div className="nosto_order" style={{ display: "none" }}>
32
- {order.purchase.number}
33
- </div>
34
- </>
35
- );
36
- };
37
-
38
- export default NostoOrder;
@@ -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,37 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { NostoContext } from "./context";
3
-
4
- interface NostoProviderProps {
5
- account: string;
6
- currentVariation: string;
7
- host: string;
8
- children: React.ReactElement;
9
- }
10
-
11
- const NostoProvider: React.FC<NostoProviderProps> = ({
12
- account,
13
- currentVariation,
14
- host,
15
- children,
16
- }) => {
17
- useEffect(() => {
18
- const script = document.createElement("script");
19
- script.type = "text/javascript";
20
- script.src = "//" + (host || "connect.nosto.com") + "/include/" + account;
21
- script.async = true;
22
- document.head.appendChild(script);
23
-
24
- window.nostojs = (cb: Function) =>
25
- (window.nostojs.q = window.nostojs.q || []).push(cb);
26
- // @ts-ignore
27
- window.nostojs((api) => api.setAutoLoad(false));
28
- }, []);
29
-
30
- return (
31
- <NostoContext.Provider value={{ account }}>
32
- {children}
33
- </NostoContext.Provider>
34
- );
35
- };
36
-
37
- 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;