loyalty-protocol 1.0.0

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/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { useLoyaltyChannel } from "./src/hooks/useLoyaltyChannel";
2
+
3
+ export { useLoyaltyChannel };
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "loyalty-protocol",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "type": "commonjs",
13
+ "private": false
14
+ }
@@ -0,0 +1,17 @@
1
+ import { useCallback } from "react";
2
+
3
+ const useLoyaltyChannel = () => {
4
+ const sendInformationToLoyaltyProtocol = ({ url }) => {
5
+ /** @type {HTMLIFrameElement} */
6
+ const iframe = document.getElementById("loyalty-protocol");
7
+
8
+ if (!iframe || typeof iframe.contentWindow === "undefined")
9
+ throw new Error(`Element with ID: loyalty-protocol is not iframe window`);
10
+
11
+ iframe.contentWindow.postMessage(url, "https://stage.kstore.global/");
12
+ };
13
+
14
+ return { sendInformationToLoyaltyProtocol };
15
+ };
16
+
17
+ export { useLoyaltyChannel };