Commit 9370584b authored by PDuarte's avatar PDuarte

storing poject current

parent 7cd6a131
...@@ -5,6 +5,9 @@ import UserDropdown from './UserDropdown' ...@@ -5,6 +5,9 @@ import UserDropdown from './UserDropdown'
import NavbarSearch from './NavbarSearch' import NavbarSearch from './NavbarSearch'
import NotificationDropdown from './NotificationDropdown' import NotificationDropdown from './NotificationDropdown'
import SelectProject from './SelectProject'
// ** Third Party Components // ** Third Party Components
import { Sun, Moon } from 'react-feather' import { Sun, Moon } from 'react-feather'
import { NavItem, NavLink } from 'reactstrap' import { NavItem, NavLink } from 'reactstrap'
...@@ -25,11 +28,18 @@ const NavbarUser = props => { ...@@ -25,11 +28,18 @@ const NavbarUser = props => {
return ( return (
<ul className='nav navbar-nav align-items-center ml-auto'> <ul className='nav navbar-nav align-items-center ml-auto'>
{/* <IntlDropdown /> */} {/* <IntlDropdown /> */}
<NavItem className='d-none d-lg-block'>
<NavLink className='nav-link-style'>
<SelectProject />
</NavLink>
</NavItem>
<NavItem className='d-none d-lg-block'> <NavItem className='d-none d-lg-block'>
<NavLink className='nav-link-style'> <NavLink className='nav-link-style'>
<ThemeToggler /> <ThemeToggler />
</NavLink> </NavLink>
</NavItem> </NavItem>
{/* <NavbarSearch /> */} {/* <NavbarSearch /> */}
{/* <CartDropdown /> */} {/* <CartDropdown /> */}
{/* <NotificationDropdown /> */} {/* <NotificationDropdown /> */}
......
import { useState, useEffect, Fragment } from 'react'
import AsyncSelect from 'react-select/async'
import { useSelector, useDispatch } from 'react-redux'
import { selectThemeColors } from '@utils'
import { getData_projects } from '@src/views/settings/store/actions'
import { handleProjectSelected } from '@store/actions/navbar'
//
const SelectProject = props => {
const dispatch = useDispatch()
const store = useSelector(state => state.projectsettings)
const [dataProject, setProjectData] = useState([])
const filterProjects = inputValue => {
return dataProject.filter(i => i.label.toLowerCase().includes(inputValue.toLowerCase()))
}
const loadOptions = (inputValue, callback) => {
setTimeout(() => {
callback(filterProjects(inputValue))
}, 2000)
}
const handleInputChange = newValue => {
const val = newValue.replace(/\W/g, '')
return val
}
const handleChange = value => {
console.log(value)
dispatch(handleProjectSelected(value))
}
useEffect(() => {
if (!store.allDataProjects || store.allDataProjects.length < 1) {
dispatch(getData_projects({
start: 0,
length: 1000,
q: null
}))
}
}, [dispatch])
useEffect(() => {
if (store.allDataProjects !== null) {
const proj = store.allDataProjects.map(elm => {
return {
value: elm.id,
label: elm.app_name
}
})
setProjectData(proj)
console.log(proj)
}
}, [store.allDataProjects])
return <Fragment>
{ dataProject.length > 0 ? <AsyncSelect
isClearable={false}
className='react-select'
classNamePrefix='select'
name='callback-react-select'
loadOptions={loadOptions}
defaultOptions
onInputChange={handleInputChange}
onChange={handleChange}
theme={selectThemeColors}
/> : <div>Loading...</div> }
</Fragment>
}
export default SelectProject
\ No newline at end of file
...@@ -24,3 +24,4 @@ export const updateBookmarked = id => { ...@@ -24,3 +24,4 @@ export const updateBookmarked = id => {
// ** Handle Bookmarks & Main Search Queries // ** Handle Bookmarks & Main Search Queries
export const handleSearchQuery = val => dispatch => dispatch({ type: 'HANDLE_SEARCH_QUERY', val }) export const handleSearchQuery = val => dispatch => dispatch({ type: 'HANDLE_SEARCH_QUERY', val })
export const handleProjectSelected = val => dispatch => dispatch({ type: 'HANDLE_PROJECT_SELECTED', val })
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
const initialState = { const initialState = {
suggestions: [], suggestions: [],
bookmarks: [], bookmarks: [],
query: '' query: '',
projectCurrent: null
} }
const navbarReducer = (state = initialState, action) => { const navbarReducer = (state = initialState, action) => {
switch (action.type) { switch (action.type) {
case 'HANDLE_SEARCH_QUERY': case 'HANDLE_SEARCH_QUERY':
return { ...state, query: action.val } return { ...state, query: action.val }
case 'HANDLE_PROJECT_SELECTED':
return { ...state, projectCurrent: action.val }
case 'GET_BOOKMARKS': case 'GET_BOOKMARKS':
return { ...state, suggestions: action.data, bookmarks: action.bookmarks } return { ...state, suggestions: action.data, bookmarks: action.bookmarks }
case 'UPDATE_BOOKMARKED': case 'UPDATE_BOOKMARKED':
......
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