1
- import React from 'react'
1
+ import React , { useState } from 'react'
2
2
import { useNavigate , useLocation } from 'react-router-dom'
3
3
import { connect } from 'react-redux'
4
4
import { Tooltip } from 'antd'
@@ -9,15 +9,18 @@ import logoWideLight from '../../assets/logo-wide-light.png'
9
9
import PageHeader from './PageHeader/PageHeader'
10
10
import AuthAvatar from './AuthAvatar/AuthAvatar'
11
11
import MainMenu from './MainMenu/MainMenu'
12
+ import AccountSettingsModal from './AccountSettingsModal/AccountSettingsModal'
12
13
13
- import { openAuthModal } from '../../store/actions'
14
+ import { getAccountSettings , openAuthModal , saveUserSettings } from '../../store/actions'
14
15
15
16
import classes from './NavBar.module.css'
16
17
17
18
const NavBar = props => {
18
19
const location = useLocation ( )
19
20
const navigate = useNavigate ( )
20
21
22
+ const [ modalVisible , setModalVisible ] = useState ( false )
23
+
21
24
// Setting up components for left side of NavBar. Components dynamically change with state of admin sider menu.
22
25
const toggleButton = props . collapsed ? < MenuUnfoldOutlined /> : < MenuFoldOutlined />
23
26
const navLeft =
@@ -65,9 +68,18 @@ const NavBar = props => {
65
68
username = { props . username }
66
69
accessLevel = { props . accessLevel }
67
70
toggleAddSample = { props . tglAddSample }
71
+ setModalVisible = { setModalVisible }
68
72
/>
69
73
</ div >
70
74
</ div >
75
+ < AccountSettingsModal
76
+ modalVisible = { modalVisible }
77
+ setModalVisible = { setModalVisible }
78
+ authToken = { props . authToken }
79
+ fetchUserData = { props . getUserSettings }
80
+ userSettings = { props . userAccountSettings }
81
+ onSave = { props . saveUserSettings }
82
+ />
71
83
</ nav >
72
84
)
73
85
}
@@ -76,13 +88,17 @@ const mapStateToProps = state => {
76
88
return {
77
89
username : state . auth . username ,
78
90
accessLevel : state . auth . accessLevel ,
79
- manualAccess : state . auth . manualAccess
91
+ manualAccess : state . auth . manualAccess ,
92
+ authToken : state . auth . token ,
93
+ userAccountSettings : state . userAccount . settings
80
94
}
81
95
}
82
96
83
97
const mapDispatchToProps = dispatch => {
84
98
return {
85
- openModalHandler : ( ) => dispatch ( openAuthModal ( ) )
99
+ openModalHandler : ( ) => dispatch ( openAuthModal ( ) ) ,
100
+ getUserSettings : token => dispatch ( getAccountSettings ( token ) ) ,
101
+ saveUserSettings : ( token , data ) => dispatch ( saveUserSettings ( token , data ) )
86
102
}
87
103
}
88
104
0 commit comments