diff --git a/src/_helpers/router.js b/src/_helpers/router.js index 7ad6d3e..88d1cfe 100644 --- a/src/_helpers/router.js +++ b/src/_helpers/router.js @@ -19,9 +19,19 @@ export const router = new Router({ { path: '/', component: HomePage, children: [ - { path: '', component: NetworksPage }, + { + path: '', component: NetworksPage, + children: [ + { path: '', component: NewNetworkPage }, + ] + }, { path: '/profile', component: ProfilePage }, - { path: '/networks', component: NetworksPage }, + { + path: '/networks', component: NetworksPage , + children: [ + { path: '', component: NewNetworkPage }, + ] + }, { path: '/networks/new', component: NewNetworkPage }, { path: '/networks/:uuid', component: NetworkPage } ] diff --git a/src/_services/index.js b/src/_services/index.js index fa72f5b..d68e20e 100644 --- a/src/_services/index.js +++ b/src/_services/index.js @@ -3,5 +3,6 @@ export * from './user.service'; export * from './domain.service'; export * from './plan.service'; export * from './footprint.service'; +export * from './paymentMethod.service'; export * from './accountPlan.service'; export * from './network.service'; diff --git a/src/_services/paymentMethod.service.js b/src/_services/paymentMethod.service.js new file mode 100644 index 0000000..fb1498b --- /dev/null +++ b/src/_services/paymentMethod.service.js @@ -0,0 +1,15 @@ +import config from 'config'; +import { getWithAuth, handleCrudResponse } from '../_helpers'; + +export const paymentMethodService = { + getAll, + getById +}; + +function getAll() { + return fetch(`${config.apiUrl}/paymentMethods`, getWithAuth()).then(handleCrudResponse); +} + +function getById(paymentMethodId) { + return fetch(`${config.apiUrl}/paymentMethods/${paymentMethodId}`, getWithAuth()).then(handleCrudResponse); +} diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 6a2bb18..4bb647f 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -37,7 +37,7 @@ const actions = { router.push('/'); setTimeout(() => { // display success message after route change completes - dispatch('alert/success', 'Registration successful', { root: true }); + dispatch('alert/success', messages.alert_registration_success, { root: true }); }) }, error => { diff --git a/src/_store/index.js b/src/_store/index.js index 26024af..e87208f 100644 --- a/src/_store/index.js +++ b/src/_store/index.js @@ -8,6 +8,7 @@ import { users } from './users.module'; import { plans } from './plans.module'; import { footprints } from './footprints.module'; import { domains } from './domains.module'; +import { paymentMethods } from './paymentMethods.module'; import { accountPlans } from './accountPlans.module'; import { networks } from './networks.module'; @@ -19,9 +20,10 @@ export const store = new Vuex.Store({ system, account, users, - domains, plans, footprints, + domains, + paymentMethods, accountPlans, networks } diff --git a/src/_store/paymentMethods.module.js b/src/_store/paymentMethods.module.js new file mode 100644 index 0000000..e4eed88 --- /dev/null +++ b/src/_store/paymentMethods.module.js @@ -0,0 +1,60 @@ +import { paymentMethodService } from '../_services'; + +const state = { + loading: null, + error: null, + paymentMethods: null, + paymentMethod: null +}; + +const actions = { + getAll({ commit }) { + commit('getAllRequest'); + paymentMethodService.getAll() + .then( + paymentMethods => commit('getAllSuccess', paymentMethods), + error => commit('getAllFailure', error) + ); + }, + + getByUuid({ commit }, uuid) { + commit('getByUuidRequest'); + paymentMethodService.getById(uuid) + .then( + paymentMethod => commit('getByUuidSuccess', paymentMethod), + error => commit('getByUuidFailure', error) + ); + } +}; + +const mutations = { + getAllRequest(state) { + state.loading = true; + }, + getAllSuccess(state, paymentMethods) { + state.loading = false; + state.paymentMethods = paymentMethods; + }, + getAllFailure(state, error) { + state.loading = false; + state.error = { error }; + }, + getByUuidRequest(state) { + state.loading = true; + }, + getByUuidSuccess(state, paymentMethod) { + state.loading = false; + state.paymentMethod = paymentMethod; + }, + getByUuidFailure(state, error) { + state.loading = false; + state.error = { error }; + } +}; + +export const paymentMethods = { + namespaced: true, + state, + actions, + mutations +}; diff --git a/src/_store/system.module.js b/src/_store/system.module.js index 8ac2730..1784add 100644 --- a/src/_store/system.module.js +++ b/src/_store/system.module.js @@ -2,7 +2,8 @@ import { systemService } from '../_services'; const state = { configs: { - allowRegistration: null + allowRegistration: null, + paymentsEnabled: true }, messages: {}, countries: [], diff --git a/src/account/NetworksPage.vue b/src/account/NetworksPage.vue index f6aac8b..135e0c4 100644 --- a/src/account/NetworksPage.vue +++ b/src/account/NetworksPage.vue @@ -1,11 +1,8 @@ diff --git a/src/account/NewNetworkPage.vue b/src/account/NewNetworkPage.vue index 3f86d65..3aa5a44 100644 --- a/src/account/NewNetworkPage.vue +++ b/src/account/NewNetworkPage.vue @@ -34,6 +34,24 @@ {{messages['footprint_description_'+network.footprint]}} +
+ +
{{ errors.first('paymentMethod') }}
+
{{ errors.first('paymentMethodInfo') }}
+
{{ errors.first('paymentMethodType') }}
+
{{ errors.first('paymentMethodService') }}
+
{{ errors.first('paymentInfo') }}
+ + + +
+
+ credit selected +
+
+ invite code selected +
+
@@ -56,7 +74,11 @@ locale: 'en_US', timezone: '', plan: 'bubble', - footprint: 'Worldwide' + footprint: 'Worldwide', + paymentMethodObject: { + paymentMethodType: null, + paymentInfo: null + } }, user: currentUser(), submitted: false, @@ -68,6 +90,7 @@ ...mapState('domains', ['domains']), ...mapState('plans', ['plans']), ...mapState('footprints', ['footprints']), + ...mapState('paymentMethods', ['paymentMethods']), ...mapState('networks', { creating: state => state.loading, error: state => state.error @@ -122,6 +145,9 @@ ...mapActions('footprints', { loadFootprints: 'getAll' }), + ...mapActions('paymentMethods', { + loadPaymentMethods: 'getAll' + }), handleSubmit(e) { this.submitted = true; this.$validator.validate().then(valid => { @@ -135,6 +161,7 @@ this.loadDomains(currentUser().uuid); this.loadPlans(); this.loadFootprints(); + this.loadPaymentMethods(); } }; \ No newline at end of file