Commit 23ae754a authored by PDuarte's avatar PDuarte

delete asset UI

parent 8f7f09f7
......@@ -52,7 +52,7 @@ const SuccessProgressToast = () => (
)
const ElementCard = ({ selectedElement, onSubmitHandler }) => {
const ElementCard = ({ selectedElement, onSubmitHandler, handelDelete }) => {
const store = useSelector(state => state.projectsettings)
const [PlatformName, setPlatformName] = useState('Web')
......@@ -471,9 +471,11 @@ return (
<Button.Ripple className='mb-1 mb-sm-0 mr-0 mr-sm-1' type='submit' color='primary'>
Save Changes
</Button.Ripple>
{/* <Button.Ripple color='secondary' outline onClick={() => dispatch(getPlatform(selectedElement.id))} >
Reset
</Button.Ripple> */}
{ !!handelDelete &&
<Button.Ripple style={{marginLeft: 'auto'}} color='danger' outline onClick={() => handelDelete()} >
Delete
</Button.Ripple>
}
</Col>
</Row>
</Form>
......
......@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
import { useParams, Link } from 'react-router-dom'
// ** Store & Actions
import { getasset, updateasset } from '../../store/actions'
import { getasset, updateasset, deleteasset } from '../../store/actions'
import { useSelector, useDispatch } from 'react-redux'
......@@ -41,6 +41,12 @@ const ElementEdit = () => {
}
const handelDelete = () => {
if (!confirm('Delete')) return
dispatch(
deleteasset({ ...dataElement })
)
}
// ** Function to get user on mount
useEffect(() => {
dispatch(getasset(id))
......@@ -58,7 +64,8 @@ const ElementEdit = () => {
return store.selectedAsset !== null && store.selectedAsset !== undefined ? (
<ElementCard
selectedElement={store.selectedAsset}
onSubmitHandler={onSubmitHandler}
onSubmitHandler={onSubmitHandler}
handelDelete={handelDelete}
/>
) : (
<Alert color='info'>
......
......@@ -81,6 +81,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 => {
return (dispatch, getState) => {
......
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