Commit 3a84115e authored by PDuarte's avatar PDuarte

basic layout menu

parent e319af13
// ** React Imports // ** React Imports
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { cleanLayoutMenu } from '../store/actions'
import { store } from '@store/storeConfig/store'
// ** Custom Components // ** Custom Components
import Avatar from '@components/avatar' import Avatar from '@components/avatar'
// module settings // module settings
...@@ -225,7 +228,7 @@ export const serverSideColumns = [ ...@@ -225,7 +228,7 @@ export const serverSideColumns = [
<Link <Link
to={`${moduleSettings.baseURL}/edit/${row.id}`} to={`${moduleSettings.baseURL}/edit/${row.id}`}
className='user-name text-truncate mb-0' className='user-name text-truncate mb-0'
// onClick={() => store.dispatch(cleanProject(row.id))} onClick={() => store.dispatch(cleanLayoutMenu(row.id))}
> >
<span className='font-weight-bold'>{row.name}</span> <span className='font-weight-bold'>{row.name}</span>
</Link> </Link>
......
...@@ -26,11 +26,11 @@ const Tables = () => { ...@@ -26,11 +26,11 @@ const Tables = () => {
</Row> </Row>
<Row> <Row>
<Col sm='12'> <Col sm='12'>
<div class="card"> <div className="card">
<div class="card-header"> <div className="card-header">
<h4 class="card-title">{moduleSettings.mainTitleSingle}</h4> <h4 className="card-title">{moduleSettings.mainTitleSingle}</h4>
</div> </div>
<div class="card-body"> <div className="card-body">
<ElementEdit /> <ElementEdit />
</div> </div>
</div> </div>
......
...@@ -15,7 +15,7 @@ import moduleSettings from '../module' ...@@ -15,7 +15,7 @@ import moduleSettings from '../module'
const ElementEdit = () => { const ElementEdit = () => {
// ** States & Vars // ** States & Vars
const store = useSelector(state => state.projectsettings), const store = useSelector(state => state.screens),
[dataElement, setElementData] = useState(null), [dataElement, setElementData] = useState(null),
dispatch = useDispatch(), dispatch = useDispatch(),
{ id } = useParams() { id } = useParams()
...@@ -39,15 +39,15 @@ const ElementEdit = () => { ...@@ -39,15 +39,15 @@ const ElementEdit = () => {
// ** Update user image on mount or change // ** Update user image on mount or change
useEffect(() => { useEffect(() => {
if (store.selectedElement !== null || (store.selectedElement !== null && dataElement !== null && store.selectedElement.id !== dataElement.id)) { if (store.selectedLayoutMenu !== null || (store.selectedLayoutMenu !== null && dataElement !== null && store.selectedLayoutMenu.id !== dataElement.id)) {
return setElementData(store.selectedElement) return setElementData(store.selectedLayoutMenu)
} }
}, [store.selectedElement]) }, [store.selectedLayoutMenu])
return store.selectedElement !== null && store.selectedElement !== undefined ? ( return store.selectedLayoutMenu !== null && store.selectedLayoutMenu !== undefined ? (
<ElementCard <ElementCard
selectedElement={store.selectedElement} selectedElement={store.selectedLayoutMenu}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
/> />
) : ( ) : (
......
...@@ -84,11 +84,20 @@ export const getData_layoutmenus = params => { ...@@ -84,11 +84,20 @@ export const getData_layoutmenus = params => {
.catch(err => console.log(err)) .catch(err => console.log(err))
} }
} }
export const cleanLayoutMenu = id => {
return async dispatch => {
dispatch({
type: 'GET_LAYOUTMENU',
data: null
})
}
}
export const updateLayoutMenu = layoumenu => { export const updateLayoutMenu = layoumenu => {
return (dispatch, getState) => { return (dispatch, getState) => {
axios axios
.put(`${process.env.REACT_APP_API}/api/layoumenus/${layoumenu.id}`, project) .put(`${process.env.REACT_APP_API}/api/layoutmenus/${layoumenu.id}`, layoumenu)
.then(response => { .then(response => {
dispatch({ dispatch({
type: 'UPDATE_LAYOUTMENU', type: 'UPDATE_LAYOUTMENU',
......
...@@ -57,7 +57,11 @@ const screens = (state = initialState, action) => { ...@@ -57,7 +57,11 @@ const screens = (state = initialState, action) => {
return { ...state, return { ...state,
selectedLayoutMenu : action.data selectedLayoutMenu : action.data
} }
case 'GET_LAYOUTMENU':
return { ...state,
selectedLayoutMenu : action.data
}
case 'UPDATE_LAYOUTMENU': case 'UPDATE_LAYOUTMENU':
return { ...state } return { ...state }
......
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