|
4 | 4 | <edit-avatar /> |
5 | 5 |
|
6 | 6 | <div class="edit-profile--fields"> |
7 | | - <form-field label="Name" type="text" :value="currentUser.name" :margin-top="false" @change="logChange"/> |
8 | | - <form-field label="Description" type="textarea" value="Dummy description" /> |
9 | | - <form-field label="Location" type="text" value="location" /> |
| 7 | + <form-field label="Name" type="text" v-model="userParams.name" :margin-top="false" /> |
| 8 | + <form-field label="Description" type="textarea" v-model="userParams.bio" /> |
| 9 | + <form-field label="Location" type="text" v-model="userParams.location" /> |
10 | 10 | </div> |
11 | 11 |
|
12 | 12 | </div> |
13 | 13 |
|
14 | 14 | <div class="folders--options-wrapper"> |
15 | | - <button class="button--cta-blue">SAVE</button> |
| 15 | + <button @click="saveForm" class="button--cta-blue">SAVE</button> |
16 | 16 | </div> |
17 | 17 | </div> |
18 | 18 | </template> |
|
21 | 21 | import EditAvatar from './edit-avatar'; |
22 | 22 | import FormField from './form-field'; |
23 | 23 |
|
| 24 | +import usersMixin from './mixins/usersMixin'; |
| 25 | +
|
24 | 26 | export default { |
25 | 27 | components: { EditAvatar, FormField }, |
26 | 28 |
|
27 | | - // TODO: Extract this into a class or module that can be reused accross the application |
| 29 | + mixins: [usersMixin], |
| 30 | +
|
28 | 31 | data() { |
29 | 32 | return { |
30 | | - currentUser: this.$store.state.currentUser |
| 33 | + userParams: { |
| 34 | + name: this.currentUser.name, |
| 35 | + bio: 'Dummy bio', |
| 36 | + location: 'Cambridge UK' |
| 37 | + } |
31 | 38 | } |
32 | 39 | }, |
33 | 40 |
|
| 41 | + // TODO: Extract this into a class or module that can be reused across the application |
| 42 | + beforeCreate() { |
| 43 | + this.currentUser = this.$store.state.currentUser; |
| 44 | + }, |
| 45 | +
|
34 | 46 | methods: { |
35 | | - logChange(value) { |
36 | | - console.log(value) |
| 47 | + saveForm() { |
| 48 | + console.log('params', this.userParams) |
| 49 | +
|
| 50 | + this.updateUser(this.userParams) |
| 51 | + .then(res => { |
| 52 | + console.log('aya', res) |
| 53 | + }) |
| 54 | + .catch(error => { |
| 55 | + console.error(error) |
| 56 | + }) |
37 | 57 | } |
38 | 58 | } |
39 | 59 | } |
|
0 commit comments