Commit c5bcf03d authored by Michael Henretty's avatar Michael Henretty
Browse files

add saving email locally

parent d1beda52
......@@ -152,6 +152,7 @@ input[type="email"],
input[type="text"] {
height: var(--input-height);
border: 1px solid black;
border-radius: 0;
font-size: var(--base-font-size);
box-sizing: border-box;
padding: 0.8rem 0.2rem 0;
......
......@@ -7,17 +7,28 @@ interface Props {
}
interface State {
}
export default class Home extends Component<Props, State> {
export default class Profile extends Component<Props, State> {
constructor(props) {
super(props);
this.saveEmail = this.saveEmail.bind(this);
}
private saveEmail() {
let el = document.getElementById('email') as HTMLInputElement;
this.props.user.setEmail(el.value);
}
render() {
let state = this.props.user.getState();
return <div id="profile-container" className={this.props.active}>
<h2>Profile Data</h2>
<div className="input-and-button">
<label for="email">Your email address</label>
<input id="email" type="email" />
<button>Save</button>
<input id="email" type="email" name="email" value={state.email}/>
<button onClick={this.saveEmail}>Save</button>
</div>
<div id="opt-in">
<input id="send-emails" type="checkbox" />
......
......@@ -4,6 +4,7 @@ const USER_KEY = 'userdata';
interface UserState {
userId: string;
email: string;
clips: number;
}
......@@ -30,6 +31,7 @@ export default class User {
if (!this.state) {
this.state = {
userId: generateGUID(),
email: '',
clips: 0
};
this.store();
......@@ -47,4 +49,13 @@ export default class User {
public getId(): string {
return this.state.userId;
}
public setEmail(email: string): void {
this.state.email = email;
this.store();
}
public getState(): UserState {
return this.state;
}
}
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