2021-05-04 02:03:19 +08:00
|
|
|
import { storeUserData } from "../lib/user";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A hook for the user profile form.
|
|
|
|
*
|
2022-03-16 18:33:53 +08:00
|
|
|
* 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.
|
2021-05-04 02:03:19 +08:00
|
|
|
*/
|
|
|
|
const UserForm = {
|
|
|
|
mounted() {
|
|
|
|
this.el.addEventListener("submit", (event) => {
|
2021-07-07 20:32:49 +08:00
|
|
|
const name = this.el.user_form_name.value;
|
|
|
|
const hex_color = this.el.user_form_hex_color.value;
|
2021-05-04 02:03:19 +08:00
|
|
|
storeUserData({ name, hex_color });
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UserForm;
|