@asaleh37/ui-base 1.1.5 → 1.1.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asaleh37/ui-base",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -10,7 +10,6 @@ import { AppInfo, AppInfoActions } from "../redux/features/common/AppInfoSlice";
10
10
 
11
11
  const App: React.FC<AppInfo> = (props: AppInfo) => {
12
12
  const dispatch = useDispatch();
13
- console.log("App Info", props);
14
13
  const AppLayoutState = useSelector((state: RootState) => state.AppLayout);
15
14
  let themeOptions = { ...LightThemeOptions };
16
15
  if (AppLayoutState.themeMode === "dark") {
@@ -26,7 +25,7 @@ const App: React.FC<AppInfo> = (props: AppInfo) => {
26
25
  }, []);
27
26
  return (
28
27
  <ThemeProvider theme={theme}>
29
- {props?.apiBaseUrl ? <Layout /> : <>No Info Yet</>}
28
+ <Layout />
30
29
  </ThemeProvider>
31
30
  );
32
31
  };
@@ -69,32 +69,34 @@ const Login: React.FC = () => {
69
69
  );
70
70
  const loginTheme = createTheme(DarkThemeOptions);
71
71
  const checkUserSession = async () => {
72
- if (userSession.isAuthenticated == null) {
73
- try {
74
- let response = await axios.get(
75
- `${appInfo.apiBaseUrl}/api/auth/userInfo`,
76
- {
77
- withCredentials: true,
72
+ if (appInfo?.apiBaseUrl) {
73
+ if (userSession.isAuthenticated == null) {
74
+ try {
75
+ let response = await axios.get(
76
+ `${appInfo.apiBaseUrl}/api/auth/userInfo`,
77
+ {
78
+ withCredentials: true,
79
+ }
80
+ );
81
+ if (response != null && response.data != null) {
82
+ const UserSession = {
83
+ isAuthenticated: true,
84
+ authorities: response.data.authorities,
85
+ userProfile: response.data,
86
+ };
87
+ dispatch(UserSessionActions.setAuthenticated(UserSession));
88
+ } else {
89
+ dispatch(UserSessionActions.setUnAuthenticated());
78
90
  }
79
- );
80
- if (response != null && response.data != null) {
81
- const UserSession = {
82
- isAuthenticated: true,
83
- authorities: response.data.authorities,
84
- userProfile: response.data,
85
- };
86
- dispatch(UserSessionActions.setAuthenticated(UserSession));
87
- } else {
91
+ } catch (error) {
88
92
  dispatch(UserSessionActions.setUnAuthenticated());
89
93
  }
90
- } catch (error) {
91
- dispatch(UserSessionActions.setUnAuthenticated());
92
94
  }
93
95
  }
94
96
  };
95
97
  useEffect(() => {
96
98
  checkUserSession();
97
- }, []);
99
+ }, [appInfo]);
98
100
  return (
99
101
  <ThemeProvider theme={loginTheme}>
100
102
  <Paper