@campxdev/campx-web-utils 0.5.2 → 0.5.3

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,6 +2,6 @@ export * from './src/components/ChangePassword';
2
2
  export * from './src/config/axios';
3
3
  export * from './src/context/export';
4
4
  export * from './src/hooks/export';
5
- export * from './src/layout/AppLayout';
5
+ export * from './src/layout/AppLayout/AppLayout';
6
6
  export * from './src/selectors/export';
7
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.5.2",
3
+ "version": "0.5.3",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "peerDependencies": {
7
- "@campxdev/react-blueprint": ">=1.8.3",
7
+ "@campxdev/react-blueprint": ">=1.8.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.8.3",
17
+ "@campxdev/react-blueprint": "1.8.9",
18
18
  "@hookform/resolvers": "^3.9.0",
19
19
  "@mui/x-date-pickers": "^7.22.1",
20
20
  "axios": "^1.7.2",
@@ -4,9 +4,11 @@ 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 { ReactNode, Suspense, useState } from 'react';
7
- import { ChangePasswordDialog } from '../components/ChangePassword';
8
- import { axios } from '../config/axios';
9
- import { ErrorBoundary } from '../context/export';
7
+ import { ChangePasswordDialog } from '../../components/ChangePassword';
8
+ import { axios } from '../../config/axios';
9
+ import { ErrorBoundary } from '../../context/export';
10
+ import HelpDocs from './components/HelpDocs';
11
+ import { helpDocsConfig } from './components/helpDocsConfig';
10
12
 
11
13
  type Props = {
12
14
  actions?: ReactNode[];
@@ -51,6 +53,12 @@ export const AppLayout: React.FC<Props> = ({
51
53
  });
52
54
  }
53
55
 
56
+ const fullPath = window.location.pathname;
57
+ const pathSegments = fullPath.split('/').filter(Boolean);
58
+ const actualPath = pathSegments.slice(1).join('/');
59
+ const normalizedPath = actualPath.replace(/\/\d+/g, '/:id');
60
+ const helpDocsActions = helpDocsConfig[`/${normalizedPath}`]?.actions || [];
61
+
54
62
  return (
55
63
  <AppLayoutContainer>
56
64
  <Sidebar menu={menu} collapsed={collapsed} setCollapsed={setCollapsed} />
@@ -79,6 +87,7 @@ export const AppLayout: React.FC<Props> = ({
79
87
  profileSx: { width: 32, height: 32, fontSize: '12px' },
80
88
  })}
81
89
  />
90
+ {helpDocsActions.length > 0 && <HelpDocs actions={helpDocsActions} />}
82
91
  <OuletContainer
83
92
  sx={{
84
93
  // backgroundColor: theme.palette.surface.paperBackground,
@@ -102,9 +111,7 @@ const AppLayoutContainer = styled(Stack)(({ theme }: { theme?: any }) => ({
102
111
  flexDirection: 'row',
103
112
  backgroundColor: theme.palette.surface.defaultBackground,
104
113
 
105
- [theme.breakpoints.down('md')]: {
106
- flexWrap: 'wrap',
107
- },
114
+ [theme.breakpoints.down('md')]: { flexWrap: 'wrap' },
108
115
  }));
109
116
 
110
117
  const OuletContainer = styled(Box)(({ theme }: { theme?: any }) => ({
@@ -113,26 +120,19 @@ const OuletContainer = styled(Box)(({ theme }: { theme?: any }) => ({
113
120
  overflowY: 'scroll',
114
121
  width: '100%',
115
122
 
116
- '&::-webkit-scrollbar': {
117
- width: '0.5em',
118
- height: '0.2em',
119
- },
123
+ '&::-webkit-scrollbar': { width: '0.5em', height: '0.2em' },
120
124
 
121
125
  '&::-webkit-scrollbar-thumb': {
122
126
  backgroundColor: theme.palette.primary.light,
123
127
  borderRadius: '3px',
124
128
 
125
- '&:hover': {
126
- backgroundColor: theme.palette.primary.main,
127
- },
129
+ '&:hover': { backgroundColor: theme.palette.primary.main },
128
130
  },
129
131
 
130
132
  [theme.breakpoints.down('md')]: {
131
133
  margin: '0px 12px 12px 12px',
132
134
  height: 'calc(100vh - 118px)',
133
135
 
134
- '&::-webkit-scrollbar': {
135
- display: 'none',
136
- },
136
+ '&::-webkit-scrollbar': { display: 'none' },
137
137
  },
138
138
  }));
@@ -0,0 +1,114 @@
1
+ import { Icons } from '@campxdev/react-blueprint';
2
+ import { useTheme } from '@mui/material';
3
+ import Box from '@mui/material/Box';
4
+ import SpeedDial from '@mui/material/SpeedDial';
5
+ import SpeedDialAction from '@mui/material/SpeedDialAction';
6
+ import * as React from 'react';
7
+
8
+ interface HelpDocsActionType {
9
+ name: string;
10
+ onClick?: () => void;
11
+ backgroundColor?: string;
12
+ }
13
+
14
+ interface HelpDocsProps {
15
+ actions: HelpDocsActionType[];
16
+ }
17
+
18
+ const HelpDocs: React.FC<HelpDocsProps> = ({ actions }) => {
19
+ const theme = useTheme();
20
+ const [open, setOpen] = React.useState(false);
21
+
22
+ const handleOpen = () => setOpen(true);
23
+ const handleClose = () => setOpen(false);
24
+
25
+ return (
26
+ <Box
27
+ sx={{
28
+ position: 'fixed',
29
+ bottom: 26,
30
+ right: 0,
31
+ zIndex: 1000,
32
+ }}
33
+ >
34
+ <SpeedDial
35
+ ariaLabel="Custom Help Docs"
36
+ sx={{
37
+ position: 'absolute',
38
+ bottom: 6,
39
+ right: 42,
40
+ '& .MuiFab-primary': {
41
+ backgroundColor: theme.palette.highlight.highlightBlue,
42
+ borderRadius: '8px',
43
+ width: '50px',
44
+ height: '50px',
45
+ display: 'flex',
46
+ justifyContent: 'center',
47
+ alignItems: 'center',
48
+ '&:hover': {
49
+ backgroundColor: theme.palette.highlight.highlightBlue,
50
+ },
51
+ },
52
+ }}
53
+ icon={<Icons.HelpDocsIcon size={20} />}
54
+ onClose={handleClose}
55
+ onOpen={handleOpen}
56
+ open={open}
57
+ direction="left"
58
+ >
59
+ {actions.map((action: HelpDocsActionType) => (
60
+ <SpeedDialAction
61
+ key={action.name}
62
+ onClick={() => {
63
+ action.onClick?.();
64
+ handleClose();
65
+ }}
66
+ icon={
67
+ <span
68
+ style={{
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ justifyContent: 'center',
72
+ width: '100%',
73
+ height: '100%',
74
+ fontWeight: 'bold',
75
+ whiteSpace: 'nowrap',
76
+ overflow: 'hidden',
77
+ textOverflow: 'ellipsis',
78
+ }}
79
+ >
80
+ {action.name}
81
+ </span>
82
+ }
83
+ FabProps={{
84
+ sx: {
85
+ width: 'auto',
86
+ minWidth: '180px',
87
+ maxWidth: '280px',
88
+ padding: '8px 12px',
89
+ boxShadow: 'none',
90
+ height: '40px',
91
+ borderRadius: '8px',
92
+ backgroundColor: theme.palette.surface.defaultBackground,
93
+ color: theme.palette.text.primary,
94
+ fontWeight: 500,
95
+ fontFamily: 'Heebo',
96
+ fontSize: '12px',
97
+ whiteSpace: 'nowrap',
98
+ textAlign: 'right',
99
+ display: 'flex',
100
+ justifyContent: 'flex-end',
101
+ alignItems: 'center',
102
+ '&:hover': {
103
+ backgroundColor: theme.palette.surface.defaultBackground,
104
+ },
105
+ },
106
+ }}
107
+ />
108
+ ))}
109
+ </SpeedDial>
110
+ </Box>
111
+ );
112
+ };
113
+
114
+ export default HelpDocs;
@@ -0,0 +1,89 @@
1
+ export const helpDocsConfig: Record<
2
+ string,
3
+ { actions: { name: string; onClick: () => void }[] }
4
+ > = {
5
+ '/payments/exam-fees': {
6
+ actions: [
7
+ {
8
+ name: 'Know how to collect exam fee',
9
+ onClick: () =>
10
+ window.open('https://docs.campx.in/Workflows/collect_fee/', '_blank'),
11
+ },
12
+ ],
13
+ },
14
+ '/payments/student-permissions': {
15
+ actions: [
16
+ {
17
+ name: 'Know how to manage permissions',
18
+ onClick: () =>
19
+ window.open('https://docs.campx.in/Workflows/collect_fee/', '_blank'),
20
+ },
21
+ ],
22
+ },
23
+ '/exams/blocked-students': {
24
+ actions: [
25
+ {
26
+ name: 'Know how to block students',
27
+ onClick: () =>
28
+ window.open('https://docs.campx.in/Workflows/collect_fee/', '_blank'),
29
+ },
30
+ ],
31
+ },
32
+ '/ums/settings/assessments/assessment-types': {
33
+ actions: [
34
+ {
35
+ name: 'Know how to setup Assessment rules',
36
+ onClick: () =>
37
+ window.open(
38
+ 'https://docs.campx.in/Workflows/assessment_rules/',
39
+ '_blank',
40
+ ),
41
+ },
42
+ ],
43
+ },
44
+ '/ums/settings/assessments/assessment-templates': {
45
+ actions: [
46
+ {
47
+ name: 'Know how to setup Assessment rules',
48
+ onClick: () =>
49
+ window.open(
50
+ 'https://docs.campx.in/Workflows/assessment_rules/',
51
+ '_blank',
52
+ ),
53
+ },
54
+ ],
55
+ },
56
+ '/ums/classrooms/:id/timetable': {
57
+ actions: [
58
+ {
59
+ name: 'Know how to suspend a class',
60
+ onClick: () =>
61
+ window.open(
62
+ 'https://docs.campx.in/Workflows/suspending-a-class/',
63
+ '_blank',
64
+ ),
65
+ },
66
+ ],
67
+ },
68
+
69
+ '/exams/examinations/:id/bundle-subjects': {
70
+ actions: [
71
+ {
72
+ name: 'Learn about Scanning & Bundling',
73
+ onClick: () =>
74
+ window.open(
75
+ 'https://docs.campx.in/Workflows/scanningbundling_booklets/',
76
+ '_blank',
77
+ ),
78
+ },
79
+ {
80
+ name: 'Know how to upload digital booklets',
81
+ onClick: () =>
82
+ window.open(
83
+ 'https://docs.campx.in/Workflows/digital_booklets/',
84
+ '_blank',
85
+ ),
86
+ },
87
+ ],
88
+ },
89
+ };
@@ -1,7 +1,7 @@
1
1
  import { Icons } from '@campxdev/react-blueprint';
2
2
  import { Navigate, Outlet } from 'react-router-dom';
3
3
  import AppContent from '../AppContent';
4
- import { AppLayout } from '../layout/AppLayout';
4
+ import { AppLayout } from '../layout/AppLayout/AppLayout';
5
5
 
6
6
  export const mainRoutes = [
7
7
  {
@@ -20,14 +20,8 @@ export const mainRoutes = [
20
20
  </AppLayout>
21
21
  ),
22
22
  children: [
23
- {
24
- index: true,
25
- element: <Navigate to={'app-content'} />,
26
- },
27
- {
28
- path: 'app-content',
29
- element: <AppContent />,
30
- },
23
+ { index: true, element: <Navigate to={'app-content'} /> },
24
+ { path: 'app-content', element: <AppContent /> },
31
25
  ],
32
26
  },
33
27
  ];