Commit 9408fd5e authored by PDuarte's avatar PDuarte

delete pagesmenus and playlists UI

parent f7793f8a
...@@ -48,7 +48,7 @@ const SuccessProgressToast = () => ( ...@@ -48,7 +48,7 @@ const SuccessProgressToast = () => (
) )
const ElementCard = ({ selectedElement, onSubmitHandler }) => { const ElementCard = ({ selectedElement, onSubmitHandler, handelDelete }) => {
const store = useSelector(state => state.projectsettings) const store = useSelector(state => state.projectsettings)
const [PlatformName, setPlatformName] = useState('Web'), const [PlatformName, setPlatformName] = useState('Web'),
[projectPlaylists, setProjectPlaylists] = useState(null) [projectPlaylists, setProjectPlaylists] = useState(null)
...@@ -389,9 +389,11 @@ return ( ...@@ -389,9 +389,11 @@ return (
<Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'> <Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'>
Save Changes Save Changes
</Button.Ripple> </Button.Ripple>
{/* <Button.Ripple color='secondary' outline onClick={() => dispatch(getPlatform(selectedElement.id))} > { !!handelDelete &&
Reset <Button.Ripple style={{marginLeft: 'auto'}} color='danger' outline onClick={() => handelDelete()} >
</Button.Ripple> */} Delete
</Button.Ripple>
}
</Col> </Col>
</Row> </Row>
</Form> </Form>
......
...@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react' ...@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
import { useParams, Link } from 'react-router-dom' import { useParams, Link } from 'react-router-dom'
// ** Store & Actions // ** Store & Actions
import { getmenupages, updatemenupages } from '../../store/actions' import { getmenupages, updatemenupages, deletePage } from '../../store/actions'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
...@@ -38,6 +38,12 @@ const ElementEdit = () => { ...@@ -38,6 +38,12 @@ const ElementEdit = () => {
} }
const handelDelete = () => {
if (!confirm('Delete')) return
dispatch(
deletePage({ ...dataElement })
)
}
// ** Function to get user on mount // ** Function to get user on mount
useEffect(() => { useEffect(() => {
dispatch(getmenupages(id)) dispatch(getmenupages(id))
...@@ -56,6 +62,7 @@ const ElementEdit = () => { ...@@ -56,6 +62,7 @@ const ElementEdit = () => {
<ElementCard <ElementCard
selectedElement={store.selectedMenuPage} selectedElement={store.selectedMenuPage}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
handelDelete={handelDelete}
/> />
) : ( ) : (
<Alert color='info'> <Alert color='info'>
......
...@@ -107,4 +107,26 @@ export const getData_menupages = params => { ...@@ -107,4 +107,26 @@ export const getData_menupages = params => {
idproject: 2 idproject: 2
} }
return _getData_menupages(newparams) return _getData_menupages(newparams)
} }
\ No newline at end of file
export const deletePage = params => {
return (dispatch, getState) => {
axios
.delete(`${process.env.REACT_APP_API}${moduleSettings.apiBaseURL}/${params.id}`, params)
.then(response => {
dispatch({
type: 'GET_MENUPAGE',
data: null
})
})
.then(() => {
dispatch(setSaveSatus(true))
})
.catch(err => {
const errosMsg = !err.response ? 'error' : err.response.data.message
console.log(errosMsg)
dispatch(setErrorMsg(errosMsg))
})
}
}
\ No newline at end of file
...@@ -51,7 +51,7 @@ const SuccessProgressToast = () => ( ...@@ -51,7 +51,7 @@ const SuccessProgressToast = () => (
) )
const ElementCard = ({ selectedElement, onSubmitHandler }) => { const ElementCard = ({ selectedElement, onSubmitHandler, handelDelete }) => {
const store = useSelector(state => state.projectsettings) const store = useSelector(state => state.projectsettings)
const [PlatformName, setPlatformName] = useState('Web') const [PlatformName, setPlatformName] = useState('Web')
...@@ -311,9 +311,11 @@ return ( ...@@ -311,9 +311,11 @@ return (
<Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'> <Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'>
Save Changes Save Changes
</Button.Ripple> </Button.Ripple>
{/* <Button.Ripple color='secondary' outline onClick={() => dispatch(getPlatform(selectedElement.id))} > { !!handelDelete &&
Reset <Button.Ripple style={{marginLeft: 'auto'}} color='danger' outline onClick={() => handelDelete()} >
</Button.Ripple> */} Delete
</Button.Ripple>
}
</Col> </Col>
</Row> </Row>
</Form> </Form>
......
...@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react' ...@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
import { useParams, Link } from 'react-router-dom' import { useParams, Link } from 'react-router-dom'
// ** Store & Actions // ** Store & Actions
import { getplaylist, updateplaylist } from '../../store/actions' import { getplaylist, updateplaylist, deletePlaylist } from '../../store/actions'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
...@@ -37,6 +37,12 @@ const ElementEdit = () => { ...@@ -37,6 +37,12 @@ const ElementEdit = () => {
} }
const handelDelete = () => {
if (!confirm('Delete')) return
dispatch(
deletePlaylist({ ...dataElement })
)
}
// ** Function to get user on mount // ** Function to get user on mount
useEffect(() => { useEffect(() => {
dispatch(getplaylist(id)) dispatch(getplaylist(id))
...@@ -55,6 +61,7 @@ const ElementEdit = () => { ...@@ -55,6 +61,7 @@ const ElementEdit = () => {
<ElementCard <ElementCard
selectedElement={store.selectedPlaylist} selectedElement={store.selectedPlaylist}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
handelDelete={handelDelete}
/> />
) : ( ) : (
<Alert color='info'> <Alert color='info'>
......
...@@ -105,4 +105,26 @@ export const getData_playlists = params => { ...@@ -105,4 +105,26 @@ export const getData_playlists = params => {
dispatch(setErrorMsg(errosMsg)) dispatch(setErrorMsg(errosMsg))
}) })
} }
} }
\ No newline at end of file
export const deletePlaylist = params => {
return (dispatch, getState) => {
axios
.delete(`${process.env.REACT_APP_API}${moduleSettings.apiBaseURL}/${params.id}`, params)
.then(response => {
dispatch({
type: 'GET_PLAYLIST',
data: null
})
})
.then(() => {
dispatch(setSaveSatus(true))
})
.catch(err => {
const errosMsg = !err.response ? 'error' : err.response.data.message
console.log(errosMsg)
dispatch(setErrorMsg(errosMsg))
})
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment