Commit 23ae754a authored by PDuarte's avatar PDuarte

delete asset UI

parent 8f7f09f7
...@@ -52,7 +52,7 @@ const SuccessProgressToast = () => ( ...@@ -52,7 +52,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')
...@@ -471,9 +471,11 @@ return ( ...@@ -471,9 +471,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 { getasset, updateasset } from '../../store/actions' import { getasset, updateasset, deleteasset } from '../../store/actions'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
...@@ -41,6 +41,12 @@ const ElementEdit = () => { ...@@ -41,6 +41,12 @@ const ElementEdit = () => {
} }
const handelDelete = () => {
if (!confirm('Delete')) return
dispatch(
deleteasset({ ...dataElement })
)
}
// ** Function to get user on mount // ** Function to get user on mount
useEffect(() => { useEffect(() => {
dispatch(getasset(id)) dispatch(getasset(id))
...@@ -59,6 +65,7 @@ const ElementEdit = () => { ...@@ -59,6 +65,7 @@ const ElementEdit = () => {
<ElementCard <ElementCard
selectedElement={store.selectedAsset} selectedElement={store.selectedAsset}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
handelDelete={handelDelete}
/> />
) : ( ) : (
<Alert color='info'> <Alert color='info'>
......
...@@ -82,6 +82,27 @@ export const getData_assets = params => { ...@@ -82,6 +82,27 @@ export const getData_assets = params => {
} }
} }
export const deleteasset = params => {
return (dispatch, getState) => {
axios
.delete(`${process.env.REACT_APP_API}${moduleSettings.apiBaseURL}/${params.id}`, params)
.then(response => {
dispatch({
type: 'GET_ASSET',
data: null
})
})
.then(() => {
dispatch(setSaveSatus(true))
})
.catch(err => {
const errosMsg = !err.response ? 'error' : err.response.data.message
console.log(errosMsg)
dispatch(setErrorMsg(errosMsg))
})
}
}
export const updateasset = params => { export const updateasset = params => {
return (dispatch, getState) => { return (dispatch, getState) => {
axios axios
......
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