@asaleh37/ui-base 1.1.3 → 1.1.5

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.3",
3
+ "version": "1.1.5",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -11,7 +11,6 @@ import { AppInfo, AppInfoActions } from "../redux/features/common/AppInfoSlice";
11
11
  const App: React.FC<AppInfo> = (props: AppInfo) => {
12
12
  const dispatch = useDispatch();
13
13
  console.log("App Info", props);
14
- dispatch(AppInfoActions.setAppInfo(props));
15
14
  const AppLayoutState = useSelector((state: RootState) => state.AppLayout);
16
15
  let themeOptions = { ...LightThemeOptions };
17
16
  if (AppLayoutState.themeMode === "dark") {
@@ -23,10 +22,11 @@ const App: React.FC<AppInfo> = (props: AppInfo) => {
23
22
  });
24
23
  useEffect(() => {
25
24
  document.title = props.documentTitle;
25
+ dispatch(AppInfoActions.setAppInfo(props));
26
26
  }, []);
27
27
  return (
28
28
  <ThemeProvider theme={theme}>
29
- <Layout />
29
+ {props?.apiBaseUrl ? <Layout /> : <>No Info Yet</>}
30
30
  </ThemeProvider>
31
31
  );
32
32
  };
@@ -17,7 +17,7 @@ import { UserSessionActions } from "../../redux/features/common/UserSessionSlice
17
17
  import { DarkThemeOptions } from "../../theme/DarkThemeOptions";
18
18
 
19
19
  const Login: React.FC = () => {
20
- const appInfo = useSelector((state: RootState) => state.AppInfo);
20
+ const appInfo = useSelector((state: RootState) => state.AppInfo.value);
21
21
  const [username, setUsername] = useState("");
22
22
  const [password, setPassword] = useState("");
23
23
  const [isLoginInProcess, setIsLoginInProcess] = useState(false);
@@ -17,7 +17,7 @@ export interface APIRequest {
17
17
  const useAxios = () => {
18
18
  const mask = useLoadingMask();
19
19
  const apiBaseUrl = useSelector(
20
- (state: RootState) => state.AppInfo.apiBaseUrl
20
+ (state: RootState) => state.AppInfo.value.apiBaseUrl
21
21
  );
22
22
  const axiosInstance = axios.create({
23
23
  baseURL: apiBaseUrl,
@@ -34,7 +34,7 @@ const Puller = styled("div")(({ theme }) => ({
34
34
  export default function MobileDrawer(props: Props) {
35
35
  const { window } = props;
36
36
  const AppLayout = useSelector((state: RootState) => state.AppLayout);
37
- const AppInfo = useSelector((state: RootState) => state.AppInfo);
37
+ const AppInfo = useSelector((state: RootState) => state.AppInfo.value);
38
38
  const dispatch = useDispatch();
39
39
  const toggleDrawer = (newState: boolean) => {
40
40
  dispatch(AppLayoutActions.setSideBarState(newState));
@@ -13,7 +13,7 @@ import {
13
13
  import NavigationTree from "./NavigationTree";
14
14
 
15
15
  const SideBar: React.FC = () => {
16
- const AppInfo = useSelector((state: RootState) => state.AppInfo);
16
+ const AppInfo = useSelector((state: RootState) => state.AppInfo.value);
17
17
  const theme = useTheme();
18
18
  const AppLayout = useSelector((state: RootState) => state.AppLayout);
19
19
  const dispatch = useDispatch();
@@ -51,7 +51,7 @@ const AppBar = styled(MuiAppBar, {
51
51
  });
52
52
 
53
53
  const TopBar: React.FC = () => {
54
- const AppInfo = useSelector((state: RootState) => state.AppInfo);
54
+ const AppInfo = useSelector((state: RootState) => state.AppInfo.value);
55
55
  const AppLayout = useSelector((state: RootState) => state.AppLayout);
56
56
  const UserSession = useSelector((state: RootState) => state.UserSession);
57
57
  const { handleGetRequest } = useAxios();
@@ -1,19 +1,25 @@
1
1
  import { createSlice } from "@reduxjs/toolkit";
2
2
 
3
3
  export type AppInfo = {
4
- documentTitle: string;
5
- apiBaseUrl: string;
6
- appName: string;
7
- appVersion: string;
8
- appLogo: any;
4
+ documentTitle: string | null;
5
+ apiBaseUrl: string | null;
6
+ appName: string | null;
7
+ appVersion: string | null;
8
+ appLogo: any | null;
9
9
  };
10
10
 
11
- const initialState: AppInfo = {
12
- documentTitle: "",
13
- apiBaseUrl: "",
14
- appName: "",
15
- appVersion: "",
16
- appLogo: null,
11
+ export type AppInfoProp = {
12
+ value: AppInfo;
13
+ };
14
+
15
+ const initialState: AppInfoProp = {
16
+ value: {
17
+ documentTitle: null,
18
+ apiBaseUrl: null,
19
+ appName: null,
20
+ appVersion: null,
21
+ appLogo: null,
22
+ },
17
23
  };
18
24
 
19
25
  const AppInfoSlice = createSlice({
@@ -21,7 +27,7 @@ const AppInfoSlice = createSlice({
21
27
  initialState: initialState,
22
28
  reducers: {
23
29
  setAppInfo: (state, action) => {
24
- state = action.payload;
30
+ state.value = action.payload;
25
31
  },
26
32
  },
27
33
  });