livebook/assets/js/hooks/user_form.js
Jonatan Kłosko b3b79afed4
Refactor JS hooks (#1055)
* Restructure hook files

* Simplify app.js

* Refactor hooks

* Implement password toggle with JS commands
2022-03-16 11:33:53 +01:00

21 lines
528 B
JavaScript

import { storeUserData } from "../lib/user";
/**
* A hook for the user profile form.
*
* On submit this hook saves the new data into cookie. This cookie
* serves as a backup and can be used to restore user data if the
* server is restarted.
*/
const UserForm = {
mounted() {
this.el.addEventListener("submit", (event) => {
const name = this.el.user_form_name.value;
const hex_color = this.el.user_form_hex_color.value;
storeUserData({ name, hex_color });
});
},
};
export default UserForm;