@asaleh37/ui-base 1.1.6 → 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.6",
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
  };
@@ -36,8 +36,6 @@ const Login: React.FC = () => {
36
36
  }
37
37
  setIsLoginInProcess(true);
38
38
  let response: any = null;
39
- console.log("login appinfo", appInfo);
40
- debugger;
41
39
  try {
42
40
  response = await axios.post(
43
41
  `${appInfo.apiBaseUrl}/api/auth/login`,
@@ -71,32 +69,34 @@ const Login: React.FC = () => {
71
69
  );
72
70
  const loginTheme = createTheme(DarkThemeOptions);
73
71
  const checkUserSession = async () => {
74
- if (userSession.isAuthenticated == null) {
75
- try {
76
- let response = await axios.get(
77
- `${appInfo.apiBaseUrl}/api/auth/userInfo`,
78
- {
79
- 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());
80
90
  }
81
- );
82
- if (response != null && response.data != null) {
83
- const UserSession = {
84
- isAuthenticated: true,
85
- authorities: response.data.authorities,
86
- userProfile: response.data,
87
- };
88
- dispatch(UserSessionActions.setAuthenticated(UserSession));
89
- } else {
91
+ } catch (error) {
90
92
  dispatch(UserSessionActions.setUnAuthenticated());
91
93
  }
92
- } catch (error) {
93
- dispatch(UserSessionActions.setUnAuthenticated());
94
94
  }
95
95
  }
96
96
  };
97
97
  useEffect(() => {
98
98
  checkUserSession();
99
- }, []);
99
+ }, [appInfo]);
100
100
  return (
101
101
  <ThemeProvider theme={loginTheme}>
102
102
  <Paper