Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
cms
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro-dev_2
cms
Commits
69f213a4
Commit
69f213a4
authored
Apr 24, 2021
by
PDuarte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show save result
parent
ac19ac50
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
12 deletions
+41
-12
projectCard.js
src/views/settings/projects/edit/projectCard.js
+21
-7
index.js
src/views/settings/store/actions/index.js
+13
-3
index.js
src/views/settings/store/reducer/index.js
+7
-2
No files found.
src/views/settings/projects/edit/projectCard.js
View file @
69f213a4
// ** React Imports
// ** React Imports
import
{
useState
,
useEffect
,
Fragment
}
from
'react'
import
{
useState
,
useEffect
,
Fragment
}
from
'react'
import
{
useDispatch
}
from
'react-redux'
import
{
use
Selector
,
use
Dispatch
}
from
'react-redux'
import
{
toast
}
from
'react-toastify'
import
{
toast
}
from
'react-toastify'
import
Avatar
from
'@components/avatar'
import
Avatar
from
'@components/avatar'
...
@@ -12,7 +12,7 @@ import { Bell, Check, X, AlertTriangle, Info } from 'react-feather'
...
@@ -12,7 +12,7 @@ import { Bell, Check, X, AlertTriangle, Info } from 'react-feather'
// ** Store & Actions
// ** Store & Actions
import
{
updateProject
}
from
'../../store/actions'
import
{
updateProject
,
resetResults
}
from
'../../store/actions'
import
{
useForm
}
from
'react-hook-form'
import
{
useForm
}
from
'react-hook-form'
import
classnames
from
'classnames'
import
classnames
from
'classnames'
...
@@ -28,7 +28,7 @@ const SuccessProgressToast = () => (
...
@@ -28,7 +28,7 @@ const SuccessProgressToast = () => (
<
div
className
=
'toastify-header'
>
<
div
className
=
'toastify-header'
>
<
div
className
=
'title-wrapper'
>
<
div
className
=
'title-wrapper'
>
<
Avatar
size
=
'sm'
color
=
'success'
icon
=
{
<
Check
size
=
{
12
}
/>} /
>
<
Avatar
size
=
'sm'
color
=
'success'
icon
=
{
<
Check
size
=
{
12
}
/>} /
>
<
h6
className
=
'toast-title'
>
Sav
ing
Project
!<
/h6
>
<
h6
className
=
'toast-title'
>
Sav
ed
!<
/h6
>
<
/div
>
<
/div
>
<
small
className
=
'text-muted'
><
/small
>
<
small
className
=
'text-muted'
><
/small
>
<
/div
>
<
/div
>
...
@@ -42,13 +42,15 @@ const SuccessProgressToast = () => (
...
@@ -42,13 +42,15 @@ const SuccessProgressToast = () => (
const
ProjectCard
=
({
selectedProject
})
=>
{
const
ProjectCard
=
({
selectedProject
})
=>
{
const
store
=
useSelector
(
state
=>
state
.
projectsettings
)
const
MySwal
=
withReactContent
(
Swal
)
const
MySwal
=
withReactContent
(
Swal
)
const
handleError
=
()
=>
{
const
handleError
=
(
text
)
=>
{
return
MySwal
.
fire
({
return
MySwal
.
fire
({
title
:
'Error!'
,
title
:
'Error!'
,
text
:
' You clicked the button!'
,
text
,
icon
:
'error'
,
icon
:
'error'
,
customClass
:
{
customClass
:
{
confirmButton
:
'btn btn-primary'
confirmButton
:
'btn btn-primary'
...
@@ -63,8 +65,6 @@ const handleError = () => {
...
@@ -63,8 +65,6 @@ const handleError = () => {
notifySuccessProgress
=
()
=>
toast
.
success
(
<
SuccessProgressToast
/>
),
notifySuccessProgress
=
()
=>
toast
.
success
(
<
SuccessProgressToast
/>
),
onSubmit
=
values
=>
{
onSubmit
=
values
=>
{
if
(
isObjEmpty
(
errors
))
{
if
(
isObjEmpty
(
errors
))
{
notifySuccessProgress
()
// handleError()
dispatch
(
dispatch
(
updateProject
({
updateProject
({
id
:
values
.
id
,
id
:
values
.
id
,
...
@@ -82,6 +82,20 @@ const handleError = () => {
...
@@ -82,6 +82,20 @@ const handleError = () => {
}
}
},
[
selectedProject
])
},
[
selectedProject
])
useEffect
(()
=>
{
if
(
store
.
errorMsg
!==
''
)
{
handleError
(
store
.
errorMsg
)
dispatch
(
resetResults
())
}
},
[
store
.
errorMsg
])
useEffect
(()
=>
{
if
(
store
.
saveSucces
)
{
notifySuccessProgress
()
dispatch
(
resetResults
())
}
},
[
store
.
saveSucces
])
return
(
return
(
<
Fragment
>
<
Fragment
>
...
...
src/views/settings/store/actions/index.js
View file @
69f213a4
...
@@ -80,6 +80,16 @@ export const cleanProject = id => {
...
@@ -80,6 +80,16 @@ export const cleanProject = id => {
}
}
}
}
export
const
resetResults
=
id
=>
{
return
async
dispatch
=>
{
dispatch
({
type
:
'RESET_RESULTS'
,
saveSucces
:
false
,
errorMsg
:
''
})
}
}
// ** Add new project
// ** Add new project
export
const
updateProject
=
project
=>
{
export
const
updateProject
=
project
=>
{
return
(
dispatch
,
getState
)
=>
{
return
(
dispatch
,
getState
)
=>
{
...
@@ -97,14 +107,14 @@ export const updateProject = project => {
...
@@ -97,14 +107,14 @@ export const updateProject = project => {
// dispatch(getData_projects())
// dispatch(getData_projects())
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
dispatch
(
setErrorMsg
(
'error'
))
dispatch
(
setErrorMsg
(
err
.
response
.
data
.
message
))
console
.
log
(
err
)
console
.
log
(
err
.
response
.
data
)
})
})
}
}
}
}
// ** Get table Data
///api/datatables/data
// ** Get table Data
platforms
export
const
getData_platforms
=
params
=>
{
export
const
getData_platforms
=
params
=>
{
return
async
dispatch
=>
{
return
async
dispatch
=>
{
await
axios
.
get
(
`
${
process
.
env
.
REACT_APP_API
}
/api/platforms`
,
params
await
axios
.
get
(
`
${
process
.
env
.
REACT_APP_API
}
/api/platforms`
,
params
...
...
src/views/settings/store/reducer/index.js
View file @
69f213a4
...
@@ -41,7 +41,12 @@ const settings = (state = initialState, action) => {
...
@@ -41,7 +41,12 @@ const settings = (state = initialState, action) => {
...
state
,
...
state
,
errorMsg
:
action
.
errorMsg
errorMsg
:
action
.
errorMsg
}
}
case
'RESET_RESULTS'
:
return
{
...
state
,
saveSucces
:
false
,
errorMsg
:
''
}
case
'GET_DATA_PROJECTS'
:
case
'GET_DATA_PROJECTS'
:
...
...
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