Default Value added to first Input on the form
This commit is contained in:
1 parent
97a99aae6e
commit
1d0a4b82ec
4 files changed
+59
-26
No files matched your search
@@ -102,7 +102,7 @@ class Auth {
|
||||
this.signinOrCreateAccount({ ...data })
|
||||
this.cb(data)
|
||||
console.log(authResult.idTokenPayload)
|
||||
setItem('auth.user', JSON.stringify(authResult.idTokenPayload))
|
||||
setItem('authUser', JSON.stringify(authResult.idTokenPayload))
|
||||
if (window.location.href.includes(`callback`)) {
|
||||
window.location.href = '/'
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class Auth {
|
||||
})
|
||||
|
||||
console.log('signinOrCreateAccount auth: ', await data)
|
||||
setItem('auth.user', JSON.stringify(data.data.authenticate))
|
||||
setItem('authUser', JSON.stringify(data.data.authenticate))
|
||||
if (window.location.href.includes(`callback`)) {
|
||||
window.location.href = '/'
|
||||
} else {
|
||||
@@ -143,7 +143,7 @@ class Auth {
|
||||
removeItem('access_token')
|
||||
removeItem('id_token')
|
||||
removeItem('expires_at')
|
||||
removeItem('auth.user')
|
||||
removeItem('authUser')
|
||||
removeItem('auth0.ssodata')
|
||||
window.localStorage.clear()
|
||||
deleteCookie('ajs_anonymous_id')
|
||||
@@ -156,7 +156,7 @@ class Auth {
|
||||
|
||||
async isAuthenticated () {
|
||||
// check session and run Auth0 SS0
|
||||
const getUser = await getItem('auth.user')
|
||||
const getUser = await getItem('authUser')
|
||||
let user = JSON.parse(getUser)
|
||||
|
||||
if (validObject(user, 'exp') && new Date().getTime() < (user.exp * 1000)) {
|
||||
@@ -168,7 +168,7 @@ class Auth {
|
||||
const checkSSO = await this.checkSession()
|
||||
.then(result => {
|
||||
console.log('handleAuth.checksessions: ', result)
|
||||
setItem('auth.user', result.idTokenPayload.sub)
|
||||
setItem('authUser', result.idTokenPayload.sub)
|
||||
// user confirmed, log into client
|
||||
this.setSession(result)
|
||||
return result.idTokenPayload
|
||||
|
||||
@@ -43,12 +43,10 @@ class LoggedInUser extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
localStorage.setItem('loggedInUser', JSON.stringify(this.props.data.userByAuthId));
|
||||
|
||||
return (
|
||||
<div>
|
||||
{this.displayLoggedInUser()}
|
||||
|
||||
@@ -50,7 +50,7 @@ class NavBar extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
const userStored = localStorage.getItem('auth.user');
|
||||
const userStored = localStorage.getItem('authUser');
|
||||
|
||||
if (userStored !== null && userStored !== undefined && userStored !== 'undefined') {
|
||||
const user = JSON.parse(userStored);
|
||||
|
||||
@@ -6,19 +6,25 @@ import {getRolesQuery, updateUserMutation, getUsersQuery} from '../queries/queri
|
||||
class UserUpdate extends Component {
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.state = {
|
||||
id: '5b90fc33ae71ee3798b2317d', // TODO this Id is the one that should be available to all components after the validation that the user is authenticated.
|
||||
firstName: '',
|
||||
middleName: '',
|
||||
lastName: '',
|
||||
email: '',
|
||||
emailVerified: 0,
|
||||
isDeveloper: 0,
|
||||
isTrader: 0,
|
||||
isDataAnalyst: 0,
|
||||
roleId: '1'
|
||||
};
|
||||
|
||||
super(props);
|
||||
|
||||
this.defaultValuesSet = false;
|
||||
|
||||
this.state = {
|
||||
id: '5b90fc33ae71ee3798b2317d', // TODO this Id is the one that should be available to all components after the validation that the user is authenticated.
|
||||
firstName: '',
|
||||
middleName: '',
|
||||
lastName: '',
|
||||
email: '',
|
||||
emailVerified: 0,
|
||||
isDeveloper: 0,
|
||||
isTrader: 0,
|
||||
isDataAnalyst: 0,
|
||||
roleId: '1'
|
||||
};
|
||||
|
||||
console.log("constructor");
|
||||
}
|
||||
|
||||
displayRoles(){
|
||||
@@ -33,7 +39,7 @@ class UserUpdate extends Component {
|
||||
}
|
||||
|
||||
submitForm(e){
|
||||
console.log(this.state);
|
||||
console.log("submitting this>", this.state);
|
||||
e.preventDefault();
|
||||
this.props.updateUserMutation({
|
||||
variables: {
|
||||
@@ -114,15 +120,44 @@ class UserUpdate extends Component {
|
||||
this.setState({ roleId:e.target.value })
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
console.log("component did mount");
|
||||
this.setState({});
|
||||
}
|
||||
|
||||
componentWillUnmount(){
|
||||
console.log("component will UNmount");
|
||||
}
|
||||
|
||||
componentDidUpdate ()
|
||||
{
|
||||
console.log("component did update");
|
||||
if (this.defaultValuesSet === false)
|
||||
{
|
||||
let user = JSON.parse(localStorage.getItem("loggedInUser"));
|
||||
this.defaultValuesSet= true;
|
||||
this.refs.firstName.value = user.alias;
|
||||
console.log("setting defaults");
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
console.log("user at render", this.props);
|
||||
console.log("render");
|
||||
|
||||
return(
|
||||
<div>
|
||||
<form onSubmit={this.submitForm.bind(this)}>
|
||||
|
||||
<p>Complete your profile with the following optional information. Providing your real name might help other users trust you more.</p>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<input id="firstName" type="text" onChange={ (e) => this.setState({ firstName:e.target.value})}/>
|
||||
<input
|
||||
id = "firstName"
|
||||
type = "text"
|
||||
ref = "firstName"
|
||||
onBlur = { (e) => this.setState({ firstName:e.target.value})}>
|
||||
</input>
|
||||
<label htmlFor="firstName">First Name</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user