diff --git a/assets/styles/app.scss b/assets/styles/app.scss index ea3d48c..97d4d89 100644 --- a/assets/styles/app.scss +++ b/assets/styles/app.scss @@ -183,10 +183,6 @@ align-items: stretch; } - .button.is-fullwidth + .button.is-fullwidth { - margin-top: 1rem; - } - &-anonymous { width: 100%; cursor: pointer; @@ -602,4 +598,16 @@ fieldset { &:not(:last-child) { margin-bottom: $block-spacing; } + + &.authorize { + max-width: 30%; + margin-left: auto; + margin-right: auto; + } +} + +.form { + .button.is-fullwidth + .button.is-fullwidth { + margin-top: 1rem; + } } diff --git a/pages/authorize-contribution.vue b/pages/authorize-contribution.vue new file mode 100644 index 0000000..7f85b5a --- /dev/null +++ b/pages/authorize-contribution.vue @@ -0,0 +1,43 @@ + + + diff --git a/pages/make-contribution.vue b/pages/make-contribution.vue index 6477984..1d034fd 100644 --- a/pages/make-contribution.vue +++ b/pages/make-contribution.vue @@ -131,22 +131,10 @@ export default { } }, async mounted() { - try { - const response = await fetch('/api/user_data') - const data = await response.json() - console.log('data', data) - if (data.name !== 'Anonymous') { - this.userHandle = data.handle - this.userName = data.name - // TODO check whether it's github or twitter - this.contributionType = 'twitter' - } - } catch (e) { - console.error('user_data fail', e) - } + await this.getUserData() }, methods: { - ...mapActions('user', ['makeTweet', 'logOut']), + ...mapActions('user', ['makeTweet', 'logOut', 'getUserData']), async makeContribution({ retry = 0 } = {}) { try { this.isContributeBtnSnown = true diff --git a/store/user.js b/store/user.js index ed35698..0d0881b 100644 --- a/store/user.js +++ b/store/user.js @@ -81,6 +81,21 @@ const actions = { }, async logOut() { await fetch('/api/logout') + }, + async getUserData({ commit }) { + try { + const response = await fetch('/api/user_data') + const data = await response.json() + console.log('data', data) + if (data.name !== 'Anonymous') { + commit('SET_HANDLE', data.handle) + commit('SET_NAME', data.name) + // TODO check whether it's github or twitter + commit('SET_CONTRIBUTION_TYPE', 'twitter') + } + } catch (e) { + console.error('user_data fail', e) + } } }