@campxdev/shared 1.8.14 → 1.8.15

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.
Files changed (267) hide show
  1. package/antd.customize.less +73 -0
  2. package/exports.ts +19 -0
  3. package/package.json +4 -20
  4. package/src/assets/fonts/avenir/Avenir-Book.ttf +0 -0
  5. package/src/assets/fonts/avenir/Avenir-Heavy.ttf +0 -0
  6. package/src/assets/fonts/avenir/Avenir-HeavyOblique.ttf +0 -0
  7. package/src/assets/fonts/avenir/Avenir-Medium.ttf +0 -0
  8. package/src/assets/fonts/avenir/Avenir-MediumOblique.ttf +0 -0
  9. package/src/assets/fonts/avenir/index.ts +13 -0
  10. package/src/assets/fonts/poppins/Poppins-Bold.ttf +0 -0
  11. package/src/assets/fonts/poppins/Poppins-Italic.ttf +0 -0
  12. package/src/assets/fonts/poppins/Poppins-Light.ttf +0 -0
  13. package/src/assets/fonts/poppins/Poppins-LightItalic.ttf +0 -0
  14. package/src/assets/fonts/poppins/Poppins-Medium.ttf +0 -0
  15. package/src/assets/fonts/poppins/Poppins-MediumItalic.ttf +0 -0
  16. package/src/assets/fonts/poppins/Poppins-Regular.ttf +0 -0
  17. package/src/assets/fonts/poppins/Poppins-SemiBold.ttf +0 -0
  18. package/src/assets/fonts/poppins/Poppins-SemiBoldItalic.ttf +0 -0
  19. package/src/assets/fonts/poppins/index.ts +18 -0
  20. package/src/assets/images/401.png +0 -0
  21. package/src/assets/images/403.png +0 -0
  22. package/src/assets/images/404.png +0 -0
  23. package/src/assets/images/404notfound.svg +1 -0
  24. package/src/assets/images/500.png +0 -0
  25. package/src/assets/images/avatar.png +0 -0
  26. package/src/assets/images/campx_logo__full_primary.png +0 -0
  27. package/src/assets/images/index.ts +17 -0
  28. package/src/assets/images/internalservererror.svg +1 -0
  29. package/src/assets/images/noInternet.svg +1 -0
  30. package/src/assets/images/nointernet.png +0 -0
  31. package/src/assets/images/notfound.png +0 -0
  32. package/src/assets/images/pagenotfound.svg +1 -0
  33. package/src/assets/images/permissiondenied.svg +1 -0
  34. package/src/assets/images/unauth.svg +92 -0
  35. package/src/components/ActionButton.tsx +20 -0
  36. package/src/components/Attachment.tsx +26 -0
  37. package/src/components/AutocompleteSearch/AutocompleteSearch.tsx +57 -0
  38. package/src/components/AutocompleteSearch/index.tsx +1 -0
  39. package/src/components/Breadcrumbs.tsx +72 -0
  40. package/src/components/Card.tsx +98 -0
  41. package/src/components/CardsGrid.tsx +28 -0
  42. package/src/components/ChangePassword.tsx +123 -0
  43. package/src/components/Chips.tsx +81 -0
  44. package/src/components/Detail.tsx +15 -0
  45. package/src/components/DetailsGrid.tsx +52 -0
  46. package/src/components/DividerHeading.tsx +41 -0
  47. package/src/components/DrawerWrapper/DialogWrapper.tsx +67 -0
  48. package/src/components/DrawerWrapper/DrawerTemplate.tsx +53 -0
  49. package/src/components/DrawerWrapper/DrawerWrapper.tsx +53 -0
  50. package/src/components/DropDownButton/AnchorElement.tsx +44 -0
  51. package/src/components/DropDownButton/DropDownButton.tsx +184 -0
  52. package/src/components/DropDownButton/DropdownMenuItem.tsx +110 -0
  53. package/src/components/DropDownButton/index.tsx +1 -0
  54. package/src/components/DropDownButton/styles.tsx +59 -0
  55. package/src/components/ErrorBoundary/ErrorBoundary.tsx +33 -0
  56. package/src/components/ErrorBoundary/ErrorFallback.tsx +241 -0
  57. package/src/components/ErrorBoundary/GlobalNetworkLoadingIndicator.tsx +13 -0
  58. package/src/components/ErrorBoundary/index.tsx +1 -0
  59. package/src/components/ErrorBox.tsx +42 -0
  60. package/src/components/ExcelToJsonInput/ExcelJsonUpload.tsx +50 -0
  61. package/src/components/ExcelToJsonInput/ExcelToJsonInput.tsx +57 -0
  62. package/src/components/ExcelToJsonInput/index.tsx +1 -0
  63. package/src/components/FilterComponents/FilterButton.tsx +56 -0
  64. package/src/components/FilterComponents/SearchBar.tsx +45 -0
  65. package/src/components/FloatingContainer.tsx +33 -0
  66. package/src/components/Form/Form.tsx +147 -0
  67. package/src/components/Form/RenderForm.tsx +189 -0
  68. package/src/components/FullScreenLoader.tsx +19 -0
  69. package/src/components/HookForm/AutoCompleteSearch.tsx +113 -0
  70. package/src/components/HookForm/DatePicker.tsx +40 -0
  71. package/src/components/HookForm/DateTimePicker.tsx +47 -0
  72. package/src/components/HookForm/FormLabel.tsx +14 -0
  73. package/src/components/HookForm/MultiCheckbox.tsx +69 -0
  74. package/src/components/HookForm/MultiSelect.tsx +53 -0
  75. package/src/components/HookForm/RadioGroup.tsx +47 -0
  76. package/src/components/HookForm/SingleCheckbox.tsx +34 -0
  77. package/src/components/HookForm/SingleSelect.tsx +46 -0
  78. package/src/components/HookForm/TextField.tsx +40 -0
  79. package/src/components/HookForm/TimePicker.tsx +40 -0
  80. package/src/components/HookForm/index.ts +23 -0
  81. package/src/components/IconButtons/IconButtons.tsx +137 -0
  82. package/src/components/IconButtons/Icons.tsx +268 -0
  83. package/src/components/IconButtons/assets/edit.svg +4 -0
  84. package/src/components/IconButtons/assets/eye.svg +6 -0
  85. package/src/components/IconButtons/assets/trash.svg +7 -0
  86. package/src/components/IconButtons/index.tsx +8 -0
  87. package/src/components/IconLabel.tsx +37 -0
  88. package/src/components/Image/Image.tsx +45 -0
  89. package/src/components/Image/broken-image.png +0 -0
  90. package/src/components/Image/index.tsx +1 -0
  91. package/src/components/ImageUpload.tsx +98 -0
  92. package/src/components/Input/AsyncSearchSelect/AsyncSearchSelect.tsx +216 -0
  93. package/src/components/Input/AsyncSearchSelect/index.tsx +1 -0
  94. package/src/components/Input/AsyncSearchSelect/styles.tsx +105 -0
  95. package/src/components/Input/AutoCompleteSearch.tsx +121 -0
  96. package/src/components/Input/DatePicker.tsx +87 -0
  97. package/src/components/Input/DateRangePicker.tsx +105 -0
  98. package/src/components/Input/DateTimePicker.tsx +84 -0
  99. package/src/components/Input/FormLabel.tsx +21 -0
  100. package/src/components/Input/MultiCheckbox.tsx +64 -0
  101. package/src/components/Input/MultiSelect.tsx +150 -0
  102. package/src/components/Input/RadioGroup.tsx +104 -0
  103. package/src/components/Input/SingleCheckbox.tsx +78 -0
  104. package/src/components/Input/SingleSelect.tsx +104 -0
  105. package/src/components/Input/TextField.tsx +46 -0
  106. package/src/components/Input/TimePicker.tsx +77 -0
  107. package/src/components/Input/index.ts +26 -0
  108. package/src/components/Input/types.ts +3 -0
  109. package/src/components/JsonPreview.tsx +7 -0
  110. package/src/components/LabelValue.tsx +21 -0
  111. package/src/components/Layout/ChangePassword.tsx +49 -0
  112. package/src/components/Layout/Header/AppHeader.tsx +112 -0
  113. package/src/components/Layout/Header/AppsMenu.tsx +105 -0
  114. package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +33 -0
  115. package/src/components/Layout/Header/HeaderActions/FreshDeskHelpButton.tsx +24 -0
  116. package/src/components/Layout/Header/HeaderActions/HeaderActions.tsx +18 -0
  117. package/src/components/Layout/Header/HeaderActions/UserBox.tsx +56 -0
  118. package/src/components/Layout/Header/Notification.tsx +13 -0
  119. package/src/components/Layout/Header/applications.ts +103 -0
  120. package/src/components/Layout/Header/assets/background.png +0 -0
  121. package/src/components/Layout/Header/assets/campx.png +0 -0
  122. package/src/components/Layout/Header/assets/campx_square_small.svg +9 -0
  123. package/src/components/Layout/Header/assets/commuteX.png +0 -0
  124. package/src/components/Layout/Header/assets/commutex.png +0 -0
  125. package/src/components/Layout/Header/assets/commutex.svg +14 -0
  126. package/src/components/Layout/Header/assets/commutexSmall.svg +11 -0
  127. package/src/components/Layout/Header/assets/contactBg.png +0 -0
  128. package/src/components/Layout/Header/assets/enroll.svg +14 -0
  129. package/src/components/Layout/Header/assets/enroll_logo.svg +9 -0
  130. package/src/components/Layout/Header/assets/enrollx.svg +14 -0
  131. package/src/components/Layout/Header/assets/entrollx.png +0 -0
  132. package/src/components/Layout/Header/assets/exams_small.svg +12 -0
  133. package/src/components/Layout/Header/assets/examsx.svg +14 -0
  134. package/src/components/Layout/Header/assets/examx.png +0 -0
  135. package/src/components/Layout/Header/assets/hostel_small.svg +13 -0
  136. package/src/components/Layout/Header/assets/hostelx.png +0 -0
  137. package/src/components/Layout/Header/assets/hostelx.svg +13 -0
  138. package/src/components/Layout/Header/assets/index.ts +35 -0
  139. package/src/components/Layout/Header/assets/libraryx.svg +12 -0
  140. package/src/components/Layout/Header/assets/libreryx.png +0 -0
  141. package/src/components/Layout/Header/assets/pay_small.svg +16 -0
  142. package/src/components/Layout/Header/assets/payx.png +0 -0
  143. package/src/components/Layout/Header/assets/payx.svg +19 -0
  144. package/src/components/Layout/Header/assets/people_small.svg +9 -0
  145. package/src/components/Layout/Header/assets/peoplex.svg +12 -0
  146. package/src/components/Layout/Header/assets/pepolex.png +0 -0
  147. package/src/components/Layout/Header/assets/squarex.svg +12 -0
  148. package/src/components/Layout/Header/icons.tsx +57 -0
  149. package/src/components/Layout/Header/index.tsx +1 -0
  150. package/src/components/Layout/Header/styles.tsx +133 -0
  151. package/src/components/Layout/Helmet.tsx +49 -0
  152. package/src/components/Layout/LayoutWrapper.tsx +28 -0
  153. package/src/components/Layout/SideMenuHeader.tsx +29 -0
  154. package/src/components/Layout/SideNav.tsx +168 -0
  155. package/src/components/Layout/Tickets/HelpWidget/HelpWidget.tsx +273 -0
  156. package/src/components/Layout/Tickets/HelpWidget/styles.tsx +94 -0
  157. package/src/components/Layout/Tickets/MyTickets.tsx +72 -0
  158. package/src/components/Layout/Tickets/TicketDetails.tsx +65 -0
  159. package/src/components/Layout/Tickets/TimeLine.tsx +64 -0
  160. package/src/components/Layout/Tickets/index.tsx +1 -0
  161. package/src/components/Layout/Tickets/services.ts +11 -0
  162. package/src/components/Layout/Tickets/styles.tsx +136 -0
  163. package/src/components/LinearProgress.tsx +19 -0
  164. package/src/components/ListItemButton.tsx +95 -0
  165. package/src/components/LoginForm.tsx +279 -0
  166. package/src/components/MediaRow/MediaRow.tsx +67 -0
  167. package/src/components/MediaRow/index.tsx +1 -0
  168. package/src/components/ModalButtons/DialogButton.tsx +126 -0
  169. package/src/components/ModalButtons/DrawerButton.tsx +115 -0
  170. package/src/components/ModalButtons/index.tsx +4 -0
  171. package/src/components/NoDataIllustration.tsx +32 -0
  172. package/src/components/PageContent.tsx +12 -0
  173. package/src/components/PageHeader.tsx +55 -0
  174. package/src/components/PageNotFound.tsx +26 -0
  175. package/src/components/PopupConfirm/ConfirmContextProvider.tsx +40 -0
  176. package/src/components/PopupConfirm/PopupConfirm.tsx +67 -0
  177. package/src/components/PopupConfirm/animation.gif +0 -0
  178. package/src/components/PopupConfirm/index.tsx +1 -0
  179. package/src/components/PopupConfirm/useConfirm.ts +47 -0
  180. package/src/components/ResetPassword.tsx +107 -0
  181. package/src/components/Row.tsx +24 -0
  182. package/src/components/Spinner.tsx +18 -0
  183. package/src/components/StepsHeader/StepsHeader.tsx +115 -0
  184. package/src/components/StepsHeader/index.tsx +1 -0
  185. package/src/components/StyledTableContainer.tsx +33 -0
  186. package/src/components/SwitchButton.tsx +41 -0
  187. package/src/components/Table.tsx +42 -0
  188. package/src/components/Tables/BasicTable/Table.tsx +198 -0
  189. package/src/components/Tables/BasicTable/TableFooter.tsx +86 -0
  190. package/src/components/Tables/BasicTable/index.tsx +1 -0
  191. package/src/components/Tables/ReactTable/BatchActionsHeader.tsx +58 -0
  192. package/src/components/Tables/ReactTable/ReactTable.tsx +295 -0
  193. package/src/components/Tables/ReactTable/RenderTableBody.tsx +49 -0
  194. package/src/components/Tables/ReactTable/index.tsx +1 -0
  195. package/src/components/Tables/ReactTable/react-table-config.d.ts +128 -0
  196. package/src/components/Tables/common/NoRecordsFound.tsx +27 -0
  197. package/src/components/Tables/common/TableStats.tsx +22 -0
  198. package/src/components/Tables/common/icons.tsx +50 -0
  199. package/src/components/Tables/common/no-data-illu.svg +1 -0
  200. package/src/components/Tables/common/styles.tsx +170 -0
  201. package/src/components/Tables/common/types.ts +57 -0
  202. package/src/components/Tabs/NavigationTabs.tsx +80 -0
  203. package/src/components/Tabs/Tabs.tsx +53 -0
  204. package/src/components/Tabs/TabsContainer.tsx +53 -0
  205. package/src/components/Tabs/index.tsx +1 -0
  206. package/src/components/Tabs/styles.tsx +55 -0
  207. package/src/components/ToastContainer/ToastContainer.tsx +57 -0
  208. package/src/components/ToastContainer/index.tsx +1 -0
  209. package/src/components/UploadButton/UploadButton.tsx +126 -0
  210. package/src/components/UploadButton/index.tsx +1 -0
  211. package/src/components/UploadButton/types.ts +19 -0
  212. package/src/components/UploadDocument.tsx +108 -0
  213. package/src/components/UploadFileDialog/AnimatedUploadFile.gif +0 -0
  214. package/src/components/UploadFileDialog/UploadFileDialog.tsx +238 -0
  215. package/src/components/UploadFileDialog/index.tsx +1 -0
  216. package/src/components/index.ts +106 -0
  217. package/src/config/axios.ts +73 -0
  218. package/src/config/axiosEvaluator.ts +53 -0
  219. package/src/config/axiosXTenant.ts +57 -0
  220. package/src/constants/UIConstants.ts +97 -0
  221. package/src/constants/formValidations.ts +6 -0
  222. package/src/constants/index.ts +5 -0
  223. package/src/constants/isDevelopment.ts +4 -0
  224. package/src/constants/permissions.ts +67 -0
  225. package/src/constants/validateMessages.ts +12 -0
  226. package/src/contexts/LoginFormProvider.tsx +44 -0
  227. package/src/contexts/Providers.tsx +50 -0
  228. package/src/contexts/PublicProviders.tsx +30 -0
  229. package/src/contexts/QueryClientProvider.tsx +22 -0
  230. package/src/hooks/index.ts +5 -0
  231. package/src/hooks/useAuth.ts +96 -0
  232. package/src/hooks/useExternalScript.ts +37 -0
  233. package/src/hooks/useFetch.ts +53 -0
  234. package/src/hooks/useFilters.ts +83 -0
  235. package/src/hooks/useRouter.ts +31 -0
  236. package/src/layouts/Components/DashBoardMenu.tsx +232 -0
  237. package/src/layouts/Components/icons/index.tsx +403 -0
  238. package/src/layouts/Components/styles.tsx +74 -0
  239. package/src/layouts/ComponentsLayout.tsx +3 -0
  240. package/src/permissions/PageWithPermission.tsx +18 -0
  241. package/src/permissions/PermissionDeniedPage.tsx +16 -0
  242. package/src/permissions/ValidateAccess.tsx +18 -0
  243. package/src/permissions/index.ts +2 -0
  244. package/src/react-app-env.d.ts +1 -0
  245. package/src/shared-state/AssetsStore.ts +15 -0
  246. package/src/shared-state/PermissionsStore.ts +392 -0
  247. package/src/shared-state/UserStore.ts +13 -0
  248. package/src/shared-state/index.ts +4 -0
  249. package/src/theme/App.less +3 -0
  250. package/src/theme/MuiThemeProvider.tsx +18 -0
  251. package/src/theme/customCssBaseline.ts +135 -0
  252. package/src/theme/index.css +28 -0
  253. package/src/theme/muiTheme.ts +595 -0
  254. package/src/theme/theme.d.ts +75 -0
  255. package/src/utils/adminAxios.ts +15 -0
  256. package/src/utils/alphabet.ts +23 -0
  257. package/src/utils/arrayPadEnd.ts +3 -0
  258. package/src/utils/formatCurrency.ts +9 -0
  259. package/src/utils/getUrlParams.ts +5 -0
  260. package/src/utils/index.ts +7 -0
  261. package/src/utils/logout.ts +25 -0
  262. package/src/utils/ordinalSuffixOf.ts +14 -0
  263. package/src/utils/romanize.ts +40 -0
  264. package/src/utils/withRouteWrapper.tsx +25 -0
  265. package/src/utils/withSuspense.tsx +6 -0
  266. package/styled-components.tsx +60 -0
  267. package/tsconfig.json +21 -0
@@ -0,0 +1,77 @@
1
+ import { QueryBuilder } from '@mui/icons-material'
2
+ import { InputAdornment, TextFieldProps } from '@mui/material'
3
+ import 'flatpickr/dist/flatpickr.css'
4
+ import { ReactNode } from 'react'
5
+ import Flatpickr, { DateTimePickerProps } from 'react-flatpickr'
6
+ import TextField from './TextField'
7
+
8
+ export interface ITimePicker {
9
+ label?: ReactNode
10
+ name?: string
11
+ required?: boolean
12
+ minTime?: Date | string | number
13
+ maxTime?: Date | string | number
14
+ value: Date | null
15
+ onChange: (value: Date) => void
16
+ placeholder?: string
17
+ inputProps?: TextFieldProps
18
+ size?: 'medium' | 'small'
19
+ }
20
+
21
+ export default function TimePicker({
22
+ name,
23
+ label,
24
+ required,
25
+ minTime,
26
+ maxTime,
27
+ onChange,
28
+ value,
29
+ placeholder,
30
+ size = 'medium',
31
+ ...rest
32
+ }: ITimePicker) {
33
+ return (
34
+ <Flatpickr
35
+ options={{
36
+ enableTime: true,
37
+ noCalendar: true,
38
+ dateFormat: 'h:i K',
39
+ minTime,
40
+ maxTime,
41
+ allowInput: true,
42
+ }}
43
+ onClose={(dates) => {
44
+ if (onChange) onChange(dates[0])
45
+ }}
46
+ onChange={(dates: Date[]) => {
47
+ if (onChange) onChange(dates[0])
48
+ }}
49
+ value={value || null}
50
+ render={(
51
+ props: Omit<DateTimePickerProps, 'options' | 'render'>,
52
+ ref: (node: HTMLInputElement | null) => void,
53
+ ) => {
54
+ return (
55
+ <TextField
56
+ size={size}
57
+ placeholder={placeholder}
58
+ label={label}
59
+ name={name}
60
+ variant="outlined"
61
+ autoComplete="off"
62
+ required={required}
63
+ inputRef={ref}
64
+ InputProps={{
65
+ endAdornment: (
66
+ <InputAdornment position="end">
67
+ <QueryBuilder />
68
+ </InputAdornment>
69
+ ),
70
+ }}
71
+ {...rest.inputProps}
72
+ />
73
+ )
74
+ }}
75
+ />
76
+ )
77
+ }
@@ -0,0 +1,26 @@
1
+ import TextField from './TextField'
2
+ import DateTimePicker from './DateTimePicker'
3
+ import FormLabel from './FormLabel'
4
+ import MultiCheckbox from './MultiCheckbox'
5
+ import MultiSelect from './MultiSelect'
6
+ import RadioGroup from './RadioGroup'
7
+ import SingleCheckbox from './SingleCheckbox'
8
+ import SingleSelect from './SingleSelect'
9
+ import AutoCompleteSearch from './AutoCompleteSearch'
10
+ import TimePicker from './TimePicker'
11
+ import DatePicker from './DatePicker'
12
+ import DateRangePicker from './DateRangePicker'
13
+ export {
14
+ TextField,
15
+ DateTimePicker,
16
+ FormLabel,
17
+ MultiCheckbox,
18
+ MultiSelect,
19
+ RadioGroup,
20
+ SingleCheckbox,
21
+ SingleSelect,
22
+ AutoCompleteSearch,
23
+ TimePicker,
24
+ DatePicker,
25
+ DateRangePicker,
26
+ }
@@ -0,0 +1,3 @@
1
+ import { ReactNode } from 'react'
2
+
3
+ export type IOption = { label: ReactNode; value: any }
@@ -0,0 +1,7 @@
1
+ export default function JsonPreview({ data }: { data: any }) {
2
+ return (
3
+ <div>
4
+ <pre>{JSON.stringify(data, null, 2)}</pre>
5
+ </div>
6
+ )
7
+ }
@@ -0,0 +1,21 @@
1
+ import { Box, Stack, Typography } from '@mui/material'
2
+ import { ReactNode } from 'react'
3
+
4
+ export default function LabelValue({
5
+ label,
6
+ value,
7
+ reverse = false,
8
+ }: {
9
+ label: string | ReactNode
10
+ value?: ReactNode
11
+ reverse?: boolean
12
+ }) {
13
+ return (
14
+ <Stack flexDirection={reverse ? 'column-reverse' : 'column'} gap="6px">
15
+ <Typography variant="subtitle2">{label}</Typography>
16
+ <Typography paragraph fontWeight={600}>
17
+ {value ?? '-'}
18
+ </Typography>
19
+ </Stack>
20
+ )
21
+ }
@@ -0,0 +1,49 @@
1
+ import { Button, Stack } from '@mui/material'
2
+ import { useForm } from 'react-hook-form'
3
+ import { toast } from 'react-toastify'
4
+ import { FormTextField } from '..'
5
+ import axios, { axiosErrorToast } from '../../config/axios'
6
+
7
+ export default function ChangePassword({ close }) {
8
+ const { handleSubmit, control } = useForm()
9
+
10
+ const onSubmit = async (formData) => {
11
+ try {
12
+ await axios.post('/auth-server/auth/change-password', formData)
13
+ toast.success('Password Changed Successfully')
14
+ } catch (error) {
15
+ axiosErrorToast(error)
16
+ }
17
+ }
18
+
19
+ return (
20
+ <form onSubmit={handleSubmit(onSubmit)}>
21
+ <Stack gap={2}>
22
+ <FormTextField
23
+ label="Old Password"
24
+ control={control}
25
+ name="oldPassword"
26
+ required
27
+ />
28
+ <FormTextField
29
+ label="New Password"
30
+ control={control}
31
+ name="newPassword"
32
+ required
33
+ />
34
+ <FormTextField
35
+ label="Confirm Password"
36
+ control={control}
37
+ name="password"
38
+ required
39
+ />
40
+ <Stack>
41
+ <Button variant="outlined" onClick={close}>
42
+ Cancel
43
+ </Button>
44
+ <Button type="submit">Submit</Button>
45
+ </Stack>
46
+ </Stack>
47
+ </form>
48
+ )
49
+ }
@@ -0,0 +1,112 @@
1
+ import { Box, Button, Typography } from '@mui/material'
2
+ import { ReactNode } from 'react'
3
+ import { isDevelopment } from '../../../constants/isDevelopment'
4
+ import { applications } from './applications'
5
+ import AppsMenu from './AppsMenu'
6
+ import {
7
+ collegex,
8
+ commutex,
9
+ enrollx,
10
+ examx,
11
+ hostelx,
12
+ payx,
13
+ peoplex,
14
+ } from './assets'
15
+
16
+ import { HelpOutline } from '@mui/icons-material'
17
+ import CogWheelMenu from './HeaderActions/CogWheelMenu'
18
+ import {
19
+ StyledHeader,
20
+ StyledImageWrapper,
21
+ StyledLogosWrapper,
22
+ StyledRouterLink,
23
+ } from './styles'
24
+ import UserBox from './HeaderActions/UserBox'
25
+ import FreshDeskHelpButton from './HeaderActions/FreshDeskHelpButton'
26
+ import HeaderActions from './HeaderActions/HeaderActions'
27
+
28
+ const imageMap = {
29
+ ums: collegex,
30
+ enroll: enrollx,
31
+ exams: examx,
32
+ payments: payx,
33
+ people: peoplex,
34
+ campx: collegex,
35
+ commute: commutex,
36
+ hostel: hostelx,
37
+ }
38
+
39
+ interface AppHeaderProps {
40
+ clientLogo: string
41
+ fullName: string
42
+ userBoxActions: {
43
+ label: ReactNode
44
+ icon?: ReactNode
45
+ onClick: any
46
+ }[]
47
+ customHeaderActions?: ReactNode
48
+ cogWheelMenu?: { label: string; path: string }[]
49
+ }
50
+
51
+ export default function AppHeader({
52
+ clientLogo = imageMap.campx,
53
+ fullName,
54
+ userBoxActions = [],
55
+ cogWheelMenu = [],
56
+ customHeaderActions,
57
+ }: AppHeaderProps) {
58
+ return (
59
+ <StyledHeader>
60
+ <Box sx={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
61
+ <AppsMenu />
62
+ <AppLogo clientLogo={clientLogo} />
63
+ </Box>
64
+ <Box className="actions">
65
+ {customHeaderActions ? (
66
+ customHeaderActions
67
+ ) : (
68
+ <HeaderActions
69
+ cogWheelMenu={cogWheelMenu}
70
+ fullName={fullName}
71
+ userBoxActions={userBoxActions}
72
+ />
73
+ )}
74
+ </Box>
75
+ </StyledHeader>
76
+ )
77
+ }
78
+
79
+ const AppLogo = ({ clientLogo }) => {
80
+ const originSubdomain = window.location.host.split('.')?.slice(-3)[0] ?? 'ums'
81
+ const currentApp =
82
+ applications.find((item) => item.key === originSubdomain)?.key ?? 'campx'
83
+
84
+ return (
85
+ <StyledRouterLink to={'/'}>
86
+ <StyledLogosWrapper>
87
+ <StyledImageWrapper>
88
+ <img src={imageMap[currentApp]} />
89
+ </StyledImageWrapper>
90
+ <Box
91
+ sx={{
92
+ height: '26px',
93
+ width: '2px',
94
+ background: 'gray',
95
+ }}
96
+ ></Box>
97
+ <StyledImageWrapper>
98
+ {isDevelopment ? (
99
+ <Typography variant="h1">Developer</Typography>
100
+ ) : (
101
+ <img
102
+ src={clientLogo}
103
+ onError={(e: any) => {
104
+ e.target.src = imageMap.campx
105
+ }}
106
+ />
107
+ )}
108
+ </StyledImageWrapper>
109
+ </StyledLogosWrapper>
110
+ </StyledRouterLink>
111
+ )
112
+ }
@@ -0,0 +1,105 @@
1
+ import { Box, Menu, Typography } from '@mui/material'
2
+ import Cookies from 'js-cookie'
3
+ import { useState } from 'react'
4
+ import { applications } from './applications'
5
+ import { AppsIcon } from './icons'
6
+ import {
7
+ StyledDescription,
8
+ StyledIconButton,
9
+ StyledMenuItem,
10
+ StyledMenuItemContainer,
11
+ StyledLink,
12
+ StyledImageBox,
13
+ } from './styles'
14
+
15
+ export const campxTenantKey = Cookies.get('campx_tenant')
16
+
17
+ const AppsMenu = () => {
18
+ const [anchorEl, setAnchorEl] = useState<any>(null)
19
+ const open = Boolean(anchorEl)
20
+
21
+ const handleClick = (event) => {
22
+ setAnchorEl(event.currentTarget)
23
+ }
24
+
25
+ const handleClose = () => {
26
+ setAnchorEl(null)
27
+ }
28
+
29
+ return (
30
+ <>
31
+ <StyledIconButton onClick={handleClick}>
32
+ <AppsIcon />
33
+ </StyledIconButton>
34
+
35
+ <Menu
36
+ transitionDuration={150}
37
+ elevation={2}
38
+ id="basic-menu"
39
+ anchorEl={anchorEl}
40
+ open={open}
41
+ onClose={handleClose}
42
+ anchorOrigin={{
43
+ vertical: 'bottom',
44
+ horizontal: 'left',
45
+ }}
46
+ transformOrigin={{
47
+ vertical: 'top',
48
+ horizontal: 'left',
49
+ }}
50
+ TransitionProps={{
51
+ unmountOnExit: false,
52
+ }}
53
+ sx={{
54
+ '& .MuiPaper-root': {
55
+ left: '0 !important',
56
+ top: '64px !important',
57
+ '&>:last-child': {
58
+ paddingBottom: '0px',
59
+ },
60
+ },
61
+ }}
62
+ >
63
+ <Box sx={{ padding: '0.3rem 1rem' }}>
64
+ <Typography variant="body2">Switch to</Typography>
65
+ </Box>
66
+ <Box>
67
+ {applications.map((item, index) => (
68
+ <StyledLink
69
+ href={item.path + `/${campxTenantKey ?? ''}`}
70
+ key={index}
71
+ >
72
+ <StyledMenuItemContainer
73
+ key={index}
74
+ onClick={() => {
75
+ window.location.href = item.path
76
+ handleClose()
77
+ }}
78
+ >
79
+ <MenuItem data={item} />
80
+ </StyledMenuItemContainer>
81
+ </StyledLink>
82
+ ))}
83
+ </Box>
84
+ </Menu>
85
+ </>
86
+ )
87
+ }
88
+
89
+ export default AppsMenu
90
+
91
+ const MenuItem = ({ data }) => {
92
+ return (
93
+ <StyledMenuItem>
94
+ <StyledImageBox>
95
+ <img src={data.icon} style={{ width: '20px', height: '20px' }} />
96
+ </StyledImageBox>
97
+ <Box>
98
+ <Typography variant="h1" sx={{ marginBottom: '7px' }}>
99
+ {data?.title}
100
+ </Typography>
101
+ <StyledDescription>{data?.description}</StyledDescription>
102
+ </Box>
103
+ </StyledMenuItem>
104
+ )
105
+ }
@@ -0,0 +1,33 @@
1
+ import { SettingsOutlined } from '@mui/icons-material'
2
+ import { IconButton } from '@mui/material'
3
+ import { useHistory } from '../../../../hooks/useRouter'
4
+ import DropDownButton from '../../../DropDownButton/DropDownButton'
5
+
6
+ const CogWheelMenu = ({ menu }) => {
7
+ const history = useHistory()
8
+
9
+ return (
10
+ <DropDownButton
11
+ anchor={({ open }) => (
12
+ <IconButton color="secondary" onClick={open}>
13
+ <SettingsOutlined />
14
+ </IconButton>
15
+ )}
16
+ menu={menu?.map((item) => ({
17
+ label: item?.label,
18
+ onClick: () => {
19
+ history.push(item?.path)
20
+ },
21
+ }))}
22
+ menuProps={{
23
+ PaperProps: { sx: { top: '56px !important' } },
24
+ transformOrigin: {
25
+ horizontal: 'center',
26
+ vertical: 'top',
27
+ },
28
+ }}
29
+ />
30
+ )
31
+ }
32
+
33
+ export default CogWheelMenu
@@ -0,0 +1,24 @@
1
+ import { HelpOutline } from '@mui/icons-material'
2
+ import { Button } from '@mui/material'
3
+
4
+ export default function FreshDeskHelpButton() {
5
+ const handleOpenFreshDeskWidget = () => {
6
+ try {
7
+ ;(window as any)?.openFreshDeskWidget()
8
+ } catch (error) {
9
+ // eslint-disable-next-line no-console
10
+ console.error('Error launching Freshdesk')
11
+ }
12
+ }
13
+ return (
14
+ <Button
15
+ variant="text"
16
+ color="secondary"
17
+ startIcon={<HelpOutline />}
18
+ onClick={handleOpenFreshDeskWidget}
19
+ sx={{ padding: '20px' }}
20
+ >
21
+ Help
22
+ </Button>
23
+ )
24
+ }
@@ -0,0 +1,18 @@
1
+ import { Box } from '@mui/material'
2
+ import UserBox from './UserBox'
3
+ import CogWheelMenu from './CogWheelMenu'
4
+ import FreshDeskHelpButton from './FreshDeskHelpButton'
5
+
6
+ export default function HeaderActions({
7
+ cogWheelMenu,
8
+ fullName,
9
+ userBoxActions,
10
+ }) {
11
+ return (
12
+ <>
13
+ <FreshDeskHelpButton />
14
+ {cogWheelMenu?.length ? <CogWheelMenu menu={cogWheelMenu} /> : null}
15
+ <UserBox fullName={fullName} actions={userBoxActions} />
16
+ </>
17
+ )
18
+ }
@@ -0,0 +1,56 @@
1
+ import { ExitToAppOutlined, HttpsOutlined } from '@mui/icons-material'
2
+ import logout from '../../../../utils/logout'
3
+ import ChangePassword from '../../../ChangePassword'
4
+ import DropDownButton from '../../../DropDownButton/DropDownButton'
5
+ import { IMenuItemProps } from '../../../DropDownButton/DropdownMenuItem'
6
+ import { StyledAvatar } from '../styles'
7
+
8
+ const getStartingLetters = (text: string) => {
9
+ if (!text) return ''
10
+ return text
11
+ .split(' ')
12
+ ?.map((w) => w[0])
13
+ ?.join('')
14
+ }
15
+
16
+ export default function UserBox({
17
+ fullName,
18
+ actions,
19
+ customActions = [],
20
+ }: {
21
+ fullName: string
22
+ actions: IMenuItemProps[] | []
23
+ customActions?: IMenuItemProps[] | []
24
+ }) {
25
+ return (
26
+ <DropDownButton
27
+ anchor={({ open }) => (
28
+ <StyledAvatar onClick={open}>
29
+ {getStartingLetters(fullName)}
30
+ </StyledAvatar>
31
+ )}
32
+ menu={
33
+ customActions?.length
34
+ ? customActions
35
+ : [
36
+ ...actions,
37
+ {
38
+ label: 'Change Password',
39
+ actionType: 'dialog',
40
+ icon: <HttpsOutlined />,
41
+ content: ({ close }) => <ChangePassword close={close} />,
42
+ contentTitle: 'Change Password',
43
+ },
44
+ {
45
+ label: 'Logout',
46
+ icon: <ExitToAppOutlined />,
47
+ onClick: logout,
48
+ },
49
+ ]
50
+ }
51
+ menuProps={{
52
+ PaperProps: { sx: { top: '56px !important' } },
53
+ }}
54
+ />
55
+ )
56
+ }
@@ -0,0 +1,13 @@
1
+ import { IconButton } from '@mui/material'
2
+ import { NotificationIcon } from './icons'
3
+
4
+ function Notification() {
5
+ return (
6
+ <>
7
+ <IconButton>
8
+ <NotificationIcon />
9
+ </IconButton>
10
+ </>
11
+ )
12
+ }
13
+ export default Notification
@@ -0,0 +1,103 @@
1
+ import { isDevelopment } from '../../../constants'
2
+ import {
3
+ campxSquareSmall,
4
+ examsSmall,
5
+ hostelSmall,
6
+ paySmall,
7
+ peopleSmall,
8
+ commuteSmall,
9
+ enrollSmall,
10
+ } from './assets'
11
+
12
+ const origins = {
13
+ ums: {
14
+ dev: 'https://ums.campx.dev',
15
+ prod: 'https://ums.campx.in',
16
+ },
17
+ payments: {
18
+ dev: 'https://payments.campx.dev',
19
+ prod: 'https://payments.campx.in',
20
+ },
21
+ exams: {
22
+ dev: 'https://exams.campx.dev',
23
+ prod: 'https://exams.campx.in',
24
+ },
25
+ people: {
26
+ dev: 'https://people.campx.dev',
27
+ prod: 'https://people.campx.in',
28
+ },
29
+ hostel: {
30
+ dev: 'https://hostel.campx.dev',
31
+ prod: 'https://hostel.campx.in',
32
+ },
33
+ commute: {
34
+ dev: 'https://commute.campx.dev',
35
+ prod: 'https://commute.campx.in',
36
+ },
37
+ enroll: {
38
+ dev: 'https://enroll.campx.dev',
39
+ prod: 'https://enroll.campx.in',
40
+ },
41
+ }
42
+
43
+ export const applications = [
44
+ {
45
+ title: 'CollegeX',
46
+ path: isDevelopment ? origins.ums.dev : origins.ums.prod,
47
+ icon: campxSquareSmall,
48
+ key: 'ums',
49
+ description: 'Manage Complete Campus Activities',
50
+ },
51
+ {
52
+ title: 'ExamX',
53
+ key: 'exams',
54
+ path: isDevelopment ? origins.exams.dev : origins.exams.prod,
55
+ icon: examsSmall,
56
+ description: 'Manage all Examinations in the Campus',
57
+ },
58
+ {
59
+ title: 'PayX',
60
+ key: 'payments',
61
+ path: isDevelopment ? origins.payments.dev : origins.payments.prod,
62
+ icon: paySmall,
63
+ description: 'Manage Payments in the Campus',
64
+ },
65
+ {
66
+ title: 'EnrollX',
67
+ key: 'enroll',
68
+ path: isDevelopment ? origins.enroll.dev : origins.enroll.prod,
69
+ icon: enrollSmall,
70
+ description: 'Manage Admissions in the Campus',
71
+ },
72
+ {
73
+ title: 'HostelX',
74
+ key: 'hostel',
75
+ path: isDevelopment ? origins.hostel.dev : origins.hostel.prod,
76
+ icon: hostelSmall,
77
+ description: 'Manage Hostels in the Campus',
78
+ },
79
+ {
80
+ title: 'CommuteX',
81
+ key: 'commute',
82
+ path: isDevelopment ? origins.commute.dev : origins.commute.prod,
83
+ icon: commuteSmall,
84
+ description: 'Manage Commute in the Campus',
85
+ },
86
+ ...(isDevelopment
87
+ ? [
88
+ {
89
+ title: 'PeopleX',
90
+ key: 'people',
91
+ path: isDevelopment ? origins.people.dev : origins.people.prod,
92
+ icon: peopleSmall,
93
+ description: 'Manage People in the Campus',
94
+ },
95
+ ]
96
+ : []),
97
+ // {
98
+ // title: 'EnrollX',
99
+ // path: '/hostel',
100
+ // icon: enrollHeaderLogo,
101
+ // // description: 'Manage Admissions in the Campus',
102
+ // },
103
+ ]
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="35" height="35" viewBox="0 0 35 35">
2
+ <defs>
3
+ <linearGradient id="linear-gradient" x1="0.5" x2="0.5" y2="1" gradientUnits="objectBoundingBox">
4
+ <stop offset="0" stop-color="#596e79"/>
5
+ <stop offset="1" stop-color="#7c909b"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <path id="Subtraction_7" data-name="Subtraction 7" d="M-5678.321,8264.99h-13.18v-13.234h6.563v6.672h6.617v6.563Zm21.82,0h-13.18v-6.562h6.617v-6.672h6.563v13.234Zm0-21.875h-6.562v-6.562h-6.617v-6.562h13.18v13.125Zm-28.437,0h-6.562V8229.99h13.18v6.563h-6.617v6.563Z" transform="translate(5691.501 -8229.99)" fill="url(#linear-gradient)"/>
9
+ </svg>