mirror of
https://git.pleroma.social/sjw/pleroma-fe.git
synced 2024-12-23 20:45:09 +01:00
Get rid of mutation_types file, use inline approach. Minor fixes
This commit is contained in:
parent
636be3b681
commit
a3e19cbafa
@ -1,7 +1,6 @@
|
||||
import { validationMixin } from 'vuelidate'
|
||||
import { required, sameAs } from 'vuelidate/lib/validators'
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
import { SIGN_UP } from '../../mutation_types'
|
||||
|
||||
const registration = {
|
||||
mixins: [validationMixin],
|
||||
@ -12,8 +11,7 @@ const registration = {
|
||||
username: '',
|
||||
password: '',
|
||||
confirm: ''
|
||||
},
|
||||
clientValidationFailed: false
|
||||
}
|
||||
}),
|
||||
validations: {
|
||||
user: {
|
||||
@ -37,8 +35,8 @@ const registration = {
|
||||
...mapState({
|
||||
registrationOpen: (state) => state.instance.registrationOpen,
|
||||
signedIn: (state) => !!state.users.currentUser,
|
||||
isPending: (state) => state.users[SIGN_UP.isPending],
|
||||
serverValidationErrors: (state) => state.users[SIGN_UP.errors],
|
||||
isPending: (state) => state.users.signUpPending,
|
||||
serverValidationErrors: (state) => state.users.signUpErrors,
|
||||
termsOfService: (state) => state.instance.tos
|
||||
})
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||
import { compact, map, each, merge } from 'lodash'
|
||||
import { set } from 'vue'
|
||||
import { SIGN_UP } from '../mutation_types'
|
||||
import oauthApi from '../services/new_api/oauth'
|
||||
import {humanizeErrors} from './errors'
|
||||
|
||||
@ -50,26 +49,27 @@ export const mutations = {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'highlight', highlighted)
|
||||
},
|
||||
[SIGN_UP.PENDING] (state) {
|
||||
state[SIGN_UP.isPending] = true
|
||||
state[SIGN_UP.errors] = []
|
||||
signUpPending (state) {
|
||||
state.signUpPending = true
|
||||
state.signUpErrors = []
|
||||
},
|
||||
[SIGN_UP.SUCCESS] (state) {
|
||||
state[SIGN_UP.isPending] = false
|
||||
signUpSuccess (state) {
|
||||
state.signUpPending = false
|
||||
},
|
||||
[SIGN_UP.FAILURE] (state, errors) {
|
||||
state[SIGN_UP.isPending] = false
|
||||
state[SIGN_UP.errors] = errors
|
||||
signUpFailure (state, errors) {
|
||||
state.signUpPending = false
|
||||
state.signUpErrors = errors
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultState = {
|
||||
loggingIn: false,
|
||||
lastLoginName: false,
|
||||
currentUser: false,
|
||||
users: [],
|
||||
usersObject: {},
|
||||
sign_up_pending: false,
|
||||
sign_up_errors: []
|
||||
signUpPending: false,
|
||||
signUpErrors: []
|
||||
}
|
||||
|
||||
const users = {
|
||||
@ -96,7 +96,7 @@ const users = {
|
||||
})
|
||||
},
|
||||
async signUp (store, userInfo) {
|
||||
store.commit(SIGN_UP.PENDING)
|
||||
store.commit('signUpPending')
|
||||
|
||||
let rootState = store.rootState
|
||||
|
||||
@ -113,13 +113,13 @@ const users = {
|
||||
username: userInfo.username,
|
||||
password: userInfo.password
|
||||
})
|
||||
store.commit(SIGN_UP.SUCCESS)
|
||||
store.commit('signUpSuccess')
|
||||
store.commit('setToken', result.access_token)
|
||||
store.dispatch('loginUser', result.access_token)
|
||||
} else {
|
||||
let data = await response.json()
|
||||
let errors = humanizeErrors(JSON.parse(data.error))
|
||||
store.commit(SIGN_UP.FAILURE, errors)
|
||||
store.commit('signUpFailure', errors)
|
||||
throw Error(errors)
|
||||
}
|
||||
},
|
||||
|
@ -1,9 +0,0 @@
|
||||
export const SIGN_UP = {
|
||||
// mutations
|
||||
SUCCESS: 'SIGN_UP_SUCCESS',
|
||||
FAILURE: 'SIGN_UP_FAILURE',
|
||||
PENDING: 'SIGN_UP_PENDING',
|
||||
// state
|
||||
isPending: 'sign_up_pending',
|
||||
errors: 'sign_up_errors'
|
||||
}
|
Loading…
Reference in New Issue
Block a user