Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-029
2023-029
Commits
6d4db559
Commit
6d4db559
authored
Sep 03, 2023
by
janithgamage1.ed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
1e0eff13
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
39 deletions
+71
-39
Project/Frontend/SignConnectPlus/src/pages/parameter/curriculum-management/list/list.tsx
...s/src/pages/parameter/curriculum-management/list/list.tsx
+10
-8
Project/Frontend/SignConnectPlus/src/sections/parameters/curriculum-management/AddEditCurriculum.tsx
...ns/parameters/curriculum-management/AddEditCurriculum.tsx
+42
-22
Project/Frontend/SignConnectPlus/src/sections/parameters/curriculum-management/AlertCurriculumDelete.tsx
...arameters/curriculum-management/AlertCurriculumDelete.tsx
+13
-3
Project/Frontend/SignConnectPlus/src/store/reducers/curriculum.ts
...Frontend/SignConnectPlus/src/store/reducers/curriculum.ts
+2
-2
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
+4
-4
No files found.
Project/Frontend/SignConnectPlus/src/pages/parameter/curriculum-management/list/list.tsx
View file @
6d4db559
...
...
@@ -34,15 +34,15 @@ import { DeleteTwoTone, EditTwoTone, EyeTwoTone, PlusOutlined } from '@ant-desig
//types
import
{
PopupTransition
}
from
'
components/@extended/Transitions
'
;
import
curriculumLevels
from
'
data/curriculumLevels
'
;
import
status
from
'
data/status
'
;
import
AddEditCurriculum
from
'
sections/parameters/curriculum-management/AddEditCurriculum
'
;
import
AlertCurriculumDelete
from
'
sections/parameters/curriculum-management/AlertCurriculumDelete
'
;
import
{
useDispatch
,
useSelector
}
from
'
store
'
;
import
{
fetchCurriculums
,
toInitialState
}
from
'
store/reducers/curriculum
'
;
import
{
openSnackbar
}
from
'
store/reducers/snackbar
'
;
import
{
Curriculums
}
from
'
types/curriculum
'
;
import
{
ReactTableProps
,
curriculumProps
}
from
'
./types/types
'
;
import
curriculumLevels
from
'
data/curriculumLevels
'
;
import
{
Curriculum
,
Curriculums
}
from
'
types/curriculum
'
;
import
{
ReactTableProps
}
from
'
./types/types
'
;
// ==============================|| REACT TABLE ||============================== //
...
...
@@ -142,7 +142,7 @@ const List = () => {
[
{
Header
:
'
#
'
,
accessor
:
'
id
'
,
accessor
:
'
_
id
'
,
className
:
'
cell-center
'
,
Cell
:
({
row
}:
{
row
:
Row
})
=>
{
if
(
row
.
id
===
undefined
||
row
.
id
===
null
||
row
.
id
===
''
)
{
...
...
@@ -273,6 +273,7 @@ const List = () => {
onClick=
{
(
e
:
MouseEvent
<
HTMLButtonElement
>
)
=>
{
e
.
stopPropagation
();
setCurriculumId
(
row
.
values
.
_id
)
setCurriculumTitle
(
row
.
values
.
curriculumTitle
)
setOpenAlert
(
true
)
}
}
>
...
...
@@ -290,7 +291,7 @@ const List = () => {
//dialog model
const
[
addEdit
,
setAddEdit
]
=
useState
<
boolean
>
(
false
);
const
[
curriculum
,
setCurriculum
]
=
useState
<
curriculumProps
>
();
const
[
curriculum
,
setCurriculum
]
=
useState
<
Curriculum
>
();
const
handleAddEdit
=
()
=>
{
setAddEdit
(
!
addEdit
);
...
...
@@ -299,7 +300,8 @@ const List = () => {
//alert model
const
[
openAlert
,
setOpenAlert
]
=
useState
(
false
);
const
[
curriculumId
,
setCurriculumId
]
=
useState
<
number
|
string
|
undefined
>
(
undefined
)
const
[
curriculumId
,
setCurriculumId
]
=
useState
<
string
|
undefined
>
(
undefined
)
const
[
curriculumTitle
,
setCurriculumTitle
]
=
useState
<
string
|
undefined
>
(
undefined
)
const
handleAlertClose
=
()
=>
{
setOpenAlert
(
!
openAlert
);
...
...
@@ -375,10 +377,10 @@ const List = () => {
sx=
{
{
'
& .MuiDialog-paper
'
:
{
p
:
0
},
transition
:
'
transform 225ms
'
}
}
aria
-
describedby=
"alert-dialog-slide-description"
>
<
AddEditCurriculum
curriculum=
{
curriculum
}
onCancel=
{
handleAddEdit
}
/>
<
AddEditCurriculum
curriculum=
{
curriculum
!
}
onCancel=
{
handleAddEdit
}
/>
</
Dialog
>
{
/* alert model */
}
{
!
curriculum
&&
<
AlertCurriculumDelete
title=
{
""
}
open=
{
openAlert
}
handleClose=
{
handleAlertClose
}
deleteId=
{
curriculumId
}
/>
}
{
!
curriculum
&&
<
AlertCurriculumDelete
title=
{
curriculumTitle
!
}
open=
{
openAlert
}
handleClose=
{
handleAlertClose
}
deleteId=
{
curriculumId
}
/>
}
</
MainCard
>
</>
)
...
...
Project/Frontend/SignConnectPlus/src/sections/parameters/curriculum-management/AddEditCurriculum.tsx
View file @
6d4db559
import
{
useState
}
from
'
react
'
;
import
{
use
Effect
,
use
State
}
from
'
react
'
;
// material-ui
import
{
...
...
@@ -33,6 +33,12 @@ import IconButton from 'components/@extended/IconButton';
import
{
DeleteFilled
}
from
'
@ant-design/icons
'
;
import
MainCard
from
'
components/MainCard
'
;
import
curriculumLevels
,
{
CurriculumLevelsType
}
from
'
data/curriculumLevels
'
;
import
useAuth
from
'
hooks/useAuth
'
;
import
{
dispatch
,
useSelector
}
from
'
store
'
;
import
{
addCurriculum
}
from
'
store/reducers/curriculum
'
;
import
{
fetchTutorials
}
from
'
store/reducers/tutorial
'
;
import
{
Curriculum
}
from
'
types/curriculum
'
;
import
{
Tutorial
}
from
'
types/tutorial
'
;
import
AlertCurriculumDelete
from
'
./AlertCurriculumDelete
'
;
// types
...
...
@@ -60,25 +66,13 @@ const getInitialValues = (curriculum: FormikValues | null) => {
// ==============================|| CUSTOMER ADD / EDIT ||============================== //
export
interface
Props
{
curriculum
?:
{
_id
:
number
|
string
|
undefined
;
curriculumCode
:
string
;
curriculumLevel
:
number
;
curriculumTitle
:
string
;
curriculumDescription
:
string
;
curriculumImage
:
string
;
tutorials
:
string
[];
status
:
number
;
createdBy
:
string
;
updatedBy
:
string
;
createdAt
:
Date
;
updatedAt
:
Date
;
};
curriculum
:
Curriculum
;
onCancel
:
()
=>
void
;
}
const
AddEditCurriculum
=
({
curriculum
,
onCancel
}:
Props
)
=>
{
const
theme
=
useTheme
();
const
{
user
}
=
useAuth
();
const
isCreating
=
!
curriculum
;
...
...
@@ -96,11 +90,27 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => {
validationSchema
:
CurriculumSchema
,
enableReinitialize
:
true
,
onSubmit
:
(
values
,
{
setSubmitting
,
resetForm
})
=>
{
console
.
log
(
values
);
try
{
if
(
curriculum
)
{
// PUT API
}
else
{
// POST API
// const dummyObject: Curriculum = curriculumReqOb
// dispatch(addCurriculum(dummyObject))
const
req
:
Curriculum
=
{
curriculumCode
:
values
.
curriculumCode
,
curriculumLevel
:
values
.
curriculumLevel
!
,
curriculumTitle
:
values
.
curriculumTitle
,
curriculumDescription
:
values
.
curriculumDescription
,
curriculumImage
:
values
.
curriculumImage
,
tutorials
:
values
.
tutorials
!
,
createdBy
:
user
?.
name
!
,
};
dispatch
(
addCurriculum
(
req
))
}
resetForm
()
setSubmitting
(
false
);
...
...
@@ -114,6 +124,16 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => {
const
{
errors
,
touched
,
handleSubmit
,
isSubmitting
,
getFieldProps
,
values
}
=
formik
;
// const { handleSubmit, isSubmitting } = formik;
const
{
tutorials
}
=
useSelector
(
state
=>
state
.
tutorial
);
/**
* API Config
* Tutorial API
*/
useEffect
(()
=>
{
dispatch
(
fetchTutorials
());
},
[
dispatch
])
return
(
<>
<
FormikProvider
value=
{
formik
}
>
...
...
@@ -232,18 +252,18 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => {
values
.
tutorials
.
map
((
item
,
index
)
=>
{
return
(
<>
<
Grid
item
xs=
{
11
}
>
<
Grid
item
xs=
{
11
}
>
<
Stack
spacing=
{
1.25
}
>
<
InputLabel
htmlFor=
{
`tutorials.${index}`
}
>
Tutorial
</
InputLabel
>
<
Autocomplete
fullWidth
id=
{
`tutorials.${index}`
}
// value=
{
tutorials
.
find
((
option
)
=
>
option.id === formik.values.curriculumLevel
) || null}
// onChange=
{
(
event
:
any
,
newValue
:
CurriculumLevelsType
|
null
)
=>
{
// formik.setFieldValue(`tutorials.$
{
index
}
`, newValue?.
id);
//
}
}
options=
{
[]
}
// getOptionLabel=
{
(
item
)
=>
`${item.description
}`
}
value=
{
tutorials
.
find
((
option
)
=>
option
.
_id
===
formik
.
values
.
tutorials
[
index
]
)
||
null
}
onChange=
{
(
event
:
any
,
newValue
:
Tutorial
|
null
)
=>
{
formik
.
setFieldValue
(
`tutorials.${index}`
,
newValue
?.
_
id
);
}
}
options=
{
tutorials
}
getOptionLabel=
{
(
item
)
=>
`${item.tutorialTitle
}`
}
renderInput=
{
(
params
)
=>
{
return
(
<
TextField
...
...
Project/Frontend/SignConnectPlus/src/sections/parameters/curriculum-management/AlertCurriculumDelete.tsx
View file @
6d4db559
...
...
@@ -7,20 +7,22 @@ import { PopupTransition } from 'components/@extended/Transitions';
// assets
import
{
DeleteFilled
}
from
'
@ant-design/icons
'
;
import
{
useDispatch
}
from
'
store
'
;
import
{
deleteCurriculum
}
from
'
store/reducers/curriculum
'
;
// types
interface
Props
{
title
:
string
;
open
:
boolean
;
handleClose
:
(
status
:
boolean
)
=>
void
;
deleteId
:
number
|
string
|
undefined
;
deleteId
:
string
|
undefined
;
}
// ==============================|| Curriculum - DELETE ||============================== //
export
default
function
AlertCurriculumDelete
({
title
,
open
,
handleClose
,
deleteId
}:
Props
)
{
//
const dispatch = useDispatch();
const
dispatch
=
useDispatch
();
return
(
<
Dialog
...
...
@@ -41,6 +43,14 @@ export default function AlertCurriculumDelete({ title, open, handleClose, delete
<
Typography
variant=
"h4"
align=
"center"
>
Are you sure you want to delete?
</
Typography
>
<
Typography
align=
"center"
>
By deleting
<
Typography
variant=
"subtitle1"
component=
"span"
>
{
'
'
}
"
{
title
}
"
{
'
'
}
</
Typography
>
Curriculum, Its details
&
tasks will also be deleted.
</
Typography
>
</
Stack
>
<
Stack
direction=
"row"
spacing=
{
2
}
sx=
{
{
width
:
1
}
}
>
...
...
@@ -48,7 +58,7 @@ export default function AlertCurriculumDelete({ title, open, handleClose, delete
Cancel
</
Button
>
<
Button
fullWidth
color=
"error"
variant=
"contained"
onClick=
{
()
=>
{
// dispatch(deleteNutrition
(deleteId!))
dispatch
(
deleteCurriculum
(
deleteId
!
))
handleClose
(
true
)
}
}
autoFocus
>
Delete
...
...
Project/Frontend/SignConnectPlus/src/store/reducers/curriculum.ts
View file @
6d4db559
...
...
@@ -71,7 +71,7 @@ const slice = createSlice({
// DELETE CURRICULUM
deleteCurriculumSuccess
(
state
,
action
)
{
state
.
curriculums
=
state
.
curriculums
.
filter
(
curriculum
=>
curriculum
.
_id
!==
action
.
payload
.
_id
);
state
.
curriculums
=
state
.
curriculums
.
filter
(
curriculum
=>
curriculum
.
_id
!==
action
.
payload
);
state
.
success
=
"
Curriculum deleted successfully.
"
},
...
...
@@ -177,7 +177,7 @@ export function updateCurriculum(updatedCurriculum: Curriculum) {
* @param curriculumId
* @returns
*/
export
function
deleteCurriculum
(
curriculumId
:
number
)
{
export
function
deleteCurriculum
(
curriculumId
:
string
)
{
return
async
()
=>
{
dispatch
(
slice
.
actions
.
startLoading
());
...
...
Project/Frontend/SignConnectPlus/src/types/curriculum.ts
View file @
6d4db559
...
...
@@ -23,11 +23,11 @@ export type Curriculum = {
curriculumTitle
:
string
curriculumDescription
:
string
curriculumImage
:
string
curriculumMark
:
number
tutorials
:
tutorialType
[],
status
:
number
curriculumMark
?
:
number
tutorials
:
string
[],
status
?
:
number
createdBy
:
string
createdAt
:
Date
createdAt
?
:
Date
updatedBy
?:
string
updatedAt
?:
Date
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment