@@ -137,30 +137,32 @@ export default {
137137 },
138138 computed: {
139139 hasProfile : function () {
140- return !! this .profile .updated_at
140+ return !! this .profile ? .updated_at
141141 },
142142 hasAudience: function () {
143- return !! this .profile .audience
143+ return !! this .profile ? .audience
144144 },
145145 isWikiTemporary: function () {
146- return this .profile .temporality === ' temporary'
146+ return this .profile ? .temporality === ' temporary'
147147 },
148148 updatedAt: function () {
149- if (this .profile .updated_at ) {
149+ if (this .profile ? .updated_at ) {
150150 return ` Last updated on ${ new Date (this .profile .updated_at ).toLocaleString ()} `
151151 }
152152 return false
153153 }
154154 },
155155 methods: {
156156 getQuestionResponse (question ) {
157- const customResponse = this .profile [question + ' _other' ]
158- if (customResponse) {
159- return ` Other: ${ customResponse} `
160- }
161- const providedResponse = this .profile [question]
162- if (providedResponse) {
163- return providedResponses[question][providedResponse]
157+ if (this .profile ) {
158+ const customResponse = this .profile [question + ' _other' ]
159+ if (customResponse) {
160+ return ` Other: ${ customResponse} `
161+ }
162+ const providedResponse = this .profile [question]
163+ if (providedResponse) {
164+ return providedResponses[question][providedResponse]
165+ }
164166 }
165167 return ' No answer selected.'
166168 },
@@ -184,11 +186,8 @@ export default {
184186 temporality: this .dialog .data .stepTwo .temporality ,
185187 ... (this .dialog .data .stepTwo .otherTemporality && { temporality_other: this .dialog .data .stepTwo .otherTemporality })
186188 }
187-
188- this .profile = (await this .$store .dispatch (' updateProfile' , {
189- wiki: this .wikiId , profile: JSON .stringify (profile)
190- })).data .data ?? {}
191-
189+ await this .$store .dispatch (' updateProfile' , { wiki: this .wikiId , profile: JSON .stringify (profile) })
190+ this .profile = this .$store .state .wikis .currentWikiProfile
192191 this .$refs .message .show (' success' , ' Intended use has been updated.' )
193192 this .dialog .show = false
194193 } catch (error) {
@@ -200,13 +199,7 @@ export default {
200199 }
201200 },
202201 async created () {
203- try {
204- const details = await this .$api .wikiDetails ({ wiki: this .wikiId })
205- this .profile = details .wiki_latest_profile ?? {}
206- } catch (error) {
207- console .log (error)
208- this .$refs .message .show (' error' , ' Something went wrong with fetching your intended use.' )
209- }
202+ this .profile = this .$store .state .wikis .currentWikiProfile
210203 }
211204}
212205< / script>
0 commit comments