@campxdev/shared 0.1.0
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/.eslintrc.js +34 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +16 -0
- package/.storybook/preview.js +9 -0
- package/antd.customize.less +73 -0
- package/exports.ts +20 -0
- package/package.json +78 -0
- package/public/dean.JPG +0 -0
- package/public/download.png +0 -0
- package/public/illustrations/bookmark.svg +19 -0
- package/public/illustrations/girl-writing.png +0 -0
- package/public/illustrations/whiteboard.svg +24 -0
- package/public/images/AnimatedUploadFile.gif +0 -0
- package/public/images/doc@2x.png +0 -0
- package/public/images/greenTick.png +0 -0
- package/public/images/jpg.png +0 -0
- package/public/images/paperclip@2x.png +0 -0
- package/public/images/pdf.png +0 -0
- package/public/images/ppt.png +0 -0
- package/public/images/profileImage.jpg +0 -0
- package/public/images/profileImage.png +0 -0
- package/public/index.html +50 -0
- package/public/logo.png +0 -0
- package/public/logo_campx_full.png +0 -0
- package/public/logo_square.svg +21 -0
- package/public/omr_sign.jpg +0 -0
- package/src/App.tsx +35 -0
- package/src/assets/fonts/avenir/Avenir.ttc +0 -0
- package/src/assets/fonts/avenir/index.ts +2 -0
- package/src/assets/fonts/poppins/Poppins-Bold.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Italic.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Light.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-LightItalic.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Medium.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-MediumItalic.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-SemiBold.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-SemiBoldItalic.ttf +0 -0
- package/src/assets/fonts/poppins/index.ts +7 -0
- package/src/assets/images/File bundle-bro.svg +122 -0
- package/src/assets/images/Filebundle.png +0 -0
- package/src/assets/images/NoPart.png +0 -0
- package/src/assets/images/ResultProcess.png +0 -0
- package/src/assets/images/ResultProcess.svg +99 -0
- package/src/assets/images/attachment.svg +1 -0
- package/src/assets/images/avatar.png +0 -0
- package/src/assets/images/index.ts +19 -0
- package/src/assets/images/pdf.png +0 -0
- package/src/assets/images/taskAttachment.png +0 -0
- package/src/assets/images/welcomeimage.jpg +0 -0
- package/src/assets/static_files/External_Marks_Import .xlsx +0 -0
- package/src/assets/static_files/Leads_Sample.xlsx +0 -0
- package/src/assets/static_files/Subject_Topic_Import_Sheet.xlsx +0 -0
- package/src/assets/static_files/admissions_Sample.xlsx +0 -0
- package/src/assets/static_files/barcodes_template.xlsx +0 -0
- package/src/assets/static_files/hostel_rooms_import.xlsx +0 -0
- package/src/assets/static_files/index.ts +24 -0
- package/src/assets/static_files/sample_admissions.xlsx +0 -0
- package/src/assets/static_files/sample_admissions_report.xlsx +0 -0
- package/src/assets/static_files/sample_curriculum_subjects_template.xlsx +0 -0
- package/src/assets/static_files/sample_import_students_new.xlsx +0 -0
- package/src/assets/static_files/sample_internal_marks.xlsx +0 -0
- package/src/assets/static_files/sample_student_subjects_template.xlsx +0 -0
- package/src/components/ActionButton.tsx +28 -0
- package/src/components/Attachment.tsx +26 -0
- package/src/components/AutocompleteSearch/AutocompleteSearch.tsx +57 -0
- package/src/components/AutocompleteSearch/index.tsx +1 -0
- package/src/components/Breadcrumbs.tsx +73 -0
- package/src/components/Card.tsx +97 -0
- package/src/components/CardsGrid.tsx +28 -0
- package/src/components/Chips.tsx +77 -0
- package/src/components/Detail.tsx +15 -0
- package/src/components/DetailsGrid.tsx +52 -0
- package/src/components/DividerHeading.tsx +40 -0
- package/src/components/DrawerWrapper/DialogWrapper.tsx +63 -0
- package/src/components/DrawerWrapper/DrawerTemplate.tsx +53 -0
- package/src/components/DrawerWrapper/DrawerWrapper.tsx +53 -0
- package/src/components/DropDownButton.tsx +184 -0
- package/src/components/ErrorBoundary.js +45 -0
- package/src/components/ErrorBox.tsx +42 -0
- package/src/components/FloatingContainer.tsx +26 -0
- package/src/components/FullCalendar/Actions.tsx +162 -0
- package/src/components/FullCalendar/FullCalendarWrapper.tsx +54 -0
- package/src/components/HookForm/AutoCompleteSearch.tsx +143 -0
- package/src/components/HookForm/DatePicker.tsx +65 -0
- package/src/components/HookForm/DateTimePicker.tsx +70 -0
- package/src/components/HookForm/FormLabel.tsx +14 -0
- package/src/components/HookForm/MultiCheckbox.tsx +82 -0
- package/src/components/HookForm/MultiSelect.tsx +100 -0
- package/src/components/HookForm/RadioGroup.tsx +113 -0
- package/src/components/HookForm/SingleCheckbox.tsx +46 -0
- package/src/components/HookForm/SingleSelect.tsx +93 -0
- package/src/components/HookForm/TextField.tsx +74 -0
- package/src/components/HookForm/TimePicker.tsx +82 -0
- package/src/components/HookForm/index.ts +23 -0
- package/src/components/IconButtons/IconButtons.tsx +137 -0
- package/src/components/IconButtons/Icons.tsx +269 -0
- package/src/components/IconButtons/assets/edit.svg +4 -0
- package/src/components/IconButtons/assets/eye.svg +6 -0
- package/src/components/IconButtons/assets/trash.svg +7 -0
- package/src/components/IconButtons/index.tsx +8 -0
- package/src/components/IconLabel.tsx +37 -0
- package/src/components/Image/Image.tsx +43 -0
- package/src/components/Image/broken-image.png +0 -0
- package/src/components/Image/index.tsx +1 -0
- package/src/components/ImageUpload.tsx +98 -0
- package/src/components/Input/AutoCompleteSearch.tsx +143 -0
- package/src/components/Input/DatePicker.tsx +60 -0
- package/src/components/Input/DateRangePicker.tsx +131 -0
- package/src/components/Input/DateTimePicker.tsx +70 -0
- package/src/components/Input/FormLabel.tsx +14 -0
- package/src/components/Input/MultiCheckbox.tsx +79 -0
- package/src/components/Input/MultiSelect.tsx +52 -0
- package/src/components/Input/RadioGroup.tsx +55 -0
- package/src/components/Input/SingleCheckbox.tsx +23 -0
- package/src/components/Input/SingleSelect.tsx +139 -0
- package/src/components/Input/TextField.tsx +50 -0
- package/src/components/Input/TimePicker.tsx +82 -0
- package/src/components/Input/index.ts +26 -0
- package/src/components/JsonPreview/JsonPreview.tsx +7 -0
- package/src/components/JsonPreview/index.tsx +1 -0
- package/src/components/LabelValue/LabelValue.tsx +21 -0
- package/src/components/LabelValue/index.tsx +1 -0
- package/src/components/Layout/ChangePassword.tsx +49 -0
- package/src/components/Layout/Header/AppHeader.tsx +150 -0
- package/src/components/Layout/Header/CogWheelMenu.tsx +35 -0
- package/src/components/Layout/Header/FreshDeskHelpButton.tsx +19 -0
- package/src/components/Layout/Header/MainAppHeader.tsx +6 -0
- package/src/components/Layout/Header/Notification.tsx +13 -0
- package/src/components/Layout/Header/UserBox.tsx +51 -0
- package/src/components/Layout/Header/applications.tsx +39 -0
- package/src/components/Layout/Header/icons.tsx +57 -0
- package/src/components/Layout/Header/index.tsx +1 -0
- package/src/components/Layout/Header/styles.tsx +48 -0
- package/src/components/LinearProgress/LinearProgress.tsx +27 -0
- package/src/components/LinearProgress/index.tsx +1 -0
- package/src/components/MediaRow/MediaRow.tsx +69 -0
- package/src/components/MediaRow/index.tsx +1 -0
- package/src/components/MenuButton.tsx +105 -0
- package/src/components/ModalButtons/DialogButton.tsx +84 -0
- package/src/components/ModalButtons/DrawerButton.tsx +89 -0
- package/src/components/ModalButtons/index.tsx +4 -0
- package/src/components/NoDataIllustration/NoDataIllustration.tsx +32 -0
- package/src/components/NoDataIllustration/index.tsx +1 -0
- package/src/components/PageContent.tsx +14 -0
- package/src/components/PageHeader.tsx +52 -0
- package/src/components/PopupConfirm/ConfirmContextProvider.tsx +22 -0
- package/src/components/PopupConfirm/PopupConfirm.tsx +33 -0
- package/src/components/PopupConfirm/index.tsx +1 -0
- package/src/components/PopupConfirm/useConfirm.ts +47 -0
- package/src/components/Row/Row.tsx +24 -0
- package/src/components/Row/index.tsx +1 -0
- package/src/components/SearchBar/SearchBar.tsx +53 -0
- package/src/components/SearchBar/index.tsx +1 -0
- package/src/components/Spinner.tsx +18 -0
- package/src/components/StepsHeader/StepsHeader.tsx +115 -0
- package/src/components/StepsHeader/index.tsx +1 -0
- package/src/components/Styled/OutlinedIconButton.tsx +7 -0
- package/src/components/Styled/index.tsx +1 -0
- package/src/components/StyledTableContainer.tsx +33 -0
- package/src/components/Swiper/Swiper.tsx +39 -0
- package/src/components/Swiper/index.tsx +1 -0
- package/src/components/SwitchButton/SwitchButton.tsx +41 -0
- package/src/components/SwitchButton/index.tsx +1 -0
- package/src/components/TableComponent/BatchActionsHeader.tsx +58 -0
- package/src/components/TableComponent/Icons/index.tsx +50 -0
- package/src/components/TableComponent/ReactTable.tsx +293 -0
- package/src/components/TableComponent/RenderTableBody.tsx +65 -0
- package/src/components/TableComponent/TableFooter/TableFooter.tsx +102 -0
- package/src/components/TableComponent/TableFooter/index.tsx +1 -0
- package/src/components/TableComponent/TableFooter/styles.tsx +28 -0
- package/src/components/TableComponent/index.tsx +219 -0
- package/src/components/TableComponent/no-data-illu.svg +1 -0
- package/src/components/TableComponent/react-table-config.d.ts +129 -0
- package/src/components/TableComponent/styles.tsx +173 -0
- package/src/components/TableComponent/types.ts +57 -0
- package/src/components/Tabs/Tabs.tsx +52 -0
- package/src/components/Tabs/TabsContainer.tsx +50 -0
- package/src/components/Tabs/index.tsx +1 -0
- package/src/components/Tabs/styles.tsx +55 -0
- package/src/components/ToastContainer/ToastContainer.tsx +42 -0
- package/src/components/ToastContainer/index.tsx +1 -0
- package/src/components/UploadButton/UploadButton.tsx +98 -0
- package/src/components/UploadButton/index.tsx +1 -0
- package/src/components/UploadButton/types.ts +14 -0
- package/src/components/UploadDocument/UploadDocument.tsx +108 -0
- package/src/components/UploadDocument/index.tsx +1 -0
- package/src/components/UploadFileDialog/UploadFileDialog.tsx +240 -0
- package/src/components/UploadFileDialog/index.tsx +1 -0
- package/src/components/index.ts +59 -0
- package/src/config/axios.ts +138 -0
- package/src/constants/UIConstants.ts +97 -0
- package/src/constants/formValidations.ts +6 -0
- package/src/constants/index.ts +4 -0
- package/src/constants/permissions.ts +67 -0
- package/src/constants/validateMessages.ts +12 -0
- package/src/contexts/Providers.tsx +24 -0
- package/src/contexts/QueryClientProvider.tsx +22 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useFetch.ts +53 -0
- package/src/hooks/useRouter.ts +31 -0
- package/src/index.tsx +9 -0
- package/src/layouts/ComponentsLayout.tsx +3 -0
- package/src/pages/LoginPage/LoginPage.tsx +166 -0
- package/src/pages/LoginPage/index.ts +1 -0
- package/src/pages/LoginPage/styles.tsx +121 -0
- package/src/pages/index.ts +4 -0
- package/src/permissions/PageWithPermission.tsx +58 -0
- package/src/permissions/PermissionDeniedPage.tsx +23 -0
- package/src/permissions/PermissionsStore.ts +289 -0
- package/src/permissions/ValidateAccess.tsx +18 -0
- package/src/permissions/index.ts +3 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/shared-state/AssetsStore.ts +15 -0
- package/src/shared-state/UserStore.ts +13 -0
- package/src/shared-state/index.ts +3 -0
- package/src/stories/Button.stories.tsx +41 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Header.stories.tsx +25 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Page.stories.tsx +26 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/TextField.stories.tsx +18 -0
- package/src/stories/TextField.tsx +49 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/src/theme/App.less +3 -0
- package/src/theme/MuiThemeProvider.tsx +11 -0
- package/src/theme/customCssBaseline.ts +78 -0
- package/src/theme/index.css +75 -0
- package/src/theme/muiTheme.ts +516 -0
- package/src/theme/theme.d.ts +75 -0
- package/src/utils/alphabet.ts +23 -0
- package/src/utils/arrayPadEnd.ts +3 -0
- package/src/utils/formatCurrency.ts +9 -0
- package/src/utils/getUrlParams.ts +5 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/ordinalSuffixOf.ts +14 -0
- package/src/utils/romanize.ts +40 -0
- package/src/utils/withRouteWrapper.tsx +25 -0
- package/src/utils/withSuspense.tsx +6 -0
- package/styled-components.tsx +60 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import Axios from 'axios'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import { toast } from 'react-toastify'
|
|
4
|
+
import { globalStore } from '../App'
|
|
5
|
+
import Cookies from 'js-cookie'
|
|
6
|
+
|
|
7
|
+
const isDevelopment = process.env.NODE_ENV === 'development'
|
|
8
|
+
const sessionKey = Cookies.get('campx_session_key')
|
|
9
|
+
|
|
10
|
+
const formatParams = (params) => {
|
|
11
|
+
return Object.fromEntries(
|
|
12
|
+
Object.entries(params ?? {})?.map((i) => [
|
|
13
|
+
i[0],
|
|
14
|
+
i[1] === '__empty__' ? '' : i[1],
|
|
15
|
+
]),
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let axios = Axios.create({
|
|
20
|
+
baseURL: process.env.REACT_APP_API_HOST,
|
|
21
|
+
withCredentials: true,
|
|
22
|
+
...(isDevelopment && {
|
|
23
|
+
headers: {
|
|
24
|
+
campx_session_key: sessionKey,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
axios.interceptors.request.use(
|
|
30
|
+
function (config) {
|
|
31
|
+
const params = formatParams(config?.params)
|
|
32
|
+
globalStore.update((s) => {
|
|
33
|
+
s.loading = true
|
|
34
|
+
s.error.message = ''
|
|
35
|
+
s.error.statusCode = null
|
|
36
|
+
s.error.description = ''
|
|
37
|
+
})
|
|
38
|
+
return { ...config, params }
|
|
39
|
+
},
|
|
40
|
+
function (error) {
|
|
41
|
+
globalStore.update((s) => {
|
|
42
|
+
s.loading = true
|
|
43
|
+
})
|
|
44
|
+
return Promise.reject(error)
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
axios.interceptors.response.use(
|
|
49
|
+
function (response) {
|
|
50
|
+
globalStore.update((s) => {
|
|
51
|
+
s.loading = false
|
|
52
|
+
})
|
|
53
|
+
return response
|
|
54
|
+
},
|
|
55
|
+
function (err) {
|
|
56
|
+
globalStore.update((s) => {
|
|
57
|
+
s.loading = false
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
if (err.message == 'Network Error') {
|
|
61
|
+
globalStore.update((s) => {
|
|
62
|
+
s.error = {
|
|
63
|
+
message: err.message,
|
|
64
|
+
statusCode: 999,
|
|
65
|
+
description: 'Please check your network connection',
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
const method = err.response.config.method
|
|
70
|
+
if (method === 'get' || method === 'GET') {
|
|
71
|
+
setError(err.response.status, err.response.data.message)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return Promise.reject(err)
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
export default axios
|
|
81
|
+
|
|
82
|
+
export const axiosErrorToast = (error: any, fallback?: string) => {
|
|
83
|
+
const fallbackMessage = fallback ?? 'Something went wrong.'
|
|
84
|
+
const errorMessage =
|
|
85
|
+
typeof error?.response?.data?.message !== 'string'
|
|
86
|
+
? error?.response?.data?.message?.join('\n') ?? fallbackMessage
|
|
87
|
+
: error?.response?.data?.message
|
|
88
|
+
|
|
89
|
+
return toast.error(errorMessage)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const setError = (statusCode: number, message: string) => {
|
|
93
|
+
switch (statusCode) {
|
|
94
|
+
case 401:
|
|
95
|
+
localStorage.removeItem('token')
|
|
96
|
+
globalStore.update((s) => {
|
|
97
|
+
s.error.message = message ?? 'Session Expired!'
|
|
98
|
+
s.error.statusCode = statusCode
|
|
99
|
+
s.error.description =
|
|
100
|
+
'Your session has been expired, Please login to continue'
|
|
101
|
+
})
|
|
102
|
+
break
|
|
103
|
+
case 404:
|
|
104
|
+
// globalStore.update((s) => {
|
|
105
|
+
// s.error.message = message ?? 'Not Found!'
|
|
106
|
+
// s.error.statusCode = statusCode
|
|
107
|
+
// s.error.description =
|
|
108
|
+
// 'The resource you are trying to access is not found.'
|
|
109
|
+
// })
|
|
110
|
+
toast.error('The resource you are trying to access is not found.')
|
|
111
|
+
|
|
112
|
+
break
|
|
113
|
+
case 403:
|
|
114
|
+
globalStore.update((s) => {
|
|
115
|
+
s.error.message = message ?? 'Forbidden!'
|
|
116
|
+
s.error.statusCode = statusCode
|
|
117
|
+
s.error.description =
|
|
118
|
+
'The resource you are trying to access is forbidden.'
|
|
119
|
+
})
|
|
120
|
+
break
|
|
121
|
+
|
|
122
|
+
case 400:
|
|
123
|
+
case 422:
|
|
124
|
+
globalStore.update((s) => {
|
|
125
|
+
s.error.message = ''
|
|
126
|
+
s.error.description = ''
|
|
127
|
+
s.error.statusCode = null
|
|
128
|
+
})
|
|
129
|
+
break
|
|
130
|
+
|
|
131
|
+
default:
|
|
132
|
+
globalStore.update((s) => {
|
|
133
|
+
s.error.message = 'Unknown Network Error!'
|
|
134
|
+
s.error.statusCode = 999
|
|
135
|
+
s.error.description = 'Unknown network error occurred!'
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export const batchOptions = Array.from({ length: 11 }, (_, i) => {
|
|
2
|
+
return `${2012 + i} - ${2012 + i + 1}`
|
|
3
|
+
}).reverse()
|
|
4
|
+
|
|
5
|
+
export const examGroupBatches = Array.from({ length: 10 }, (_, i) => {
|
|
6
|
+
return `${2012 + i} - ${2012 + i + 1}`
|
|
7
|
+
})
|
|
8
|
+
export const currentYear = new Date().getFullYear()
|
|
9
|
+
|
|
10
|
+
const startYear = 2012
|
|
11
|
+
|
|
12
|
+
export const yearOptions = Array.from(
|
|
13
|
+
{ length: currentYear - startYear + 1 },
|
|
14
|
+
(_, i) => {
|
|
15
|
+
return `${startYear + i}`
|
|
16
|
+
},
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
export const months = [
|
|
20
|
+
'January',
|
|
21
|
+
'February',
|
|
22
|
+
'March',
|
|
23
|
+
'April',
|
|
24
|
+
'May',
|
|
25
|
+
'June',
|
|
26
|
+
'July',
|
|
27
|
+
'August',
|
|
28
|
+
'September',
|
|
29
|
+
'October',
|
|
30
|
+
'November',
|
|
31
|
+
'December',
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
export const religionOptions = [
|
|
35
|
+
'Hinduism',
|
|
36
|
+
'Islam',
|
|
37
|
+
'Christianity',
|
|
38
|
+
'Sikhism',
|
|
39
|
+
'Buddhism',
|
|
40
|
+
'Jainism',
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
export const casteOptions = [
|
|
44
|
+
'OC',
|
|
45
|
+
'BC_A',
|
|
46
|
+
'BC_B',
|
|
47
|
+
'BC_C',
|
|
48
|
+
'BC_D',
|
|
49
|
+
'BC_E',
|
|
50
|
+
'SC',
|
|
51
|
+
'ST',
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
export const nationalityOptions = ['Indian', 'Other']
|
|
55
|
+
|
|
56
|
+
export const examTimings = [
|
|
57
|
+
'09:00 AM',
|
|
58
|
+
'10:00 AM',
|
|
59
|
+
'11:00 AM',
|
|
60
|
+
'01:00 PM',
|
|
61
|
+
'02:00 PM',
|
|
62
|
+
'03:00 PM',
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
export const USER_TYPES = [
|
|
66
|
+
{
|
|
67
|
+
label: 'Staff User',
|
|
68
|
+
value: 'Staff_User',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: 'Faculty User',
|
|
72
|
+
value: 'Faculty_User',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: 'Student User',
|
|
76
|
+
value: 'Student_User',
|
|
77
|
+
},
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
export function getRandomColor(name) {
|
|
81
|
+
const firstAlphabet = name.charAt(0).toLowerCase()
|
|
82
|
+
|
|
83
|
+
const asciiCode = firstAlphabet.charCodeAt(0)
|
|
84
|
+
|
|
85
|
+
const colorNum =
|
|
86
|
+
asciiCode.toString() + asciiCode.toString() + asciiCode.toString()
|
|
87
|
+
|
|
88
|
+
var num = Math.round(0xffffff * parseInt(colorNum))
|
|
89
|
+
var r = (num >> 16) & 145
|
|
90
|
+
var g = (num >> 8) & 145
|
|
91
|
+
var b = num & 145
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
color: 'rgb(' + r + ', ' + g + ', ' + b + ', 0.8)',
|
|
95
|
+
character: firstAlphabet?.toUpperCase(),
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export interface IPermission {
|
|
2
|
+
can_create_admission: boolean
|
|
3
|
+
can_create_role: boolean
|
|
4
|
+
can_create_user: boolean
|
|
5
|
+
can_delete_admission: boolean
|
|
6
|
+
can_delete_role: boolean
|
|
7
|
+
can_delete_user: boolean
|
|
8
|
+
can_edit_admission: boolean
|
|
9
|
+
can_edit_role: boolean
|
|
10
|
+
can_edit_user: boolean
|
|
11
|
+
can_manage_admissions: boolean
|
|
12
|
+
can_manage_roles: boolean
|
|
13
|
+
can_manage_users: boolean
|
|
14
|
+
can_view_admissions: boolean
|
|
15
|
+
can_view_roles: boolean
|
|
16
|
+
can_view_users: boolean
|
|
17
|
+
can_view_students: boolean
|
|
18
|
+
can_view_exams: boolean
|
|
19
|
+
can_view_classrooms: boolean
|
|
20
|
+
can_view_clubs: boolean
|
|
21
|
+
can_view_events: boolean
|
|
22
|
+
can_view_students_feed: boolean
|
|
23
|
+
can_print_application_form: boolean
|
|
24
|
+
can_pay_tution_fee: boolean
|
|
25
|
+
can_allot_tution_fee: boolean
|
|
26
|
+
can_manage_scholarships: boolean
|
|
27
|
+
can_create_scholarship: boolean
|
|
28
|
+
can_edit_scholarship: boolean
|
|
29
|
+
can_delete_scholarship: boolean
|
|
30
|
+
can_manage_exams: boolean
|
|
31
|
+
can_create_exam: boolean
|
|
32
|
+
can_create_exam_timetable: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const defaultPermissions = {
|
|
36
|
+
can_create_admission: false,
|
|
37
|
+
can_create_role: false,
|
|
38
|
+
can_create_user: false,
|
|
39
|
+
can_delete_admission: false,
|
|
40
|
+
can_delete_role: false,
|
|
41
|
+
can_delete_user: false,
|
|
42
|
+
can_edit_admission: false,
|
|
43
|
+
can_edit_role: false,
|
|
44
|
+
can_edit_user: false,
|
|
45
|
+
can_manage_admissions: false,
|
|
46
|
+
can_manage_roles: false,
|
|
47
|
+
can_manage_users: false,
|
|
48
|
+
can_view_admissions: false,
|
|
49
|
+
can_view_roles: false,
|
|
50
|
+
can_view_users: false,
|
|
51
|
+
can_view_students: false,
|
|
52
|
+
can_view_exams: false,
|
|
53
|
+
can_view_classrooms: false,
|
|
54
|
+
can_view_clubs: false,
|
|
55
|
+
can_view_events: false,
|
|
56
|
+
can_view_students_feed: false,
|
|
57
|
+
can_print_application_form: false,
|
|
58
|
+
can_pay_tution_fee: false,
|
|
59
|
+
can_allot_tution_fee: false,
|
|
60
|
+
can_manage_scholarships: false,
|
|
61
|
+
can_create_scholarship: false,
|
|
62
|
+
can_edit_scholarship: false,
|
|
63
|
+
can_delete_scholarship: false,
|
|
64
|
+
can_manage_exams: false,
|
|
65
|
+
can_create_exam: false,
|
|
66
|
+
can_create_exam_timetable: false,
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Validation messages for ant design forms
|
|
2
|
+
|
|
3
|
+
export const validateMessages = {
|
|
4
|
+
required: '${label} is required!',
|
|
5
|
+
types: {
|
|
6
|
+
email: '${label} is not validate email!',
|
|
7
|
+
number: '${label} is not a validate number!',
|
|
8
|
+
},
|
|
9
|
+
number: {
|
|
10
|
+
range: '${label} must be between ${min} and ${max}',
|
|
11
|
+
},
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import MuiThemeProvider from "../theme/MuiThemeProvider";
|
|
2
|
+
import ConfirmContextProvider from "../components/PopupConfirm/ConfirmContextProvider";
|
|
3
|
+
import { CssBaseline } from "@mui/material";
|
|
4
|
+
import { BrowserRouter } from "react-router-dom";
|
|
5
|
+
import QueryClientProvider from "./QueryClientProvider";
|
|
6
|
+
|
|
7
|
+
import DialogProvider from "../components/DrawerWrapper/DrawerWrapper";
|
|
8
|
+
import { ToastContainer } from '../components'
|
|
9
|
+
|
|
10
|
+
export default function Providers({ children }) {
|
|
11
|
+
return (
|
|
12
|
+
<BrowserRouter>
|
|
13
|
+
<QueryClientProvider>
|
|
14
|
+
<MuiThemeProvider>
|
|
15
|
+
<DialogProvider>
|
|
16
|
+
<ConfirmContextProvider>{children}</ConfirmContextProvider>
|
|
17
|
+
<CssBaseline />
|
|
18
|
+
<ToastContainer />
|
|
19
|
+
</DialogProvider>
|
|
20
|
+
</MuiThemeProvider>
|
|
21
|
+
</QueryClientProvider>
|
|
22
|
+
</BrowserRouter>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
QueryClient,
|
|
3
|
+
QueryClientProvider as ReactQueryClientProvider,
|
|
4
|
+
} from 'react-query'
|
|
5
|
+
|
|
6
|
+
export const queryClient = new QueryClient({
|
|
7
|
+
defaultOptions: {
|
|
8
|
+
queries: {
|
|
9
|
+
refetchOnWindowFocus: false,
|
|
10
|
+
retry: false,
|
|
11
|
+
// useErrorBoundary: (error: AxiosError) => error.response?.status >= 400,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default function QueryClientProvider({ children }) {
|
|
17
|
+
return (
|
|
18
|
+
<ReactQueryClientProvider client={queryClient}>
|
|
19
|
+
{children}
|
|
20
|
+
</ReactQueryClientProvider>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import axios from '../config/axios'
|
|
3
|
+
|
|
4
|
+
export function useMockFetch(promiseFn: Function) {
|
|
5
|
+
const [data, setData] = useState<any>()
|
|
6
|
+
const [error, setError] = useState<any>(null)
|
|
7
|
+
const [loading, setLoading] = useState(true)
|
|
8
|
+
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setLoading(true)
|
|
11
|
+
promiseFn()
|
|
12
|
+
.then((res) => {
|
|
13
|
+
setData(res.data)
|
|
14
|
+
setLoading(false)
|
|
15
|
+
})
|
|
16
|
+
.catch((err) => {
|
|
17
|
+
setLoading(false)
|
|
18
|
+
setError(null)
|
|
19
|
+
})
|
|
20
|
+
}, [])
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
data,
|
|
24
|
+
loading,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function useFetch(url: string, skip?: boolean) {
|
|
29
|
+
const [data, setData] = useState<any>()
|
|
30
|
+
const [error, setError] = useState<any>(null)
|
|
31
|
+
const [loading, setLoading] = useState(true)
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (skip) return
|
|
35
|
+
setLoading(true)
|
|
36
|
+
axios
|
|
37
|
+
.get(url)
|
|
38
|
+
.then((res) => {
|
|
39
|
+
setData(res.data)
|
|
40
|
+
setLoading(false)
|
|
41
|
+
})
|
|
42
|
+
.catch((err) => {
|
|
43
|
+
setError(err)
|
|
44
|
+
setLoading(false)
|
|
45
|
+
})
|
|
46
|
+
}, [])
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
data,
|
|
50
|
+
loading,
|
|
51
|
+
error,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useLocation, useMatch, useNavigate, useParams } from 'react-router-dom'
|
|
2
|
+
|
|
3
|
+
const useHistory = () => {
|
|
4
|
+
const navigate = useNavigate()
|
|
5
|
+
const { pathname, search } = useLocation()
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
push: navigate,
|
|
9
|
+
location: {
|
|
10
|
+
pathname: pathname,
|
|
11
|
+
search: search,
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const useRouteMatch = (path?) => {
|
|
16
|
+
const { pathname } = useLocation()
|
|
17
|
+
const params = useParams()
|
|
18
|
+
const match = useMatch({ path, end: false })
|
|
19
|
+
// console.log({
|
|
20
|
+
// match,
|
|
21
|
+
// params,
|
|
22
|
+
// pathname,
|
|
23
|
+
// })
|
|
24
|
+
return {
|
|
25
|
+
params: params,
|
|
26
|
+
path: match?.pattern?.path,
|
|
27
|
+
url: pathname,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { useHistory, useRouteMatch }
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Spinner } from '../../components'
|
|
2
|
+
import { useFetch } from '../../hooks'
|
|
3
|
+
import axios from '../../config/axios'
|
|
4
|
+
import { Visibility, VisibilityOff } from '@mui/icons-material'
|
|
5
|
+
import {
|
|
6
|
+
Alert,
|
|
7
|
+
Box,
|
|
8
|
+
IconButton,
|
|
9
|
+
InputAdornment,
|
|
10
|
+
Stack,
|
|
11
|
+
Typography,
|
|
12
|
+
} from '@mui/material'
|
|
13
|
+
import { useState } from 'react'
|
|
14
|
+
import { useForm } from 'react-hook-form'
|
|
15
|
+
import { welcomeImage } from '../../assets/images'
|
|
16
|
+
import {
|
|
17
|
+
StyledBanner,
|
|
18
|
+
StyledBannerFooter,
|
|
19
|
+
StyledBannerImage,
|
|
20
|
+
StyledButton,
|
|
21
|
+
StyledFormSection,
|
|
22
|
+
StyledLink,
|
|
23
|
+
StyledMain,
|
|
24
|
+
StyledTextField,
|
|
25
|
+
} from './styles'
|
|
26
|
+
import { useNavigate } from 'react-router-dom'
|
|
27
|
+
import Cookies from 'js-cookie'
|
|
28
|
+
import axiosBase from 'axios'
|
|
29
|
+
|
|
30
|
+
const LoginPage = () => {
|
|
31
|
+
const { loading, data: assets } = useFetch('/assets')
|
|
32
|
+
|
|
33
|
+
if (loading) {
|
|
34
|
+
return <Spinner />
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<StyledMain>
|
|
40
|
+
<StyledBanner>
|
|
41
|
+
<StyledBannerImage>
|
|
42
|
+
<img src={welcomeImage} alt="login-banner" />
|
|
43
|
+
</StyledBannerImage>
|
|
44
|
+
<StyledBannerFooter>
|
|
45
|
+
<div className="logo">
|
|
46
|
+
<Typography variant="body1">Powered By</Typography>
|
|
47
|
+
<img
|
|
48
|
+
src={
|
|
49
|
+
'https://campx-logos.s3.ap-south-1.amazonaws.com/CampX.png'
|
|
50
|
+
}
|
|
51
|
+
alt="login-banner"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
<div className="copyright">
|
|
55
|
+
<Typography variant="subtitle1">
|
|
56
|
+
© All Rights reserved to CampX Edutech Pvt. Ltd., 2022
|
|
57
|
+
</Typography>
|
|
58
|
+
</div>
|
|
59
|
+
</StyledBannerFooter>
|
|
60
|
+
</StyledBanner>
|
|
61
|
+
<StyledFormSection>
|
|
62
|
+
<Box width={'100%'}>
|
|
63
|
+
<Box
|
|
64
|
+
sx={{
|
|
65
|
+
display: 'flex',
|
|
66
|
+
justifyContent: 'center',
|
|
67
|
+
marginBottom: '54px',
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<img
|
|
71
|
+
src={assets?.logo}
|
|
72
|
+
style={{
|
|
73
|
+
width: '200px',
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
</Box>
|
|
77
|
+
<LoginForm />
|
|
78
|
+
</Box>
|
|
79
|
+
</StyledFormSection>
|
|
80
|
+
</StyledMain>
|
|
81
|
+
<StyledLink
|
|
82
|
+
style={{
|
|
83
|
+
textAlign: 'right',
|
|
84
|
+
display: 'block',
|
|
85
|
+
position: 'absolute',
|
|
86
|
+
top: '20px',
|
|
87
|
+
right: '20px',
|
|
88
|
+
}}
|
|
89
|
+
href="/results/search"
|
|
90
|
+
>
|
|
91
|
+
Student Results
|
|
92
|
+
</StyledLink>
|
|
93
|
+
</>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default LoginPage
|
|
98
|
+
|
|
99
|
+
export function LoginForm() {
|
|
100
|
+
const [showPassword, setShowPassword] = useState(false)
|
|
101
|
+
const { handleSubmit, control } = useForm()
|
|
102
|
+
const [error, setError] = useState('')
|
|
103
|
+
|
|
104
|
+
const onSubmit = async (values) => {
|
|
105
|
+
try {
|
|
106
|
+
const res = await axiosBase.post(
|
|
107
|
+
`https://auth-api.campx.in/auth/login`,
|
|
108
|
+
values,
|
|
109
|
+
)
|
|
110
|
+
Cookies.set('campx_session_key', res.data.cookie)
|
|
111
|
+
window.location.href = '/'
|
|
112
|
+
} catch (err) {
|
|
113
|
+
// eslint-disable-next-line no-console
|
|
114
|
+
console.log(err)
|
|
115
|
+
setError(err.response.data.message ?? 'Server Error')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Box sx={{ maxWidth: '500px' }} margin="0 auto" padding={'0 1rem'}>
|
|
121
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
122
|
+
<Stack gap={'40px'}>
|
|
123
|
+
<Box>
|
|
124
|
+
<StyledTextField
|
|
125
|
+
size="medium"
|
|
126
|
+
control={control}
|
|
127
|
+
name="username"
|
|
128
|
+
label="User ID"
|
|
129
|
+
required
|
|
130
|
+
/>
|
|
131
|
+
</Box>
|
|
132
|
+
<Box>
|
|
133
|
+
<StyledTextField
|
|
134
|
+
control={control}
|
|
135
|
+
name="password"
|
|
136
|
+
label="Password"
|
|
137
|
+
type={showPassword ? 'text' : 'password'}
|
|
138
|
+
required
|
|
139
|
+
InputProps={{
|
|
140
|
+
endAdornment: (
|
|
141
|
+
<InputAdornment position="end">
|
|
142
|
+
<IconButton
|
|
143
|
+
size="small"
|
|
144
|
+
aria-label="toggle password visibility"
|
|
145
|
+
onClick={() => setShowPassword((prev) => !prev)}
|
|
146
|
+
edge="end"
|
|
147
|
+
>
|
|
148
|
+
{showPassword ? <VisibilityOff /> : <Visibility />}
|
|
149
|
+
</IconButton>
|
|
150
|
+
</InputAdornment>
|
|
151
|
+
),
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
</Box>
|
|
155
|
+
<StyledButton type="submit">Login</StyledButton>
|
|
156
|
+
</Stack>
|
|
157
|
+
</form>
|
|
158
|
+
{error && (
|
|
159
|
+
<Alert severity="error" sx={{ marginTop: '20px' }}>
|
|
160
|
+
{error}
|
|
161
|
+
</Alert>
|
|
162
|
+
)}
|
|
163
|
+
</Box>
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './LoginPage'
|