@campxdev/shared 1.10.76 → 1.10.77

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.10.76",
3
+ "version": "1.10.77",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -82,18 +82,20 @@ export const EducationForm = ({ data, hideDialog }) => {
82
82
  label="Institution"
83
83
  required
84
84
  />
85
- <FormDatePicker
86
- control={control}
87
- name="startDate"
88
- label="From Date"
89
- required
90
- />
91
- <FormDatePicker
92
- control={control}
93
- name="endDate"
94
- label="To Date"
95
- required
96
- />
85
+ <Stack direction="row" gap={2}>
86
+ <FormDatePicker
87
+ control={control}
88
+ name="startDate"
89
+ label="From Date"
90
+ required
91
+ />
92
+ <FormDatePicker
93
+ control={control}
94
+ name="endDate"
95
+ label="To Date"
96
+ required
97
+ />
98
+ </Stack>
97
99
  <FormTextField
98
100
  control={control}
99
101
  multiline
@@ -17,10 +17,14 @@ import {
17
17
  import { createUpdateExperience } from '../service'
18
18
 
19
19
  const schema = yup.object().shape({
20
- experienceType: yup.string().required('Experience Type is required'),
20
+ experienceType: yup.string().required('Experience type is required'),
21
21
  title: yup.string().required('Title is required'),
22
- organizationName: yup.string().required('Organization Name is required'),
23
- fromDate: yup.string().required('FromDate is Required'),
22
+ organizationName: yup.string().required('Organization name is required'),
23
+ fromDate: yup.string().required('From date is Required'),
24
+ toDate: yup.string().when('currentlyWorking', {
25
+ is: (val) => !val,
26
+ then: yup.string().required('To date is Required'),
27
+ }),
24
28
  })
25
29
 
26
30
  export const ExperienceForm = ({ data, hideDialog }) => {
@@ -63,6 +67,7 @@ export const ExperienceForm = ({ data, hideDialog }) => {
63
67
  }
64
68
  const selectedType = watch('experienceType')
65
69
  const currentlyWorking = watch('currentlyWorking')
70
+ const isEmploymentType = selectedType === 'Employment'
66
71
 
67
72
  return (
68
73
  <form onSubmit={handleSubmit(onSubmit, onError)}>
@@ -82,7 +87,7 @@ export const ExperienceForm = ({ data, hideDialog }) => {
82
87
  <FormTextField
83
88
  control={control}
84
89
  name="title"
85
- label="Title"
90
+ label={isEmploymentType ? 'Job Title' : `${selectedType} Title`}
86
91
  required
87
92
  />
88
93
  <FormTextField
@@ -96,20 +101,22 @@ export const ExperienceForm = ({ data, hideDialog }) => {
96
101
  name="currentlyWorking"
97
102
  label="Currently Working"
98
103
  />
99
- <FormDatePicker
100
- control={control}
101
- name="fromDate"
102
- label="From"
103
- required
104
- />
105
- {!currentlyWorking && (
104
+ <Stack direction="row" gap={2}>
106
105
  <FormDatePicker
107
106
  control={control}
108
- name="toDate"
109
- label="To"
107
+ name="fromDate"
108
+ label="From"
110
109
  required
111
110
  />
112
- )}
111
+ {!currentlyWorking && (
112
+ <FormDatePicker
113
+ control={control}
114
+ name="toDate"
115
+ label="To"
116
+ required
117
+ />
118
+ )}
119
+ </Stack>
113
120
 
114
121
  <FormTextField
115
122
  control={control}
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-console */
2
1
  import { Box, Chip, Container, Typography } from '@mui/material'
3
2
  import { useQuery } from 'react-query'
4
3
  import axios from '../../config/axios'
@@ -31,7 +30,7 @@ const MyProfile = ({ close }) => {
31
30
  const { data: classroomSubjects } = useQuery('classroom-subjects', () =>
32
31
  axios.get('/square/subjects/faculty').then((res) => res?.data),
33
32
  )
34
- const { data: ResearchProject } = useQuery('research-projects', () =>
33
+ const { data: researchProject } = useQuery('research-projects', () =>
35
34
  axios.get('/square/research-projects').then((res) => res?.data),
36
35
  )
37
36
 
@@ -71,7 +70,7 @@ const MyProfile = ({ close }) => {
71
70
  {
72
71
  key: 'research projects',
73
72
  label: 'Research Projects',
74
- component: <ResearchProjects ResearchProject={ResearchProject} />,
73
+ component: <ResearchProjects researchProject={researchProject} />,
75
74
  },
76
75
  ]
77
76
  function Years(num) {
@@ -1,11 +1,18 @@
1
- /* eslint-disable react/jsx-key */
2
- import { Box, Button } from '@mui/material'
1
+ import { Box, Button, Chip } from '@mui/material'
3
2
  import { useFieldArray } from 'react-hook-form'
4
3
  import { FormTextField } from '../../HookForm'
5
4
  import { RadioGroup } from '../../Input'
6
- import { StyledBox, StyledDeleteButton, StyledStack } from './Styles'
5
+ import { StyledGrid, StyledStack } from './Styles'
7
6
 
8
- const Authors = ({ control, selectedAuthor, setState, authorsSelect }) => {
7
+ const Authors = ({
8
+ control,
9
+ selectedAuthor,
10
+ setState,
11
+ authorsSelect,
12
+ userName,
13
+ watch,
14
+ setValue,
15
+ }) => {
9
16
  const { fields, append, remove } = useFieldArray({
10
17
  control,
11
18
  name: 'authors',
@@ -29,56 +36,45 @@ const Authors = ({ control, selectedAuthor, setState, authorsSelect }) => {
29
36
  })
30
37
  }}
31
38
  />
39
+ {selectedAuthor === 'singleAuthor' && (
40
+ <Box sx={{ marginTop: 1 }}>
41
+ <Chip variant="outlined" color="primary" label={userName} disabled />
42
+ </Box>
43
+ )}
32
44
  {selectedAuthor === 'multipleAuthors' && (
33
45
  <Box>
34
- {!fields.length && (
35
- <StyledBox>
36
- <Button
37
- variant="text"
38
- color="primary"
39
- size="small"
40
- onClick={() => {
41
- append({ name: '' })
42
- }}
43
- >
44
- Add Author
45
- </Button>
46
- </StyledBox>
47
- )}
46
+ <StyledStack direction={'row'} gap={1}>
47
+ <FormTextField
48
+ control={control}
49
+ name="newAuthor"
50
+ label="Author Name"
51
+ required
52
+ />
53
+ <Button
54
+ variant="text"
55
+ color="primary"
56
+ size="small"
57
+ onClick={() => {
58
+ append({ name: watch('newAuthor') })
59
+ setValue('newAuthor', '')
60
+ }}
61
+ >
62
+ + Add
63
+ </Button>
64
+ </StyledStack>
48
65
 
49
- {fields && (
50
- <>
51
- <StyledBox>
52
- <Button
53
- variant="text"
54
- color="primary"
55
- size="small"
56
- onClick={() => {
57
- append({ name: '' })
58
- }}
59
- >
60
- Add Author
61
- </Button>
62
- </StyledBox>
63
- {fields.map((author, index) => (
64
- <StyledStack
65
- direction={'row'}
66
- gap={2}
67
- sx={{ alignItems: 'flex-end' }}
68
- >
69
- <FormTextField
70
- control={control}
71
- name={`authors[${index}].name`}
72
- label="Details about Authors"
73
- required
74
- />
75
- {index > 0 && (
76
- <StyledDeleteButton onClick={() => remove(index)} />
77
- )}
78
- </StyledStack>
79
- ))}
80
- </>
81
- )}
66
+ <StyledGrid>
67
+ {fields.map((author: any, index) => (
68
+ <Chip
69
+ key={author.id}
70
+ variant="outlined"
71
+ color="primary"
72
+ label={author.name}
73
+ onDelete={index === 0 ? null : () => remove(index)}
74
+ disabled={index === 0}
75
+ />
76
+ ))}
77
+ </StyledGrid>
82
78
  </Box>
83
79
  )}
84
80
  </Box>
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
  import { yupResolver } from '@hookform/resolvers/yup'
3
- import { Stack, Typography } from '@mui/material'
3
+ import { Stack } from '@mui/material'
4
4
  import { useEffect, useState } from 'react'
5
5
  import { useForm } from 'react-hook-form'
6
6
  import { useMutation, useQuery } from 'react-query'
@@ -34,7 +34,10 @@ const authorsSelect = [
34
34
  const schema = yup.object().shape({
35
35
  title: yup.string().required('Title is required'),
36
36
  publicationType: yup.string().required('Publication Type is required'),
37
- publicationYear: yup.number().required('Year of Publication is required'),
37
+ publicationYear: yup
38
+ .number()
39
+ .typeError('Year of Publication must be a number')
40
+ .required('Year of Publication is required'),
38
41
  stream: yup.string().required('Stream is required'),
39
42
  program: yup.string().required('Program is required'),
40
43
  })
@@ -123,7 +126,6 @@ export const PublicationsForm = ({ data, hideDialog, userProfile = null }) => {
123
126
  }, [data, setValue])
124
127
 
125
128
  const onSubmit = (formData) => {
126
- console.log(formData, 'formDaa')
127
129
  const isOthers = formData.publicationType === 'Other'
128
130
  const postBody = {
129
131
  ...formData,
@@ -138,7 +140,6 @@ export const PublicationsForm = ({ data, hideDialog, userProfile = null }) => {
138
140
  image: media[0]?.key || null,
139
141
  attachments: state.resource.map((file) => file.key),
140
142
  }
141
- console.log(postBody, 'postBody')
142
143
  mutate(postBody)
143
144
  }
144
145
 
@@ -210,9 +211,11 @@ export const PublicationsForm = ({ data, hideDialog, userProfile = null }) => {
210
211
  selectedAuthor={selectedAuthor}
211
212
  setState={setState}
212
213
  authorsSelect={authorsSelect}
214
+ userName={userProfile?.fullName}
215
+ watch={watch}
216
+ setValue={setValue}
213
217
  />
214
218
 
215
- <Typography variant="h5">{userProfile?.fullName}</Typography>
216
219
  <FormSingleSelect
217
220
  name="publicationType"
218
221
  label="Publication Type"
@@ -46,6 +46,13 @@ export const StyledDeleteButton = styled(DeleteButton)({
46
46
  })
47
47
 
48
48
  export const StyledStack = styled(Stack)({
49
- alignItems: 'center',
49
+ alignItems: 'flex-end',
50
50
  justifyContent: 'space-between',
51
51
  })
52
+
53
+ export const StyledGrid = styled(Stack)({
54
+ display: 'grid',
55
+ gridTemplateColumns: 'repeat(auto-fill, minmax(120px, max-content))',
56
+ gap: '10px',
57
+ marginTop: '10px',
58
+ })
@@ -3,52 +3,39 @@ import StyledTabsContainer from '../StyledTabsContainer'
3
3
  import ResearchProjectData from './ResearchProjectData'
4
4
  import ResearchProjectForm from './ResearchProjectForm'
5
5
 
6
- function ResearchProjects({ ResearchProject }) {
7
- const test = []
8
- const Research = true
9
- const Ongoing = ResearchProject?.filter(
10
- (project) => project?.projectStatus == 'ongoing',
11
- )
12
- const Completed = test?.filter(
13
- (project) => project?.projectStatus == 'completed',
14
- )
15
-
6
+ function ResearchProjects({ researchProject }) {
16
7
  const tabs = [
17
8
  {
18
- key: 'Ongoing',
19
- label: 'Ongoing',
20
- component: (
21
- <ResearchProjectData title={'Ongoing'} ResearchProject={Ongoing} />
22
- ),
23
- },
24
- {
25
- key: 'Completed',
26
- label: 'Completed',
9
+ key: 'ResearchProject',
10
+ label: 'Research Project',
27
11
  component: (
28
- <ResearchProjectData title={'Completed'} ResearchProject={Completed} />
12
+ <ResearchProjectData
13
+ title={'Research Project'}
14
+ ResearchProject={researchProject}
15
+ />
29
16
  ),
30
17
  },
31
18
  ]
32
- return (
19
+ const isResearchProject = researchProject && researchProject?.length > 0
20
+
21
+ return isResearchProject ? (
33
22
  <>
34
- {Research ? (
35
- <StyledTabsContainer
36
- tabs={tabs}
37
- centered
38
- textColor="primary"
39
- indicatorBackgroundColor="primary"
40
- />
41
- ) : (
42
- <NoDataSection
43
- title="ResearchProjects"
44
- subtitle="Add ResearchProjects"
45
- addButtonTitle="Add Your ResearchProjects"
46
- addButtonContent={({ close }) => (
47
- <ResearchProjectForm close={close} data={[]} />
48
- )}
49
- />
50
- )}
23
+ <StyledTabsContainer
24
+ tabs={tabs}
25
+ centered
26
+ textColor="primary"
27
+ indicatorBackgroundColor="primary"
28
+ />
51
29
  </>
30
+ ) : (
31
+ <NoDataSection
32
+ title="Research Project"
33
+ subtitle="Add Research Project"
34
+ addButtonTitle="Add Your Research Project"
35
+ addButtonContent={({ close }) => (
36
+ <ResearchProjectForm data={null} close={close} />
37
+ )}
38
+ />
52
39
  )
53
40
  }
54
41
 
@@ -171,18 +171,20 @@ export const WorkshopForm = ({ data, hideDialog }) => {
171
171
  label="Organization"
172
172
  required
173
173
  />
174
- <FormDatePicker
175
- control={control}
176
- name="fromDate"
177
- label="From Date"
178
- required
179
- />
180
- <FormDatePicker
181
- control={control}
182
- name="toDate"
183
- label="To Date"
184
- required
185
- />
174
+ <Stack direction="row" gap={2}>
175
+ <FormDatePicker
176
+ control={control}
177
+ name="fromDate"
178
+ label="From Date"
179
+ required
180
+ />
181
+ <FormDatePicker
182
+ control={control}
183
+ name="toDate"
184
+ label="To Date"
185
+ required
186
+ />
187
+ </Stack>
186
188
  <FormTextField
187
189
  control={control}
188
190
  name="stream"
@@ -27,6 +27,7 @@ export interface TableColumn {
27
27
  dataIndex: string
28
28
  key: string
29
29
  title?: any
30
+ showTitle: boolean
30
31
  render?: (cellData: any, row: any, index: number) => any
31
32
  textColor?: string
32
33
  sort?: boolean
@@ -36,7 +37,8 @@ export interface TableColumn {
36
37
 
37
38
  export interface ColumnHeader {
38
39
  title: any
39
- colSpan: number
40
+ colSpan?: number
41
+ rowSpan?: number
40
42
  }
41
43
 
42
44
  interface TableProps {
@@ -83,18 +85,18 @@ export default function Table({
83
85
  totalCols = totalColumns ? [...totalColumns] : []
84
86
  }
85
87
 
86
- const handleSortClick = (sortBykey) => {
88
+ const handleSortClick = (sortByKey) => {
87
89
  setSort((prev) => {
88
- if (prev[sortBykey]) {
89
- if (prev[sortBykey] === 'desc') return { ...prev, [sortBykey]: 'asc' }
90
- if (prev[sortBykey] === 'asc') {
91
- delete prev[sortBykey]
90
+ if (prev[sortByKey]) {
91
+ if (prev[sortByKey] === 'desc') return { ...prev, [sortByKey]: 'asc' }
92
+ if (prev[sortByKey] === 'asc') {
93
+ delete prev[sortByKey]
92
94
  return { ...prev }
93
95
  }
94
96
  } else {
95
97
  return {
96
98
  ...prev,
97
- [sortBykey]: 'desc',
99
+ [sortByKey]: 'desc',
98
100
  }
99
101
  }
100
102
  })
@@ -155,6 +157,7 @@ export default function Table({
155
157
  isHeaderCell
156
158
  align="center"
157
159
  colSpan={col.colSpan}
160
+ rowSpan={col.rowSpan}
158
161
  >
159
162
  {col.title}
160
163
  </StyledTableCell>
@@ -162,34 +165,39 @@ export default function Table({
162
165
  </TableRow>
163
166
  )}
164
167
  <TableRow>
165
- {columns.map((col, columnIndex) => (
166
- <StyledTableCell
167
- key={columnIndex}
168
- columnsLength={columns.length}
169
- columnIndex={columnIndex + 1}
170
- rowIndex={0}
171
- col={col}
172
- sx={sx}
173
- align="center"
174
- isHeaderCell
175
- >
176
- {col.title}
168
+ {columns.map(
169
+ (col, columnIndex) =>
170
+ col.showTitle && (
171
+ <StyledTableCell
172
+ key={columnIndex}
173
+ columnsLength={columns.length}
174
+ columnIndex={columnIndex + 1}
175
+ rowIndex={0}
176
+ col={col}
177
+ sx={sx}
178
+ align="center"
179
+ isHeaderCell
180
+ >
181
+ {col.title}
177
182
 
178
- {col.sort && (
179
- <IconButton onClick={() => handleSortClick(col.dataIndex)}>
180
- <ListItemIcon>
181
- {sort[col.dataIndex] === 'asc' ? (
182
- <SortAscIcon />
183
- ) : sort[col.dataIndex] === 'desc' ? (
184
- <SortDescIcon />
185
- ) : (
186
- <SortIcon />
187
- )}
188
- </ListItemIcon>
189
- </IconButton>
190
- )}
191
- </StyledTableCell>
192
- ))}
183
+ {col.sort && (
184
+ <IconButton
185
+ onClick={() => handleSortClick(col.dataIndex)}
186
+ >
187
+ <ListItemIcon>
188
+ {sort[col.dataIndex] === 'asc' ? (
189
+ <SortAscIcon />
190
+ ) : sort[col.dataIndex] === 'desc' ? (
191
+ <SortDescIcon />
192
+ ) : (
193
+ <SortIcon />
194
+ )}
195
+ </ListItemIcon>
196
+ </IconButton>
197
+ )}
198
+ </StyledTableCell>
199
+ ),
200
+ )}
193
201
  </TableRow>
194
202
  </TableHead>
195
203
  {!loading ? (