Commit 6c0e4a98 authored by PDuarte's avatar PDuarte

project - languages based UI

parent 1e9f9147
...@@ -5,7 +5,7 @@ import { useSelector, useDispatch } from 'react-redux' ...@@ -5,7 +5,7 @@ import { useSelector, useDispatch } from 'react-redux'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import Avatar from '@components/avatar' import Avatar from '@components/avatar'
import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, CardHeader, CardTitle, CardText } from 'reactstrap' import {Spinner, Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, CardHeader, CardTitle, CardText } from 'reactstrap'
import { isObjEmpty } from '@utils' import { isObjEmpty } from '@utils'
...@@ -236,6 +236,7 @@ return ( ...@@ -236,6 +236,7 @@ return (
value={option.id}>{option.name}</option> value={option.id}>{option.name}</option>
}) : <option>Loading</option> } }) : <option>Loading</option> }
</Input> </Input>
</FormGroup> </FormGroup>
</Col> </Col>
<Col md='4' sm='12'> <Col md='4' sm='12'>
......
...@@ -24,11 +24,11 @@ const Tables = () => { ...@@ -24,11 +24,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">Project</h4> <h4 className="card-title">Project</h4>
</div> </div>
<div class="card-body"> <div className="card-body">
<ProjectsEdit /> <ProjectsEdit />
</div> </div>
</div> </div>
......
...@@ -57,7 +57,7 @@ const ProjectPlatform = ({dataElement, setElement, store}) => { ...@@ -57,7 +57,7 @@ const ProjectPlatform = ({dataElement, setElement, store}) => {
} }
return !!dataElement ? ( return !!dataElement ? (
<div clssName='permissions border mt-1'> <div className='permissions border mt-1'>
<h6 className='py-1 mx-1 mb-0 font-medium-2'> <h6 className='py-1 mx-1 mb-0 font-medium-2'>
<Lock size={18} className='mr-25' /> <Lock size={18} className='mr-25' />
<span className='align-middle'>Platforms</span> <span className='align-middle'>Platforms</span>
......
...@@ -4,11 +4,13 @@ import { useSelector, useDispatch } from 'react-redux' ...@@ -4,11 +4,13 @@ import { useSelector, useDispatch } from 'react-redux'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import Avatar from '@components/avatar' import Avatar from '@components/avatar'
import Select, { components } from 'react-select'
import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, CardHeader, CardTitle, CardText } from 'reactstrap' import {Media, Button, Label, Form, FormGroup, Input, Table, CustomInput, Card, CardBody, Row, Col, Nav, NavItem, NavLink, TabContent, TabPane, Alert, CardHeader, CardTitle, CardText } from 'reactstrap'
import { isObjEmpty } from '@utils' import { isObjEmpty, selectThemeColors } from '@utils'
import { Bell, Check, X, AlertTriangle, Info } from 'react-feather' import { Bell, Check, X, AlertTriangle, Info, Flag } from 'react-feather'
// ** Store & Actions // ** Store & Actions
...@@ -60,6 +62,7 @@ const handleError = (text) => { ...@@ -60,6 +62,7 @@ const handleError = (text) => {
} }
const [dataProject, setProjectData] = useState(null), const [dataProject, setProjectData] = useState(null),
[projectLang, setProjectLang] = useState(null),
{ register, errors, handleSubmit } = useForm(), { register, errors, handleSubmit } = useForm(),
dispatch = useDispatch(), dispatch = useDispatch(),
notifySuccessProgress = () => toast.success(<SuccessProgressToast />), notifySuccessProgress = () => toast.success(<SuccessProgressToast />),
...@@ -80,10 +83,41 @@ const handleError = (text) => { ...@@ -80,10 +83,41 @@ const handleError = (text) => {
onSubmitHandler(submitProject) onSubmitHandler(submitProject)
} }
} }
const langOptions = [
{ value: 'English', label: 'English'},
{ value: 'Spanish', label: 'Spanish'},
{ value: 'German', label: 'German'}
]
const langOnChange = (value, { action, removedValue }) => {
switch (action) {
case 'remove-value':
case 'pop-value':
if (removedValue.isFixed) {
return
}
setProjectLang(value)
break
case 'clear':
value = langOptions.filter(v => v.isFixed)
setProjectLang(value)
break
default:
setProjectLang(value)
break
}
}
useEffect(() => { useEffect(() => {
if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) { if (selectedProject !== null || (selectedProject !== null && dataProject !== null && selectedProject.id !== dataProject.id)) {
const langActive = langOptions.filter(lang => {
return selectedProject.languages.filter(elm => {
return elm.name === lang.value
}).length > 0
})
console.log(langActive)
setProjectLang(langActive)
return setProjectData(selectedProject) return setProjectData(selectedProject)
} }
}, [selectedProject]) }, [selectedProject])
...@@ -102,7 +136,6 @@ const handleError = (text) => { ...@@ -102,7 +136,6 @@ const handleError = (text) => {
} }
}, [store.saveSucces]) }, [store.saveSucces])
return ( return (
<Fragment> <Fragment>
<Form <Form
...@@ -168,6 +201,26 @@ return ( ...@@ -168,6 +201,26 @@ return (
</FormGroup> </FormGroup>
</Col> */} </Col> */}
<Col sm='12'>
</Col>
<Col className='mb-1' md='12' sm='12'>
<h6 className="py-1 mx-1 mb-0 font-medium-2"><Flag /> Languages</h6>
<Select
isClearable={false}
theme={selectThemeColors}
value={projectLang}
isMulti
name='languages'
options={langOptions}
onChange={langOnChange}
className='react-select'
classNamePrefix='select'
/>
</Col>
<Col sm='12'>
</Col>
<Col sm='12'> <Col sm='12'>
<ProjectPlatform dataElement={dataProject} setElement={setProjectData} store={store} /> <ProjectPlatform dataElement={dataProject} setElement={setProjectData} store={store} />
</Col> </Col>
......
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