10
10
</template >
11
11
12
12
<script >
13
- import {
14
- mapState
15
- } from ' pinia'
16
- import profileStore from ' @/stores/profile'
17
13
import BaseFormContainer
18
14
from ' @/components/containers/forms/BaseFormContainer.vue'
19
15
import profileCreateFormOptions
@@ -22,7 +18,6 @@ import {
22
18
birthdate as formatBirthdate
23
19
} from ' @/helpers/formatters/dateTimeString'
24
20
import createProfile from ' @/helpers/actions/api/profile/create'
25
- import getProfile from ' @/helpers/actions/api/profile/get'
26
21
import {
27
22
update as updateGlobalStore
28
23
} from ' @/helpers/actions/store/global'
@@ -37,12 +32,8 @@ export default {
37
32
},
38
33
data () {
39
34
return {
40
- token: null ,
41
- profileId: null ,
42
- profileData: null ,
43
35
error: null ,
44
36
isLoading: false ,
45
- isRemember: false ,
46
37
fields: [
47
38
' email' ,
48
39
' password' ,
@@ -52,34 +43,18 @@ export default {
52
43
}
53
44
},
54
45
computed: {
55
- ... mapState (
56
- profileStore,
57
- {
58
- profileToken: ' token'
59
- }
60
- ),
61
46
options () {
62
47
return profileCreateFormOptions (
63
48
{
64
- onSuccess: this .handleSuccess
49
+ onSuccess:
50
+ this .handleSubmitSuccess
65
51
}
66
52
)
67
- },
68
- profileArgs () {
69
- return {
70
- profileId: this .profileId
71
- }
72
53
}
73
54
},
74
- watch: {
75
- profileId: ' handleProfileIdChange' ,
76
- profileToken: ' handleProfileTokenChange' ,
77
- profileData: ' handleProfileDataChange'
78
- },
79
55
methods: {
80
56
createProfile,
81
- getProfile,
82
- handleSuccess (
57
+ handleSubmitSuccess (
83
58
event ,
84
59
fields
85
60
) {
@@ -92,30 +67,27 @@ export default {
92
67
93
68
this .createProfile (
94
69
createArgs
70
+ ).then (
71
+ this .handleProfileCreateSuccess
95
72
)
96
73
},
97
- handleProfileIdChange (
98
- value
99
- ) {
100
- if (value) {
101
- this .setSessionData ()
102
- }
103
- },
104
- handleProfileTokenChange (
105
- value
106
- ) {
107
- if (value) {
108
- this .getProfile (
109
- this .profileArgs
110
- )
111
- }
112
- },
113
- handleProfileDataChange (
114
- value
74
+ async handleProfileCreateSuccess (
75
+ responseData
115
76
) {
77
+ const profileId =
78
+ responseData .profile .id
79
+
80
+ const profileToken =
81
+ responseData .profile .token
82
+
83
+ const isRememberProfile =
84
+ responseData .isRemember
85
+
116
86
updateGlobalStore (
117
87
{
118
- ' profile.info' : value
88
+ ' profile.id' : profileId,
89
+ ' profile.token' : profileToken,
90
+ ' profile.isRemember' : isRememberProfile
119
91
}
120
92
)
121
93
},
@@ -164,14 +136,6 @@ export default {
164
136
isRemember
165
137
}
166
138
},
167
- setSessionData () {
168
- updateGlobalStore (
169
- {
170
- ' profile.token' : this .token ,
171
- ' profile.isRemember' : this .isRemember
172
- }
173
- )
174
- },
175
139
validateField (
176
140
value
177
141
) {
0 commit comments