Commit c9fe93a7 authored by Mattias Lundmark's avatar Mattias Lundmark
Browse files

Timber: DEICH-1785 First name in header instead of My Page

parent d30790c0
......@@ -56,10 +56,12 @@ module.exports = (app) => {
})
.then(json => {
const borrowerName = request.session.borrowerName = `${json.firstname ? json.firstname : ""}${json.firstname && json.surname ? " " : ""}${json.surname ? json.surname : ""}`
request.session.firstName = `${json.firstname ? json.firstname : ""}`
response.send({
isLoggedIn: true,
borrowerNumber: request.session.borrowerNumber,
borrowerName: borrowerName,
firstName: request.session.firstName,
homeBranch: request.session.homeBranch,
category: request.session.category
})
......@@ -79,6 +81,7 @@ module.exports = (app) => {
isLoggedIn: request.session.borrowerNumber !== undefined,
borrowerNumber: request.session.borrowerNumber,
borrowerName: request.session.borrowerName,
firstName: request.session.firstName,
homeBranch: request.session.homeBranch,
category: request.session.category
})
......
......@@ -441,6 +441,7 @@ module.exports = (app) => {
cardNumber: patron.cardnumber || "",
homeBranch: patron.branchcode || "",
name: `${patron.firstname} ${patron.surname}`,
firstName: patron.firstname || "",
address: patron.address || "",
zipcode: patron.zipcode || "",
city: patron.city || "",
......
......@@ -20,10 +20,11 @@ export function captchaSuccess (response) {
}
}
export const loginSuccess = (username, borrowerNumber, borrowerName, category) => action(types.LOGIN_SUCCESS, {
export const loginSuccess = (username, borrowerNumber, borrowerName, firstName, category) => action(types.LOGIN_SUCCESS, {
username,
borrowerNumber,
borrowerName,
firstName,
category
})
......@@ -74,7 +75,7 @@ export function login (username, password, captchaResponse, successActions = [])
}
})
.then(json => {
dispatch(loginSuccess(username, json.borrowerNumber, json.borrowerName, json.category))
dispatch(loginSuccess(username, json.borrowerNumber, json.borrowerName, json.firstName, json.category))
dispatch(fetchFavourites())
return dispatch(fetchProfileInfo())
})
......@@ -114,10 +115,11 @@ export function logout () {
export const requestLoginStatus = () => action(types.REQUEST_LOGIN_STATUS)
export const receiveLoginStatus = (isLoggedIn, borrowerNumber, borrowerName, homeBranch, category) => action(types.RECEIVE_LOGIN_STATUS, {
export const receiveLoginStatus = (isLoggedIn, borrowerNumber, borrowerName, firstName, homeBranch, category) => action(types.RECEIVE_LOGIN_STATUS, {
isLoggedIn,
borrowerNumber,
borrowerName,
firstName,
homeBranch,
category
})
......@@ -137,7 +139,7 @@ export function updateLoginStatus () {
credentials: "same-origin"
}).then(response => response.json())
.then(json => {
dispatch(receiveLoginStatus(json.isLoggedIn, json.borrowerNumber, json.borrowerName, json.homeBranch, json.category))
dispatch(receiveLoginStatus(json.isLoggedIn, json.borrowerNumber, json.borrowerName, json.firstName, json.homeBranch, json.category))
if (json.isLoggedIn) {
dispatch(fetchFavourites())
}
......@@ -163,7 +165,7 @@ export function updateLoginStatusBeforeAction (successAction) {
credentials: "same-origin"
}).then(response => response.json())
.then(json => {
dispatch(receiveLoginStatus(json.isLoggedIn, json.borrowerNumber, json.borrowerName, json.homeBranch, json.category))
dispatch(receiveLoginStatus(json.isLoggedIn, json.borrowerNumber, json.borrowerName, json.firstName, json.homeBranch, json.category))
dispatch(successAction)
})
.catch(error => dispatch(loginStatusFailure(error)))
......
......@@ -106,12 +106,17 @@ class SearchHeader extends React.Component {
profileLink () {
if (this.props.isLoggedIn) {
const { firstName, borrowerName } = this.props
return [
<li key={3} >
<MediaQuery query="(min-width: 1100px)" values={{ ...this.props.mediaQueryValues }} >
<img className="icon" src="/images/profile24.svg" />
</MediaQuery>
<Link to="/profile/loans" ><FormattedMessage {...messages.myProfile} /></Link >
{firstName ? (
<Link to="/profile/loans" >{firstName}</Link >
) : (
<Link to="/profile/loans" >{borrowerName}</Link >
)}
</li >
]
}
......@@ -128,15 +133,6 @@ class SearchHeader extends React.Component {
}
}
loggedInMessage () {
const { borrowerName } = this.props
return (
<span >
<FormattedMessage {...messages.loggedInAs} /> <strong ><span>{borrowerName}</span ></strong >
</span >
)
}
/**
* Renders the menu, and/or the mobile menu
*/
......@@ -146,13 +142,6 @@ class SearchHeader extends React.Component {
{this.getInspiredLink()}
{this.profileLink()}
{this.registrationLink()}
{ /* borrowerName
? (
<MediaQuery query="(min-width: 992px)" values={{ ...this.props.mediaQueryValues }} >
<li >{this.loggedInMessage()}</li >
</MediaQuery >
)
: null */}
{this.loginLink()}
{this.logoutLink()}
</ul >
......@@ -204,6 +193,7 @@ class SearchHeader extends React.Component {
render () {
const mobileNavClass = this.props.showMobileNavigation ? "primary-mobile-menu" : "primary-mobile-menu collapsed"
return (
<div >
<NonIETransitionGroup
......@@ -249,14 +239,6 @@ class SearchHeader extends React.Component {
</nav >
</MediaQuery >
{ /* borrowerName
? (<MediaQuery query="(max-width: 991px)" values={{ ...this.props.mediaQueryValues }} >
<div className="logged-in-message" >
{this.loggedInMessage()}
</div >
</MediaQuery >)
: null */ }
</NonIETransitionGroup >
<MediaQuery query="(max-width: 1099px)" values={{ ...this.props.mediaQueryValues }} >
......
......@@ -87,6 +87,7 @@ class App extends React.Component {
mobileNavigationActions={this.props.mobileNavigationActions}
profileActions={this.props.profileActions}
borrowerName={this.props.borrowerName}
firstName={this.props.firstName}
searchActions={this.props.searchActions}
isSearching={this.props.isSearching}
/>
......@@ -121,6 +122,7 @@ App.propTypes = {
showMobileNavigation: PropTypes.bool.isRequired,
windowActions: PropTypes.object.isRequired,
borrowerName: PropTypes.string,
firstName: PropTypes.string,
searchActions: PropTypes.object.isRequired,
isSearching: PropTypes.bool.isRequired
}
......@@ -131,6 +133,7 @@ function mapStateToProps (state) {
isLoggedIn: state.application.isLoggedIn,
showMobileNavigation: state.mobileNavigation.visible,
borrowerName: state.profile.borrowerName,
firstName: state.profile.firstName,
isSearching: state.search.isSearching
}
}
......
......@@ -40,6 +40,7 @@ import {
const initialState = {
borrowerName: null,
firstName: null,
category: null,
isRequestingLoansAndReservations: false,
loansAndReservationsError: null,
......@@ -132,7 +133,7 @@ export default function profile (state = initialState, action) {
case CHANGE_PASSWORD_FAILURE:
return { ...state, changePasswordError: action.payload, isRequestingChangePassword: false, changePasswordSuccess: false }
case LOGIN_SUCCESS:
return { ...initialState, borrowerName: action.payload.borrowerName, category: action.payload.category }
return { ...initialState, borrowerName: action.payload.borrowerName, firstName: action.payload.firstName, category: action.payload.category }
case LOGOUT_SUCCESS:
return initialState
case SHOW_LOGIN_DIALOG:
......@@ -192,7 +193,7 @@ export default function profile (state = initialState, action) {
}
}
case RECEIVE_LOGIN_STATUS:
return { ...state, borrowerName: action.payload.borrowerName, homeBranch: action.payload.homeBranch, category: action.payload.category }
return { ...state, borrowerName: action.payload.borrowerName, firstName: action.payload.firstName, homeBranch: action.payload.homeBranch, category: action.payload.category }
case REQUEST_RESET_PIN:
return { ...state, isRequestingResetPIN: true, passwordRecoveryFailure: null, passwordRecoverySuccess: false, passwordRecoveryInfo: null, validateResetUuidSuccess: false, changePasswordSuccess: false }
case REQUEST_RESET_PIN_SUCCESS:
......
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