@snapdragonsnursery/react-components 1.0.6 → 1.0.8
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/package.json +3 -2
- package/src/AuthButtons.jsx +3 -25
- package/src/LandingPage.jsx +101 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snapdragonsnursery/react-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"react-dom": "^18.3.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@azure/msal-react": ">=1.0.0"
|
|
28
|
+
"@azure/msal-react": ">=1.0.0",
|
|
29
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
29
30
|
},
|
|
30
31
|
"module": "src/index.js",
|
|
31
32
|
"files": [
|
package/src/AuthButtons.jsx
CHANGED
|
@@ -180,32 +180,10 @@ function AuthButtons({ theme, setTheme, authState, setAuthState }) {
|
|
|
180
180
|
trackAuthEvent("logout", true);
|
|
181
181
|
clearUserContext();
|
|
182
182
|
|
|
183
|
-
//
|
|
184
|
-
instance.
|
|
185
|
-
|
|
186
|
-
// Clear any stored tokens from localStorage/sessionStorage
|
|
187
|
-
const msalKeys = Object.keys(localStorage).filter((key) =>
|
|
188
|
-
key.startsWith("msal.")
|
|
189
|
-
);
|
|
190
|
-
msalKeys.forEach((key) => localStorage.removeItem(key));
|
|
191
|
-
|
|
192
|
-
const msalSessionKeys = Object.keys(sessionStorage).filter((key) =>
|
|
193
|
-
key.startsWith("msal.")
|
|
194
|
-
);
|
|
195
|
-
msalSessionKeys.forEach((key) => sessionStorage.removeItem(key));
|
|
196
|
-
|
|
197
|
-
// Force a re-render by updating the auth state
|
|
198
|
-
setAuthState({
|
|
199
|
-
isAuthenticated: false,
|
|
200
|
-
accountsCount: 0,
|
|
201
|
-
account: null,
|
|
202
|
-
instance: null,
|
|
183
|
+
// Use MSAL's built-in logout with redirect
|
|
184
|
+
await instance.logoutRedirect({
|
|
185
|
+
postLogoutRedirectUri: "/", // or your desired landing page
|
|
203
186
|
});
|
|
204
|
-
|
|
205
|
-
// Clear profile picture
|
|
206
|
-
setProfilePicture(null);
|
|
207
|
-
|
|
208
|
-
console.log("Local logout completed - user remains on site");
|
|
209
187
|
} catch (error) {
|
|
210
188
|
console.error("Logout failed:", error);
|
|
211
189
|
trackError(error, { context: "logout" });
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// LandingPage.jsx
|
|
2
|
+
//
|
|
3
|
+
// A reusable landing page component for Microsoft authentication
|
|
4
|
+
// Designed to work across different applications with customizable branding
|
|
5
|
+
//
|
|
6
|
+
// Example usage:
|
|
7
|
+
// import LandingPage from './LandingPage';
|
|
8
|
+
// <LandingPage
|
|
9
|
+
// logoUrl="https://your-logo-url.png"
|
|
10
|
+
// appName="Your App Name"
|
|
11
|
+
// appDescription="Your app description"
|
|
12
|
+
// onSignIn={handleSignIn}
|
|
13
|
+
// companyName="Your Company"
|
|
14
|
+
// />
|
|
15
|
+
//
|
|
16
|
+
// Props:
|
|
17
|
+
// - logoUrl: URL to the company logo (required)
|
|
18
|
+
// - appName: Name of the application (required)
|
|
19
|
+
// - appDescription: Description of the application (optional)
|
|
20
|
+
// - onSignIn: Function to handle sign-in click (optional)
|
|
21
|
+
// - companyName: Company name for footer text (optional)
|
|
22
|
+
// - backgroundColor: Custom background gradient (optional)
|
|
23
|
+
// - cardClassName: Additional CSS classes for the card (optional)
|
|
24
|
+
|
|
25
|
+
import React from 'react';
|
|
26
|
+
|
|
27
|
+
const LandingPage = ({
|
|
28
|
+
logoUrl,
|
|
29
|
+
appName,
|
|
30
|
+
appDescription = "Manage your application efficiently",
|
|
31
|
+
onSignIn,
|
|
32
|
+
companyName = "Your Company",
|
|
33
|
+
backgroundColor = "bg-gradient-to-br from-blue-50 to-indigo-100",
|
|
34
|
+
cardClassName = ""
|
|
35
|
+
}) => {
|
|
36
|
+
const handleSignInClick = () => {
|
|
37
|
+
if (onSignIn) {
|
|
38
|
+
onSignIn();
|
|
39
|
+
} else {
|
|
40
|
+
console.log('Sign in with Microsoft clicked');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div className={`min-h-screen ${backgroundColor} flex items-center justify-center p-4`}>
|
|
46
|
+
<div className={`max-w-md w-full bg-white rounded-2xl shadow-xl p-8 ${cardClassName}`}>
|
|
47
|
+
{/* Logo Section */}
|
|
48
|
+
<div className="text-center mb-8">
|
|
49
|
+
<img
|
|
50
|
+
src={logoUrl}
|
|
51
|
+
alt={`${companyName} Logo`}
|
|
52
|
+
className="h-16 mx-auto mb-4"
|
|
53
|
+
/>
|
|
54
|
+
<h1 className="text-2xl font-bold text-gray-900 mb-2">
|
|
55
|
+
{appName}
|
|
56
|
+
</h1>
|
|
57
|
+
<p className="text-gray-600">
|
|
58
|
+
{appDescription}
|
|
59
|
+
</p>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
{/* Sign In Section */}
|
|
63
|
+
<div className="space-y-6">
|
|
64
|
+
<div className="text-center">
|
|
65
|
+
<svg className="h-12 w-12 text-blue-600 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
66
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
|
|
67
|
+
</svg>
|
|
68
|
+
<h2 className="text-xl font-semibold text-gray-900 mb-2">
|
|
69
|
+
Welcome Back
|
|
70
|
+
</h2>
|
|
71
|
+
<p className="text-gray-600 text-sm">
|
|
72
|
+
Sign in with your Microsoft account to access the system
|
|
73
|
+
</p>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
{/* Microsoft Sign In Button */}
|
|
77
|
+
<button
|
|
78
|
+
onClick={handleSignInClick}
|
|
79
|
+
className="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition-colors duration-200 flex items-center justify-center space-x-2"
|
|
80
|
+
>
|
|
81
|
+
{/* Official Microsoft logo SVG */}
|
|
82
|
+
<svg className="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
83
|
+
<rect x="2" y="2" width="9" height="9" fill="#F35325"/>
|
|
84
|
+
<rect x="13" y="2" width="9" height="9" fill="#81BC06"/>
|
|
85
|
+
<rect x="2" y="13" width="9" height="9" fill="#05A6F0"/>
|
|
86
|
+
<rect x="13" y="13" width="9" height="9" fill="#FFBA08"/>
|
|
87
|
+
</svg>
|
|
88
|
+
<span>Sign in with Microsoft</span>
|
|
89
|
+
</button>
|
|
90
|
+
|
|
91
|
+
{/* Additional Info */}
|
|
92
|
+
<div className="text-center text-xs text-gray-500">
|
|
93
|
+
<p>This application is for {companyName} employees only</p>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default LandingPage;
|
package/src/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { default as AuthButtons } from "./AuthButtons";
|
|
|
2
2
|
export { default as ThemeToggle } from "./ThemeToggle";
|
|
3
3
|
export { default as ChildSearchModal } from "./ChildSearchModal";
|
|
4
4
|
export { default as ThemeToggleTest } from "./ThemeToggleTest";
|
|
5
|
+
export { default as LandingPage } from "./LandingPage";
|
|
5
6
|
export { configureTelemetry } from "./telemetry";
|