@campxdev/shared 1.11.7-0.alpha.55 → 1.11.7-0.alpha.57
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/package.json
CHANGED
|
@@ -205,11 +205,11 @@ export default function ReactTable({
|
|
|
205
205
|
/>
|
|
206
206
|
<Table sx={{ position: 'relative' }} {...getTableProps()}>
|
|
207
207
|
<TableHead>
|
|
208
|
-
{headerGroups.map((headerGroup,
|
|
209
|
-
<TableRow key={
|
|
208
|
+
{headerGroups.map((headerGroup, index) => (
|
|
209
|
+
<TableRow key={index} {...headerGroup.getHeaderGroupProps()}>
|
|
210
210
|
{showSerialNumber && <TableCell>S. No.</TableCell>}
|
|
211
|
-
{headerGroup.headers.map((column: any,
|
|
212
|
-
<TableCell key={
|
|
211
|
+
{headerGroup.headers.map((column: any, index) => (
|
|
212
|
+
<TableCell key={index} {...column.getHeaderProps()}>
|
|
213
213
|
{column.render('Header')}
|
|
214
214
|
{column.sort && (
|
|
215
215
|
<IconButton onClick={() => handleSortClick(column.id)}>
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosError } from 'axios'
|
|
1
2
|
import Cookies from 'js-cookie'
|
|
2
3
|
import { useEffect, useState } from 'react'
|
|
3
4
|
import { useNavigate } from 'react-router-dom'
|
|
@@ -94,87 +95,86 @@ function handleInstitutions(institutions) {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
permissionsEndpoint,
|
|
99
|
-
loginUrl,
|
|
100
|
-
}: AuthParams): AuthResponse => {
|
|
98
|
+
function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
|
|
101
99
|
const [loading, setLoading] = useState<boolean>(false)
|
|
102
|
-
const [data, setData] = useState
|
|
100
|
+
const [data, setData] = useState(null)
|
|
103
101
|
const { current } = InstitutionsStore.useState()
|
|
104
|
-
const navigate = useNavigate()
|
|
105
102
|
|
|
106
103
|
const appInit = async () => {
|
|
107
104
|
setLoading(true)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
s
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
PermissionsStore.update((s) => {
|
|
122
|
-
s.permissions = {
|
|
123
|
-
...res.data?.permissions,
|
|
124
|
-
can_settings_view: 1,
|
|
125
|
-
can_dashboard_view: 1,
|
|
126
|
-
can_individual_pages_view: 1,
|
|
127
|
-
can_analatics_view: isAdmin,
|
|
128
|
-
can_admin_view: isAdmin,
|
|
129
|
-
can_my_mentees_view:
|
|
130
|
-
res.data?.user?.isMentor &&
|
|
131
|
-
res.data?.permissions.can_my_mentees_view,
|
|
132
|
-
}
|
|
133
|
-
s.applications = res.data?.applications ?? []
|
|
134
|
-
s.institutionType = res.data?.institutionType
|
|
135
|
-
s.masterInstitutionUniqueId = res.data?.masterInstitutionUniqueId
|
|
136
|
-
s.masterInstitutionId = res.data?.masterInstitutionId
|
|
137
|
-
s.isMasterInstitutionUser = res.data?.institutions
|
|
138
|
-
?.map((institution) => institution?.id)
|
|
139
|
-
?.includes(res?.data?.masterInstitutionUniqueId)
|
|
140
|
-
s.isMasterInstitution = res.data?.isMasterInstitution
|
|
141
|
-
s.isHomePageEnabled = res.data?.isHomePageEnabled
|
|
142
|
-
})
|
|
105
|
+
axios
|
|
106
|
+
.get(permissionsEndpoint)
|
|
107
|
+
.then((res) => {
|
|
108
|
+
const isAdmin = checkIsAdmin(res.data.user)
|
|
109
|
+
|
|
110
|
+
setData(res.data)
|
|
111
|
+
UserStore.update((s) => {
|
|
112
|
+
s.username = res.data?.user?.username
|
|
113
|
+
s.user = res.data?.user
|
|
114
|
+
s.roles = res.data?.roles
|
|
115
|
+
s.globalUserId = res.data?.globalUserId
|
|
116
|
+
s.fullName = res.data?.fullName
|
|
117
|
+
})
|
|
143
118
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
119
|
+
PermissionsStore.update((s) => {
|
|
120
|
+
s.permissions = {
|
|
121
|
+
...res.data?.permissions,
|
|
122
|
+
can_settings_view: 1,
|
|
123
|
+
can_dashboard_view: 1,
|
|
124
|
+
can_individual_pages_view: 1,
|
|
125
|
+
can_analatics_view: isAdmin,
|
|
126
|
+
can_admin_view: isAdmin,
|
|
127
|
+
can_my_mentees_view:
|
|
128
|
+
res.data?.user?.isMentor &&
|
|
129
|
+
res.data?.permissions.can_my_mentees_view,
|
|
130
|
+
} as any
|
|
131
|
+
s.applications = res.data?.applications ?? []
|
|
132
|
+
s.institutionType = res.data?.institutionType
|
|
133
|
+
s.masterInstitutionUniqueId = res.data?.masterInstitutionUniqueId
|
|
134
|
+
s.masterInstitutionId = res.data?.masterInstitutionId
|
|
135
|
+
s.isMasterInstitutionUser = res.data?.institutions
|
|
136
|
+
?.map((institution) => institution?.id)
|
|
137
|
+
?.includes(res?.data?.masterInstitutionUniqueId)
|
|
138
|
+
s.isMasterInstitution = res.data?.isMasterInstitution
|
|
139
|
+
s.isHomePageEnabled = res.data?.isHomePageEnabled
|
|
140
|
+
})
|
|
150
141
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
InstitutionsStore.update((s) => {
|
|
143
|
+
s.institutions = res.data?.institutions
|
|
144
|
+
s.current = res.data?.institutions.find(
|
|
145
|
+
(item) => item.code === Cookies.get('campx_institution'),
|
|
146
|
+
)
|
|
147
|
+
})
|
|
155
148
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const origin = window.location.origin
|
|
160
|
-
const isStaging = origin.split('campx')[1] === '.dev'
|
|
161
|
-
|
|
162
|
-
if (isDevelopment || isStaging) {
|
|
163
|
-
openRootModal({
|
|
164
|
-
key: 'login',
|
|
165
|
-
contentData: {
|
|
166
|
-
loginUrl,
|
|
167
|
-
},
|
|
168
|
-
dialogProps: {
|
|
169
|
-
disableEscapeKeyDown: true,
|
|
170
|
-
onClose: () => {},
|
|
171
|
-
},
|
|
149
|
+
AssetsStore.update((s) => {
|
|
150
|
+
s.logo = res.data?.assets.logo
|
|
151
|
+
s.logo_square = res.data?.assets.logo_square
|
|
172
152
|
})
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
153
|
+
|
|
154
|
+
setLoading(false)
|
|
155
|
+
})
|
|
156
|
+
.catch((err: AxiosError) => {
|
|
157
|
+
const navigate = useNavigate()
|
|
158
|
+
setLoading && setLoading(false)
|
|
159
|
+
const origin = window.location.origin
|
|
160
|
+
const isStaging = origin.split('campx')[1] === '.dev'
|
|
161
|
+
|
|
162
|
+
if (isDevelopment || isStaging) {
|
|
163
|
+
openRootModal({
|
|
164
|
+
key: 'login',
|
|
165
|
+
contentData: {
|
|
166
|
+
loginUrl,
|
|
167
|
+
},
|
|
168
|
+
dialogProps: {
|
|
169
|
+
disableEscapeKeyDown: true,
|
|
170
|
+
onClose: () => {},
|
|
171
|
+
},
|
|
172
|
+
})
|
|
173
|
+
return
|
|
174
|
+
} else {
|
|
175
|
+
navigate('/auth/login')
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
useEffect(() => {
|
|
@@ -25,7 +25,6 @@ export const StyledHeaderContainer = styled.header`
|
|
|
25
25
|
|
|
26
26
|
export const StyledLeftNavContainer = muiStyled('aside')(({ theme }) => ({
|
|
27
27
|
width: sideNavWidth,
|
|
28
|
-
borderRadius: '8px 0px 0px 8px',
|
|
29
28
|
background: theme.palette.secondary.main,
|
|
30
29
|
color: 'white',
|
|
31
30
|
overflowY: 'scroll',
|