@campxdev/shared 1.8.49-alpha.8 → 1.8.49-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.8.49-alpha.8",
3
+ "version": "1.8.49-alpha.9",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -11,6 +11,10 @@ import { useEffect, useState } from 'react'
11
11
  import { useMutation, useQuery } from 'react-query'
12
12
  import { toast } from 'react-toastify'
13
13
  import { useImmer } from 'use-immer'
14
+ import { PageContent } from '../PageContent'
15
+ import PageHeader from '../PageHeader'
16
+ import useConfirm from '../PopupConfirm/useConfirm'
17
+ import Spinner from '../Spinner'
14
18
  import UserProfileRelation from './UserProfileRelation'
15
19
  import {
16
20
  defaultFilterObj,
@@ -18,20 +22,16 @@ import {
18
22
  fetchProfiles,
19
23
  removeUserApplicationProfile,
20
24
  updateUserApplicationProfile,
21
- } from './Service'
22
- import useConfirm from '../PopupConfirm/useConfirm'
23
- import Spinner from '../Spinner'
24
- import PageHeader from '../PageHeader'
25
- import { PageContent } from '../PageContent'
25
+ } from './services'
26
26
 
27
- import { SingleSelect } from '../Input'
28
- import ActionButton from '../ActionButton'
29
27
  import { axiosErrorToast } from '../../config/axios'
30
- import { DialogButton } from '../ModalButtons'
31
- import SearchBar from '../FilterComponents/SearchBar'
32
- import Table from '../Tables/BasicTable/Table'
33
28
  import { ValidateAccess } from '../../permissions'
34
29
  import { Permission, PermissionsStore } from '../../shared-state'
30
+ import ActionButton from '../ActionButton'
31
+ import SearchBar from '../FilterComponents/SearchBar'
32
+ import { SingleSelect } from '../Input'
33
+ import { DialogButton } from '../ModalButtons'
34
+ import Table from '../Tables/BasicTable/Table'
35
35
 
36
36
  interface ApplicationProfileProps {
37
37
  application: 'exams' | 'square' | 'payments' | 'enroll_x' | 'hostels'
@@ -44,14 +44,14 @@ interface ApplicationProfileProps {
44
44
  }
45
45
  }
46
46
  function ApplicationProfile({
47
- application = 'exams',
47
+ application,
48
48
  title,
49
49
  permissions,
50
50
  }: ApplicationProfileProps) {
51
51
  const { isConfirmed } = useConfirm()
52
52
  const [filters, setFilters] = useImmer(defaultFilterObj)
53
53
  const { data, isLoading, refetch } = useQuery(
54
- ['application-users', ...Object.keys(filters)?.map((key) => filters[key])],
54
+ ['application-users', filters],
55
55
  () => fetchApplicationUsers({ application, ...filters }),
56
56
  )
57
57
 
@@ -100,8 +100,8 @@ function ApplicationProfile({
100
100
  },
101
101
  {
102
102
  title: 'Actions',
103
- key: '',
104
- dataIndex: '',
103
+ key: 'actions',
104
+ dataIndex: 'actions',
105
105
  render: (_, row) => (
106
106
  <ValidateAccess
107
107
  accessKey={
@@ -133,16 +133,15 @@ function ApplicationProfile({
133
133
  s.offset = value * s.limit - s.limit
134
134
  })
135
135
  }
136
- if (profilesLoading) {
137
- return <Spinner />
138
- }
136
+
137
+ if (profilesLoading) return <Spinner />
139
138
  return (
140
139
  <>
141
140
  <PageHeader
142
141
  title={title}
143
142
  actions={[
144
143
  <ValidateAccess
145
- key={0}
144
+ key={1}
146
145
  accessKey={
147
146
  permissions
148
147
  ? Permission[permissions.add]
@@ -150,7 +149,6 @@ function ApplicationProfile({
150
149
  }
151
150
  >
152
151
  <DialogButton
153
- key={0}
154
152
  title={'Add User Profile Relation'}
155
153
  anchor={({ open }) => (
156
154
  <ActionButton onClick={open}>
@@ -185,7 +183,7 @@ function ApplicationProfile({
185
183
  />
186
184
  <Table
187
185
  columns={columns}
188
- dataSource={data?.users ?? []}
186
+ dataSource={data?.result ?? []}
189
187
  loading={isLoading || removingUserProfile}
190
188
  pagination={{
191
189
  limit: filters.limit,
@@ -213,17 +211,19 @@ export const RenderProfileDropDown = ({
213
211
  const CanEdit = permissions
214
212
  ? permissionState.permissions[Permission[permissions.edit]]
215
213
  : permissionState.permissions['can_dashboard_view']
214
+
216
215
  const [state, setState] = useState({
217
- userId: data.id,
218
- profileId: data.profiles[0].id,
216
+ userId: null,
217
+ profileId: null,
219
218
  })
220
219
 
221
220
  useEffect(() => {
222
221
  setState((pre) => ({
223
222
  userId: data.id,
224
- profileId: data.profiles[0].id,
223
+ profileId: data?.profiles?.find((p) => p.application === application)?.id,
225
224
  }))
226
225
  }, [data])
226
+
227
227
  const { mutate, isLoading } = useMutation(updateUserApplicationProfile, {
228
228
  onSuccess: (res) => {
229
229
  refetchFn()
@@ -246,6 +246,8 @@ export const RenderProfileDropDown = ({
246
246
  application: application,
247
247
  })
248
248
  }
249
+
250
+ if (!data) return null
249
251
  return (
250
252
  <>
251
253
  <StyledDropDownContainer>
@@ -1,5 +1,5 @@
1
1
  import { yupResolver } from '@hookform/resolvers/yup'
2
- import { Popper, Stack, styled } from '@mui/material'
2
+ import { Stack } from '@mui/material'
3
3
  import { useForm } from 'react-hook-form'
4
4
  import { useMutation, useQueryClient } from 'react-query'
5
5
  import { toast } from 'react-toastify'
@@ -11,7 +11,7 @@ import {
11
11
  createApplicationUserProfile,
12
12
  fetchUsers,
13
13
  userProfileSchema,
14
- } from './Service'
14
+ } from './services'
15
15
  interface UserProps {
16
16
  options: {
17
17
  label: any
@@ -52,7 +52,7 @@ function UserProfileRelation({ close, application, profiles }) {
52
52
  {
53
53
  onSuccess: (res) => {
54
54
  setState((s) => {
55
- s.options = res.users?.map((item) => ({
55
+ s.options = res.result?.map((item) => ({
56
56
  label: item.fullName,
57
57
  value: item.id,
58
58
  }))
@@ -128,41 +128,3 @@ function UserProfileRelation({ close, application, profiles }) {
128
128
  )
129
129
  }
130
130
  export default UserProfileRelation
131
-
132
- const StyledPopper = styled(Popper)(({ theme }) => ({
133
- '& .MuiPaper-root': {
134
- borderRadius: '10px',
135
- borderTopRightRadius: 0,
136
- borderTopLeftRadius: 0,
137
- boxShadow: '0px 4px 16px #0000000F',
138
- marginTop: '1px',
139
- '& .MuiAutocomplete-listbox': {
140
- minWidth: '240px',
141
- padding: '10px',
142
- '& .MuiAutocomplete-option': {
143
- padding: '10px',
144
- background: 'none',
145
- '&.Mui-focused': {
146
- background: 'none',
147
- },
148
- },
149
- '& .MuiCheckbox-root': {
150
- padding: 0,
151
- marginRight: '10px',
152
- },
153
- },
154
- '&::-webkit-scrollbar': {
155
- width: '0.5em',
156
- height: '0.5em',
157
- },
158
-
159
- '&::-webkit-scrollbar-thumb': {
160
- backgroundColor: 'rgba(0, 0, 0, 0.15)',
161
- borderRadius: '3px',
162
-
163
- '&:hover': {
164
- background: 'rgba(0, 0, 0, 0.2)',
165
- },
166
- },
167
- },
168
- }))
@@ -1,4 +1,4 @@
1
- export const batchOptions = Array.from({ length: 11 }, (_, i) => {
1
+ export const batchOptions = Array.from({ length: 12 }, (_, i) => {
2
2
  return `${2012 + i} - ${2012 + i + 1}`
3
3
  }).reverse()
4
4