@campxdev/campx-web-utils 0.4.3 → 0.4.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/export.ts CHANGED
@@ -4,4 +4,4 @@ export * from './src/context/export';
4
4
  export * from './src/hooks/export';
5
5
  export * from './src/layout/AppLayout';
6
6
  export * from './src/selectors/export';
7
- export * from './src/utils/export';
7
+ export * from './src/utils/constants';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@campxdev/campx-web-utils",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "peerDependencies": {
7
- "@campxdev/react-blueprint": ">=1.7.0",
7
+ "@campxdev/react-blueprint": ">=1.7.9",
8
8
  "@emotion/react": ">=^11.13.3",
9
9
  "@emotion/styled": ">=^11.13.0",
10
10
  "@mui/icons-material": ">=6.1.5",
@@ -14,7 +14,7 @@
14
14
  "react-redux": "=>9.1.2"
15
15
  },
16
16
  "dependencies": {
17
- "@campxdev/react-blueprint": "1.7.0",
17
+ "@campxdev/react-blueprint": "1.7.9",
18
18
  "@hookform/resolvers": "^3.9.0",
19
19
  "@mui/x-date-pickers": "^7.22.1",
20
20
  "axios": "^1.7.2",
@@ -1,6 +1,7 @@
1
1
  import { Button, TextField } from '@campxdev/react-blueprint';
2
2
  import { useState } from 'react';
3
3
  import { EmployeesSelector } from './selectors/EmployeesSelector';
4
+ import { PrintFormatSelector } from './selectors/export';
4
5
 
5
6
  function AppContent() {
6
7
  const [value, setValue] = useState('63b810ee995d6d64f4a248de');
@@ -20,6 +21,8 @@ function AppContent() {
20
21
  <div style={{ height: '300px' }}></div>
21
22
 
22
23
  <TextField />
24
+
25
+ <PrintFormatSelector onChange={() => {}} />
23
26
  </>
24
27
  );
25
28
  }
@@ -17,7 +17,7 @@ import { StyledMenuItem } from '@campxdev/react-blueprint/src/components/Navigat
17
17
  import { Visibility, VisibilityOff } from '@mui/icons-material';
18
18
  import { toast } from 'react-toastify';
19
19
  import { axios } from '../config/axios';
20
- import { isDevelopment } from '../utils/export';
20
+ import { isDevelopment } from '../utils/constants';
21
21
 
22
22
  interface PasswordVisibilityState {
23
23
  oldPassword: boolean;
@@ -1,13 +1,7 @@
1
1
  import Axios, { InternalAxiosRequestConfig } from 'axios';
2
2
  import Cookies from 'js-cookie';
3
3
  import { ApplicationStore } from '../context/application-store';
4
- import { isDevelopment } from '../utils/export';
5
-
6
- const tenantCode =
7
- window.location.hostname === 'localhost'
8
- ? Cookies.get('campx_tenant')
9
- : window.location.hostname.split('.')[0];
10
- const institutionCode = window.location.pathname.split('/')[1];
4
+ import { institutionCode, isDevelopment, tenantCode } from '../utils/constants';
11
5
 
12
6
  export const formatParams = (params: any) => {
13
7
  return Object.fromEntries(
@@ -6,11 +6,11 @@ import {
6
6
  configureStore,
7
7
  ReducersMapObject,
8
8
  } from '@reduxjs/toolkit';
9
- import Cookies from 'js-cookie';
10
9
  import { ReactNode, useEffect } from 'react';
11
10
  import { QueryClient, QueryClientProvider } from 'react-query';
12
11
  import { Provider } from 'react-redux';
13
12
  import { BrowserRouter } from 'react-router-dom';
13
+ import { institutionCode, tenantCode } from '../utils/constants';
14
14
  import { ConfirmDialogProvider } from './ConfirmDialogProvider';
15
15
  import { SnackbarProvider } from './SnackbarProvider';
16
16
 
@@ -35,14 +35,6 @@ export const Providers = ({
35
35
  },
36
36
  });
37
37
 
38
- var tenantCode =
39
- window.location.hostname === 'localhost'
40
- ? Cookies.get('campx_tenant')
41
- : window.location.hostname.split('.')[0];
42
- var institutionCode =
43
- window.location.pathname.split('/')[1] !== ''
44
- ? window.location.pathname.split('/')[1]
45
- : Cookies.get('campx_institution');
46
38
  var baseName = tenantCode && institutionCode ? `/${institutionCode}` : '/';
47
39
  useEffect(() => {
48
40
  if (window.location.pathname === '/' && institutionCode && tenantCode) {
@@ -1,11 +1,12 @@
1
1
  import { AppHeader, Sidebar, Spinner } from '@campxdev/react-blueprint';
2
2
  import { SideMenuItemProps } from '@campxdev/react-blueprint/src/components/Navigation/Sidebar/Sidebar';
3
- import { Box, Stack, useTheme } from '@mui/material';
3
+ import { Box, Stack, styled, useMediaQuery, useTheme } from '@mui/material';
4
4
  import { motion } from 'framer-motion';
5
5
  import Cookies from 'js-cookie';
6
6
  import { Suspense, useState } from 'react';
7
7
  import { axios } from '../config/axios';
8
8
  import { ErrorBoundary } from '../context/export';
9
+ import { Margin } from '@mui/icons-material';
9
10
 
10
11
  interface Props {
11
12
  children?: React.ReactNode;
@@ -14,6 +15,7 @@ interface Props {
14
15
  handleLogout?: any;
15
16
  userName?: string;
16
17
  designation?: string;
18
+ clientName?: string;
17
19
  }
18
20
 
19
21
  export const AppLayout: React.FC<Props> = ({
@@ -23,9 +25,11 @@ export const AppLayout: React.FC<Props> = ({
23
25
  handleLogout,
24
26
  userName = '',
25
27
  designation = '',
28
+ clientName = 'Ohio State University',
26
29
  }) => {
27
30
  const [collapsed, setCollapsed] = useState(true);
28
31
  const theme = useTheme();
32
+ const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
29
33
 
30
34
  function logout() {
31
35
  axios
@@ -42,10 +46,7 @@ export const AppLayout: React.FC<Props> = ({
42
46
  }
43
47
 
44
48
  return (
45
- <Stack
46
- sx={{ backgroundColor: theme.palette.surface.defaultBackground }}
47
- direction={'row'}
48
- >
49
+ <AppLayoutContainer>
49
50
  <Sidebar menu={menu} collapsed={collapsed} setCollapsed={setCollapsed} />
50
51
  <motion.div
51
52
  animate={{
@@ -54,50 +55,71 @@ export const AppLayout: React.FC<Props> = ({
54
55
  transition={{ duration: 0.3, ease: 'circOut' }}
55
56
  style={{
56
57
  margin: '12px 12px 12px 0px',
57
- width: 'calc(100% - 84px)',
58
+ width: isSmallScreen ? '100%' : 'calc(100% - 84px)',
59
+ display: isSmallScreen ? 'contents' : 'block',
58
60
  }}
59
61
  >
60
- <Stack gap="12px">
61
- <AppHeader
62
- actions={[]}
63
- collapsed={collapsed}
64
- showActiveDevices={false}
65
- onLogoutClick={handleLogout ?? logout}
66
- clientName={''}
67
- userFullName={userName}
68
- designation={designation}
69
- />
70
- <Box
71
- sx={{
72
- // backgroundColor: theme.palette.surface.paperBackground,
73
- borderRadius: '8px',
74
- height: 'calc(100vh - 96px)',
75
- overflowY: 'scroll',
76
- '&::-webkit-scrollbar': {
77
- width: '0.5em',
78
- height: '0.2em',
79
- },
62
+ <AppHeader
63
+ actions={[]}
64
+ collapsed={collapsed}
65
+ showActiveDevices={false}
66
+ onLogoutClick={handleLogout ?? logout}
67
+ clientName={''}
68
+ userFullName={userName}
69
+ designation={designation}
70
+ {...(isSmallScreen && {
71
+ profileSx: { width: 32, height: 32, fontSize: '12px' },
72
+ })}
73
+ />
74
+ <OuletContainer
75
+ sx={{
76
+ // backgroundColor: theme.palette.surface.paperBackground,
80
77
 
81
- '&::-webkit-scrollbar-thumb': {
82
- backgroundColor: theme.palette.primary.light,
83
- borderRadius: '3px',
84
-
85
- '&:hover': {
86
- backgroundColor: theme.palette.primary.main,
87
- },
88
- },
89
- ...mainContainerSx,
90
- }}
91
- onClick={() => {
92
- setCollapsed(true);
93
- }}
94
- >
95
- <Suspense fallback={<Spinner />}>
96
- <ErrorBoundary>{children}</ErrorBoundary>
97
- </Suspense>
98
- </Box>
99
- </Stack>
78
+ ...mainContainerSx,
79
+ }}
80
+ onClick={() => {
81
+ setCollapsed(true);
82
+ }}
83
+ >
84
+ <Suspense fallback={<Spinner />}>
85
+ <ErrorBoundary>{children}</ErrorBoundary>
86
+ </Suspense>
87
+ </OuletContainer>
100
88
  </motion.div>
101
- </Stack>
89
+ </AppLayoutContainer>
102
90
  );
103
91
  };
92
+
93
+ const AppLayoutContainer = styled(Stack)(({ theme }: { theme?: any }) => ({
94
+ flexDirection: 'row',
95
+ backgroundColor: theme.palette.surface.defaultBackground,
96
+
97
+ [theme.breakpoints.down('md')]: {
98
+ flexWrap: 'wrap',
99
+ },
100
+ }));
101
+
102
+ const OuletContainer = styled(Box)(({ theme }: { theme?: any }) => ({
103
+ borderRadius: '8px',
104
+ height: 'calc(100vh - 96px)',
105
+ overflowY: 'scroll',
106
+ width: '100%',
107
+
108
+ [theme.breakpoints.down('md')]: {
109
+ margin: '0px 12px 12px 12px',
110
+ },
111
+
112
+ '&::-webkit-scrollbar': {
113
+ width: '0.5em',
114
+ height: '0.2em',
115
+ },
116
+
117
+ '&::-webkit-scrollbar-thumb': {
118
+ backgroundColor: theme.palette.primary.light,
119
+ borderRadius: '3px',
120
+
121
+ '&:hover': {
122
+ backgroundColor: theme.palette.primary.main,
123
+ },
124
+ },
125
+ }));
@@ -0,0 +1,18 @@
1
+ import Cookies from 'js-cookie';
2
+
3
+ const tenantCookie = Cookies.get('campx_tenant');
4
+ const institutionCookie = Cookies.get('campx_institution');
5
+
6
+ export const isLocal = window.location.hostname === 'localhost';
7
+
8
+ export const isDevelopment = process.env.NODE_ENV === 'development' || isLocal;
9
+
10
+ export const tenantCode = isLocal
11
+ ? tenantCookie
12
+ : window.location.hostname.split('.')[0];
13
+
14
+ // if url searched is aupulse.campx.in then redirect to aupulse.campx.in/aupulse
15
+ export const institutionCode =
16
+ window.location.pathname.split('/')[1] !== ''
17
+ ? window.location.pathname.split('/')[1]
18
+ : institutionCookie;
@@ -1,3 +0,0 @@
1
- export const isDevelopment =
2
- process.env.NODE_ENV === 'development' ||
3
- window.location.hostname === 'localhost';