Commit 718a02d9 authored by PDuarte's avatar PDuarte

refactory platforms

parent 74ec76a5
...@@ -16,9 +16,9 @@ import Moment from 'moment' ...@@ -16,9 +16,9 @@ import Moment from 'moment'
const PlanAvaliability = ({dataElement, handleElmChange}) => { const PlanAvaliability = ({dataElement, handleElmChange}) => {
const [pickerstartdate, setPickerstartdate] = useState(Date.parse(dataElement.startdate)), const [pickerstartdate, setPickerstartdate] = useState(Date.parse(dataElement.startdate)),
[pickerenddate, setPickerenddate] = useState(Date.parse(dataElement.enddate)), [pickerenddate, setPickerenddate] = useState(Date.parse(dataElement.enddate)),
[plataforms, setPlatforms] = useState([]), [platforms, setPlatforms] = useState([]),
[geolocations, setGeolocations] = useState([]), [geolocations, setGeolocations] = useState([]),
[avaliaPlataforms, setAvaliaPlatforms] = useState([]), [avaliaPlatforms, setAvaliaPlatforms] = useState([]),
[permitGeo, setPermitGeo] = useState([]), [permitGeo, setPermitGeo] = useState([]),
[denytGeo, setDenyGeo] = useState([]), [denytGeo, setDenyGeo] = useState([]),
store = useSelector(state => state.projectsettings) store = useSelector(state => state.projectsettings)
...@@ -45,7 +45,7 @@ const PlanAvaliability = ({dataElement, handleElmChange}) => { ...@@ -45,7 +45,7 @@ const PlanAvaliability = ({dataElement, handleElmChange}) => {
useEffect(() => { useEffect(() => {
if (!dataElement) return if (!dataElement) return
const selected = dataElement.plataforms.map(elm => { const selected = dataElement.platforms.map(elm => {
return { return {
value: elm.id, value: elm.id,
label: elm.name label: elm.name
...@@ -83,7 +83,7 @@ const PlanAvaliability = ({dataElement, handleElmChange}) => { ...@@ -83,7 +83,7 @@ const PlanAvaliability = ({dataElement, handleElmChange}) => {
}) })
const newData = { const newData = {
...dataElement, ...dataElement,
plataforms: newValue platforms: newValue
} }
handleElmChange(newData) handleElmChange(newData)
}, },
...@@ -207,14 +207,14 @@ const PlanAvaliability = ({dataElement, handleElmChange}) => { ...@@ -207,14 +207,14 @@ const PlanAvaliability = ({dataElement, handleElmChange}) => {
</FormGroup> </FormGroup>
</Col> </Col>
<Col md='8' sm='12'> <Col md='8' sm='12'>
<Label for='plataforms'>Platforms</Label> <Label for='platforms'>Platforms</Label>
<Select <Select
isClearable={false} isClearable={false}
theme={selectThemeColors} theme={selectThemeColors}
value={avaliaPlataforms} value={avaliaPlatforms}
isMulti isMulti
name={`platforms${dataElement.id}`} name={`platforms${dataElement.id}`}
options={plataforms} options={platforms}
onChange={platfomsOnChange} onChange={platfomsOnChange}
className='react-select' className='react-select'
classNamePrefix='select' classNamePrefix='select'
...@@ -281,7 +281,7 @@ const AvaliabilityBlock = ({dataElement, handleElmChange}) => { ...@@ -281,7 +281,7 @@ const AvaliabilityBlock = ({dataElement, handleElmChange}) => {
const handleAvalChange = (value) => { const handleAvalChange = (value) => {
const newData = dataElement.map(elm => { const newData = dataElement.map(elm => {
if (elm.id === value.id) { if (elm.id === value.id) {
elm.plataforms = value.plataforms elm.platforms = value.platforms
elm.geolocations = value.geolocations elm.geolocations = value.geolocations
elm.startdate = value.startdate elm.startdate = value.startdate
elm.enddate = value.enddate elm.enddate = value.enddate
...@@ -299,7 +299,7 @@ const AvaliabilityBlock = ({dataElement, handleElmChange}) => { ...@@ -299,7 +299,7 @@ const AvaliabilityBlock = ({dataElement, handleElmChange}) => {
idassets: 'current', idassets: 'current',
startdate: '', startdate: '',
enddate: '', enddate: '',
plataforms: [], platforms: [],
geolocations: [] geolocations: []
}) })
handleElmChange(newData) handleElmChange(newData)
......
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