@arizondigital/catalyst-sso 0.1.4 → 0.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +28 -22
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.1.4",
6
+ "version": "0.2.0",
7
7
  "description": "Integer Catalyst SSO package",
8
8
  "license": "MIT",
9
9
  "author": "Arizon Digital",
package/src/index.js CHANGED
@@ -32,19 +32,16 @@ function SsoButtonPlaceholder({ buttonText, loginUrl }) {
32
32
  );
33
33
  }
34
34
 
35
- export function OktaSamlButton({ isSandbox, storeHash, channelId }) {
35
+ export function OktaSamlButton({isSandbox,storeHash,channelId}) {
36
36
  const [buttonName, setButtonName] = useState("Login With Okta");
37
37
  const [redirectUrl, setRedirectUrl] = useState("");
38
38
  console.log("OktaSamlButton Props:", { isSandbox, storeHash, channelId });
39
39
 
40
40
  useEffect(() => {
41
41
  axios
42
- .get(
43
- `https://sso-app-merchant-dev.vercel.app/api/${storeHash}/okta/saml?channel_id=${channelId}`,
44
- {
45
- withCredentials: true,
46
- },
47
- )
42
+ .get(`https://sso-app-merchant-dev.vercel.app/api/${storeHash}/okta/${channelId}/saml`, {
43
+ withCredentials: true,
44
+ })
48
45
  .then((response) => {
49
46
  const data = response.data;
50
47
 
@@ -52,34 +49,43 @@ export function OktaSamlButton({ isSandbox, storeHash, channelId }) {
52
49
 
53
50
  setButtonName(data.button_name);
54
51
  setRedirectUrl(data.redirect_url);
55
- })
52
+
53
+ })
56
54
  .catch((error) => {
57
55
  console.error("Error fetching data:", error);
58
56
  });
59
57
  }, []);
60
58
 
61
59
  return (
62
- <SsoButtonPlaceholder buttonText={buttonName} loginUrl={redirectUrl} />
60
+ <SsoButtonPlaceholder
61
+ buttonText={buttonName}
62
+ loginUrl={redirectUrl}
63
+ />
63
64
  );
64
65
  }
65
-
66
- export function EntraSamlButton({
67
- loginUrl = "",
68
- isSandbox = false,
69
- storeHash = "",
70
- }) {
71
- const [redirectUrl, setRedirectUrl] = useState(loginUrl);
66
+ export function EntraSamlButton({ isSandbox, storeHash, channelId }) {
67
+ const [buttonName, setButtonName] = useState("Login With Entra");
68
+ const [redirectUrl, setRedirectUrl] = useState("");
72
69
 
73
70
  useEffect(() => {
74
- if (isSandbox && storeHash) {
75
- setRedirectUrl(`https://sso-app-merchant-dev.vercel.app/api/entra/login`);
76
- }
77
- }, [isSandbox, storeHash]);
71
+ axios
72
+ .get(`https://sso-app-merchant-dev.vercel.app/${storeHash}/entra/${channelId}/saml`, {
73
+ withCredentials: true,
74
+ })
75
+ .then((response) => {
76
+ const data = response.data;
77
+ setButtonName(data.button_name);
78
+ setRedirectUrl(data.redirect_url);
79
+ })
80
+ .catch((error) => {
81
+ console.error("Error fetching Entra SSO data:", error);
82
+ });
83
+ }, [storeHash, channelId]);
78
84
 
79
85
  return (
80
- <SsoButtonPlaceholder
86
+ <SsoButtonPlaceholder
81
87
  buttonText="Login With Entra"
82
88
  loginUrl={redirectUrl}
83
89
  />
84
90
  );
85
- }
91
+ }