@campxdev/campx-web-utils 0.2.7 → 0.2.9

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
@@ -2,3 +2,4 @@ export * from './src/config/axios';
2
2
  export * from './src/context/export';
3
3
  export * from './src/hooks/export';
4
4
  export * from './src/utils/export';
5
+ export * from './src/Layout/AppLayout';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@campxdev/campx-web-utils",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
7
- "@campxdev/react-blueprint": "^1.2.0",
7
+ "@campxdev/react-blueprint": "^1.2.3",
8
8
  "@hookform/resolvers": "^3.9.0",
9
9
  "@mui/x-date-pickers": "^7.12.1",
10
10
  "@testing-library/jest-dom": "^5.14.1",
@@ -26,6 +26,7 @@
26
26
  "react-scripts": "5.0.1",
27
27
  "react-toastify": "^9.0.1",
28
28
  "typescript": "^4.4.2",
29
+ "uuid": "^10.0.0",
29
30
  "web-vitals": "^2.1.0",
30
31
  "yup": "^1.4.0"
31
32
  },
@@ -1,11 +1,56 @@
1
- import { Outlet } from 'react-router-dom';
1
+ import { AppHeader, Sidebar, Spinner } from '@campxdev/react-blueprint';
2
+ import { SideMenuItemProps } from '@campxdev/react-blueprint/src/components/Navigation/Sidebar/Sidebar';
3
+ import { Box, Stack, useTheme } from '@mui/material';
4
+ import { Suspense, useState } from 'react';
5
+ import { ErrorBoundary } from '../context/export';
6
+
7
+ interface Props {
8
+ children?: React.ReactNode;
9
+ menu: SideMenuItemProps[];
10
+ mainContainerSx?: any;
11
+ }
12
+
13
+ export const AppLayout: React.FC<Props> = ({
14
+ children,
15
+ menu,
16
+ mainContainerSx,
17
+ }) => {
18
+ const [collapsed, setCollapsed] = useState(true);
19
+ const theme = useTheme();
2
20
 
3
- const AppLayout = () => {
4
21
  return (
5
- <>
6
- <Outlet />
7
- </>
22
+ <Stack
23
+ sx={{ backgroundColor: theme.palette.surface.defaultBackground }}
24
+ direction={'row'}
25
+ >
26
+ <Sidebar menu={menu} collapsed={collapsed} setCollapsed={setCollapsed} />
27
+ <Stack
28
+ margin="12px 12px 12px 0px"
29
+ gap="12px"
30
+ width={collapsed ? 'calc(100% - 84px)' : 'calc(100% - 278px)'}
31
+ >
32
+ <AppHeader
33
+ actions={[]}
34
+ collapsed={collapsed}
35
+ showActiveDevices={false}
36
+ clientName={''}
37
+ userFullName={''}
38
+ />
39
+ <Box
40
+ sx={{
41
+ borderRadius: '8px',
42
+ height: '-webkit-fill-available',
43
+ ...mainContainerSx,
44
+ }}
45
+ onClick={() => {
46
+ setCollapsed(true);
47
+ }}
48
+ >
49
+ <Suspense fallback={<Spinner />}>
50
+ <ErrorBoundary>{children}</ErrorBoundary>
51
+ </Suspense>
52
+ </Box>
53
+ </Stack>
54
+ </Stack>
8
55
  );
9
56
  };
10
-
11
- export default AppLayout;
@@ -1,11 +1,11 @@
1
1
  import { Navigate } from 'react-router-dom';
2
2
  import AppContent from '../AppContent';
3
- import AppLayout from '../Layout/AppLayout';
3
+ import { AppLayout } from '../Layout/AppLayout';
4
4
 
5
5
  export const mainRoutes = [
6
6
  {
7
7
  path: '/',
8
- element: <AppLayout />,
8
+ element: <AppLayout menu={[]} />,
9
9
  children: [
10
10
  {
11
11
  index: true,
@@ -9,6 +9,8 @@ interface ConfirmStateProps {
9
9
  onConfirm: () => void,
10
10
  onCancel: () => void,
11
11
  type?: ConfirmDialogType,
12
+ confirmButtonText?: string,
13
+ cancelButtonText?: string,
12
14
  ) => void;
13
15
  }
14
16
 
@@ -29,6 +31,8 @@ export const ConfirmDialogProvider = ({
29
31
  onConfirm: () => void,
30
32
  onCancel: () => void,
31
33
  type: ConfirmDialogType = 'confirm',
34
+ confirmButtonText?: string,
35
+ cancelButtonText?: string,
32
36
  ) => {
33
37
  ApplicationStore.update((s) => {
34
38
  s.confirmDialog = {
@@ -38,6 +42,8 @@ export const ConfirmDialogProvider = ({
38
42
  onConfirm,
39
43
  onCancel,
40
44
  type,
45
+ confirmButtonText,
46
+ cancelButtonText,
41
47
  };
42
48
  });
43
49
  };
@@ -56,6 +62,8 @@ export const ConfirmDialogProvider = ({
56
62
  title={confirmDialog.title}
57
63
  message={confirmDialog.message}
58
64
  type={confirmDialog.type}
65
+ confirmButtonText={confirmDialog.confirmButtonText}
66
+ cancelButtonText={confirmDialog.cancelButtonText}
59
67
  onConfirm={() => {
60
68
  confirmDialog.onConfirm();
61
69
  handleCloseDialog();
@@ -109,8 +109,8 @@ export const Login = ({ close }: { close: () => void }) => {
109
109
  handleSubmit,
110
110
  control,
111
111
  formState: { errors },
112
- } = useForm<LoginDetails>({
113
- resolver: yupResolver<LoginDetails>(validationSchema),
112
+ } = useForm({
113
+ resolver: yupResolver(validationSchema),
114
114
  });
115
115
 
116
116
  const { mutate, isLoading } = useMutation(performLogin, {
@@ -15,6 +15,8 @@ export type ApplicationStoreType = {
15
15
  onConfirm: () => void;
16
16
  onCancel: () => void;
17
17
  type: ConfirmDialogType;
18
+ confirmButtonText?: string;
19
+ cancelButtonText?: string;
18
20
  };
19
21
  };
20
22
 
@@ -5,6 +5,8 @@ const defaultConfirmDialogState = {
5
5
  isOpen: false,
6
6
  title: '',
7
7
  message: '',
8
+ confirmButtonText: '',
9
+ cancelButtonText: '',
8
10
  type: 'confirm' as ConfirmDialogType,
9
11
  onConfirm: () => {},
10
12
  onCancel: () => {},
@@ -14,10 +16,14 @@ const useConfirm = () => {
14
16
  const isConfirmed = ({
15
17
  title,
16
18
  message,
19
+ confirmButtonText,
20
+ cancelButtonText,
17
21
  type = 'confirm',
18
22
  }: {
19
23
  title: string;
20
24
  message: string;
25
+ confirmButtonText?: string;
26
+ cancelButtonText?: string;
21
27
  type?: ConfirmDialogType;
22
28
  }): Promise<boolean> =>
23
29
  new Promise((resolve) => {
@@ -26,6 +32,8 @@ const useConfirm = () => {
26
32
  isOpen: true,
27
33
  title,
28
34
  message,
35
+ confirmButtonText,
36
+ cancelButtonText,
29
37
  type,
30
38
  onConfirm: () => {
31
39
  resolve(true);
package/tsconfig.json CHANGED
@@ -18,5 +18,5 @@
18
18
  "types": ["node"]
19
19
  },
20
20
  "include": ["src", "./types"],
21
- "exclude": ["node_modules", ".yalc"]
21
+ "exclude": [".yalc"]
22
22
  }