@campxdev/shared 1.8.23 → 1.8.24

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.23",
3
+ "version": "1.8.24",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -30,12 +30,23 @@ import { axiosErrorToast } from '../../config/axios'
30
30
  import { DialogButton } from '../ModalButtons'
31
31
  import SearchBar from '../FilterComponents/SearchBar'
32
32
  import Table from '../Tables/BasicTable/Table'
33
+ import { ValidateAccess } from '../../permissions'
34
+ import { Permission } from '../../shared-state'
33
35
 
34
36
  interface ApplicationProfileProps {
35
37
  application: 'exams' | 'square' | 'payments' | 'enroll_x'
38
+ title: string
39
+ permissions?: {
40
+ add: string
41
+ edit: string
42
+ view: string
43
+ delete: string
44
+ }
36
45
  }
37
46
  function ApplicationProfile({
38
47
  application = 'exams',
48
+ title,
49
+ permissions,
39
50
  }: ApplicationProfileProps) {
40
51
  const { isConfirmed } = useConfirm()
41
52
  const [filters, setFilters] = useImmer(defaultFilterObj)
@@ -83,6 +94,7 @@ function ApplicationProfile({
83
94
  data={row}
84
95
  application={application}
85
96
  refetchFn={refetch}
97
+ permissions={permissions}
86
98
  />
87
99
  ),
88
100
  },
@@ -91,13 +103,17 @@ function ApplicationProfile({
91
103
  key: '',
92
104
  dataIndex: '',
93
105
  render: (_, row) => (
94
- <Button
95
- variant="text"
96
- onClick={() => handleRemove(row)}
97
- sx={{ padding: '0px', margin: '0px' }}
106
+ <ValidateAccess
107
+ accessKey={permissions ? Permission[permissions.delete] : 1}
98
108
  >
99
- Remove
100
- </Button>
109
+ <Button
110
+ variant="text"
111
+ onClick={() => handleRemove(row)}
112
+ sx={{ padding: '0px', margin: '0px' }}
113
+ >
114
+ Remove
115
+ </Button>
116
+ </ValidateAccess>
101
117
  ),
102
118
  },
103
119
  ]
@@ -119,24 +135,29 @@ function ApplicationProfile({
119
135
  return (
120
136
  <>
121
137
  <PageHeader
122
- title={'Profile Configuration'}
138
+ title={title}
123
139
  actions={[
124
- <DialogButton
140
+ <ValidateAccess
125
141
  key={0}
126
- title={'Add User Profile Relation'}
127
- anchor={({ open }) => (
128
- <ActionButton onClick={open}>
129
- Add User Profile Relation
130
- </ActionButton>
131
- )}
132
- content={({ close }) => (
133
- <UserProfileRelation
134
- close={close}
135
- application={application}
136
- profiles={profiles?.profiles}
137
- />
138
- )}
139
- />,
142
+ accessKey={permissions ? Permissions[permissions.add] : 1}
143
+ >
144
+ <DialogButton
145
+ key={0}
146
+ title={'Add User Profile Relation'}
147
+ anchor={({ open }) => (
148
+ <ActionButton onClick={open}>
149
+ Add User Profile Relation
150
+ </ActionButton>
151
+ )}
152
+ content={({ close }) => (
153
+ <UserProfileRelation
154
+ close={close}
155
+ application={application}
156
+ profiles={profiles?.profiles}
157
+ />
158
+ )}
159
+ />
160
+ </ValidateAccess>,
140
161
  ]}
141
162
  />
142
163
  <PageContent sx={{ marginTop: '25px' }}>
@@ -178,7 +199,9 @@ export const RenderProfileDropDown = ({
178
199
  data,
179
200
  refetchFn,
180
201
  application,
202
+ permissions,
181
203
  }) => {
204
+ const CanEdit = permissions ? Permissions[permissions.edit] : 1
182
205
  const [state, setState] = useState({
183
206
  userId: data.id,
184
207
  profileId: data.profiles[0].id,
@@ -216,6 +239,7 @@ export const RenderProfileDropDown = ({
216
239
  onChange={(e) => {
217
240
  handleChange(e)
218
241
  }}
242
+ disabled={!CanEdit}
219
243
  endAdornment={
220
244
  isLoading && (
221
245
  <InputAdornment position="end">
@@ -58,7 +58,7 @@ export { default as ReactTable } from './Tables/ReactTable'
58
58
  export { default as TableFooter } from './Tables/BasicTable/TableFooter'
59
59
  export { default as DropDownButton } from './DropDownButton'
60
60
  export { default as useConfirm } from './PopupConfirm/useConfirm'
61
-
61
+ export { default } from './ApplicationProfile'
62
62
  export {
63
63
  UploadFileDialog,
64
64
  Chips,