Add wallet field
This commit is contained in:
parent
fb9761959c
commit
db6254639d
|
@ -12,17 +12,26 @@
|
|||
<b-field
|
||||
:type="{ 'is-danger': hasErrorName.invalid }"
|
||||
:message="{ [hasErrorName.msg]: hasErrorName.invalid }"
|
||||
:label-position="'inside'"
|
||||
label="Name"
|
||||
>
|
||||
<b-input v-model="userName" @blur="restrictSymbols('userName')" maxlength="35"></b-input>
|
||||
</b-field>
|
||||
<b-field label="Project">
|
||||
<b-field :label-position="'inside'" label="Project">
|
||||
<b-input
|
||||
v-model="userCompany"
|
||||
@blur="restrictSymbols('userCompany')"
|
||||
maxlength="35"
|
||||
></b-input>
|
||||
</b-field>
|
||||
<b-field
|
||||
:type="{ 'is-danger': hasErrorWallet.invalid }"
|
||||
:message="{ [hasErrorWallet.msg]: hasErrorWallet.invalid }"
|
||||
:label-position="'inside'"
|
||||
label="C-Chain Wallet (Optional)"
|
||||
>
|
||||
<b-input v-model="userWallet"></b-input>
|
||||
</b-field>
|
||||
</div>
|
||||
<div v-else class="buttons">
|
||||
<b-button @click="logInVia('twitter')" type="is-primary" outlined expanded>
|
||||
|
@ -40,7 +49,7 @@ import { mapGetters, mapActions } from 'vuex'
|
|||
|
||||
export default {
|
||||
computed: {
|
||||
...mapGetters('user', ['isLoggedIn', 'hasErrorName']),
|
||||
...mapGetters('user', ['isLoggedIn', 'hasErrorWallet', 'hasErrorName']),
|
||||
userName: {
|
||||
get() {
|
||||
return this.$store.state.user.name
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
<a :href="authorizeLink">{{ $t('pages.contribution.thisLink') }}</a
|
||||
>.
|
||||
</div>
|
||||
|
||||
<div class="buttons is-centered">
|
||||
<b-button
|
||||
v-if="!isContributeBtnSnown"
|
||||
|
@ -107,7 +106,7 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('user', ['isLoggedIn', 'hasErrorName']),
|
||||
...mapGetters('user', ['isLoggedIn', 'hasErrorWallet', 'hasErrorName']),
|
||||
userName: {
|
||||
get() {
|
||||
return this.$store.state.user.name
|
||||
|
@ -124,6 +123,14 @@ export default {
|
|||
this.$store.commit('user/SET_HANDLE', value)
|
||||
}
|
||||
},
|
||||
userWallet: {
|
||||
get() {
|
||||
return this.$store.state.user.wallet
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('user/SET_WALLET', value)
|
||||
}
|
||||
},
|
||||
userCompany: {
|
||||
get() {
|
||||
return this.$store.state.user.company
|
||||
|
@ -144,7 +151,8 @@ export default {
|
|||
return (
|
||||
!this.contributionType ||
|
||||
(!this.isLoggedIn && this.contributionType !== 'anonymous') ||
|
||||
this.hasErrorName.invalid
|
||||
this.hasErrorName.invalid ||
|
||||
this.hasErrorWallet
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -215,6 +223,7 @@ export default {
|
|||
if (this.contributionType !== 'anonymous') {
|
||||
formData.append('name', this.userName)
|
||||
formData.append('company', this.userCompany)
|
||||
formData.append('wallet', this.userWallet)
|
||||
}
|
||||
const resp = await fetch('api/response', {
|
||||
method: 'POST',
|
||||
|
|
|
@ -22,6 +22,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||
token: DataTypes.STRING,
|
||||
name: DataTypes.STRING,
|
||||
company: DataTypes.STRING,
|
||||
wallet: DataTypes.STRING,
|
||||
handle: DataTypes.STRING,
|
||||
socialType: DataTypes.STRING,
|
||||
attestation: DataTypes.STRING
|
||||
|
@ -33,12 +34,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||
}
|
||||
}
|
||||
)
|
||||
Contribution.nextContributionIndex = async function () {
|
||||
Contribution.nextContributionIndex = async function() {
|
||||
const rowsCount = await this.count()
|
||||
return rowsCount + 1
|
||||
}
|
||||
|
||||
Contribution.associate = function (models) {
|
||||
Contribution.associate = function(models) {
|
||||
// associations can be defined here
|
||||
}
|
||||
return Contribution
|
||||
|
|
|
@ -3,6 +3,7 @@ const state = () => {
|
|||
name: null,
|
||||
handle: 'Anonymous',
|
||||
company: '',
|
||||
wallet: null,
|
||||
contributionType: null,
|
||||
contributionIndex: null
|
||||
}
|
||||
|
@ -15,6 +16,9 @@ const mutations = {
|
|||
SET_HANDLE(state, handle) {
|
||||
state.handle = handle
|
||||
},
|
||||
SET_WALLET(state, wallet) {
|
||||
state.wallet = wallet
|
||||
},
|
||||
SET_COMPANY(state, company) {
|
||||
state.company = company
|
||||
},
|
||||
|
@ -30,6 +34,17 @@ const getters = {
|
|||
isLoggedIn: (state) => {
|
||||
return state.name !== null && state.name !== 'Anonymous'
|
||||
},
|
||||
hasErrorWallet: (state) => {
|
||||
const ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/
|
||||
const wallet = state.wallet
|
||||
if (wallet === null || wallet === '') {
|
||||
return { invalid: false, msg: '' }
|
||||
}
|
||||
if (!ADDRESS_REGEX.test(wallet)) {
|
||||
return { invalid: true, msg: 'invalid address' }
|
||||
}
|
||||
return { invalid: false, msg: '' }
|
||||
},
|
||||
hasErrorName: (state) => {
|
||||
const name = state.name
|
||||
if (name === null) {
|
||||
|
@ -84,6 +99,7 @@ https://ceremony.sherpa.cash`
|
|||
async logOut({ commit }) {
|
||||
commit('SET_HANDLE', 'Anonymous')
|
||||
commit('SET_CONTRIBUTION_TYPE', null)
|
||||
commit('SET_WALLET', null)
|
||||
commit('SET_NAME', null)
|
||||
commit('SET_COMPANY', '')
|
||||
await fetch('/api/logout')
|
||||
|
@ -96,6 +112,7 @@ https://ceremony.sherpa.cash`
|
|||
if (data.name !== 'Anonymous') {
|
||||
commit('SET_HANDLE', data.handle)
|
||||
commit('SET_NAME', data.name)
|
||||
commit('SET_WALLET', data.wallet)
|
||||
commit('SET_CONTRIBUTION_TYPE', data.socialType)
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue