Commit 268d3528 authored by PDuarte's avatar PDuarte

asset project selector

parent 146025c8
...@@ -4,7 +4,7 @@ import { Link } from 'react-router-dom' ...@@ -4,7 +4,7 @@ import { Link } from 'react-router-dom'
// ** Store & Actions // ** Store & Actions
import { addasset } from '../../store/actions' import { addasset } from '../../store/actions'
import { useDispatch } from 'react-redux' import { useDispatch, useSelector } from 'react-redux'
// ** Custom Components // ** Custom Components
import Breadcrumbs from '@components/breadcrumbs' import Breadcrumbs from '@components/breadcrumbs'
...@@ -21,6 +21,7 @@ import '@styles/react/libs/tables/react-dataTable-component.scss' ...@@ -21,6 +21,7 @@ import '@styles/react/libs/tables/react-dataTable-component.scss'
const Tables = () => { const Tables = () => {
const dispatch = useDispatch() const dispatch = useDispatch()
const storeNavbar = useSelector(state => state.navbar)
const onSubmitHandler = (values, uploadFile) => { const onSubmitHandler = (values, uploadFile) => {
dispatch( dispatch(
addasset({ addasset({
...@@ -54,9 +55,11 @@ const Tables = () => { ...@@ -54,9 +55,11 @@ const Tables = () => {
<h4 className="card-title">New {moduleSettings.mainTitleSingle}</h4> <h4 className="card-title">New {moduleSettings.mainTitleSingle}</h4>
</div> </div>
<div className="card-body"> <div className="card-body">
<ElementCard selectedElement={{ {storeNavbar.projectCurrent === null ? <div>
Select Project
</div> : <ElementCard selectedElement={{
id: '<generate>', id: '<generate>',
projectid: '2', projectid: storeNavbar.projectCurrent.value,
title: '', title: '',
parentid: null, parentid: null,
parenttype: null, parenttype: null,
...@@ -69,6 +72,7 @@ const Tables = () => { ...@@ -69,6 +72,7 @@ const Tables = () => {
}} }}
onSubmitHandler={onSubmitHandler} onSubmitHandler={onSubmitHandler}
/> />
}
</div> </div>
</div> </div>
......
...@@ -13,6 +13,15 @@ const DataTable = () => { ...@@ -13,6 +13,15 @@ const DataTable = () => {
// ** Store Vars // ** Store Vars
const dispatch = useDispatch() const dispatch = useDispatch()
const store = useSelector(state => state.assets) const store = useSelector(state => state.assets)
const storeNavbar = useSelector(state => state.navbar)
useEffect(() => {
dispatch(getData_assets({
start: 0,
length: 1000
}))
}, [storeNavbar.projectCurrent])
return ( return (
<DataTableServerSide <DataTableServerSide
......
import { useSelector, useStore, ReactReduxContext } from 'react-redux'
import axios from 'axios' import axios from 'axios'
import {setSaveSatus, setErrorMsg} from '../../../../redux/actions/api' import {setSaveSatus, setErrorMsg} from '../../../../redux/actions/api'
import moduleSettings from '../../projectassets/module' import moduleSettings from '../../projectassets/module'
import {store} from '@store/storeConfig/store'
// ** Get table Data ///api/datatables/data // ** Get table Data ///api/datatables/data
const _getData_assets = params => { const _getData_assets = params => {
return async dispatch => { return async dispatch => {
...@@ -21,10 +22,13 @@ const _getData_assets = params => { ...@@ -21,10 +22,13 @@ const _getData_assets = params => {
}) })
} }
} }
export const getData_assets = params => { export const getData_assets = params => {
const currentProject = store.getState().navbar.projectCurrent
const newparams = { const newparams = {
...params, ...params,
idproject: 2 idproject: !currentProject ? '%' : currentProject.value
} }
return _getData_assets(newparams) return _getData_assets(newparams)
} }
......
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