diff --git a/src/App.vue b/src/App.vue index 74df185..43146ee 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,8 +5,8 @@ Sample App - First Module - Second Module + Sample Component + Login Component diff --git a/src/app/baluster/api.ts b/src/app/baluster/api.ts new file mode 100644 index 0000000..963dda9 --- /dev/null +++ b/src/app/baluster/api.ts @@ -0,0 +1,7 @@ +import { HTTP, CLIENT } from '../../http'; + +export const api = { + fetchPickets(params: any) { + return HTTP.get('https://api.adviceslip.com/advice', {responseType: 'json'}); + }, +}; diff --git a/src/app/baluster/components/BalusterMasterCard.vue b/src/app/baluster/components/BalusterMasterCard.vue new file mode 100644 index 0000000..4af2868 --- /dev/null +++ b/src/app/baluster/components/BalusterMasterCard.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/app/baluster/components/DefaultCard.vue b/src/app/baluster/components/DefaultCard.vue new file mode 100644 index 0000000..754eef8 --- /dev/null +++ b/src/app/baluster/components/DefaultCard.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/app/baluster/components/ParamountCard.vue b/src/app/baluster/components/ParamountCard.vue new file mode 100644 index 0000000..a056b51 --- /dev/null +++ b/src/app/baluster/components/ParamountCard.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/app/baluster/components/PronouncementCard.vue b/src/app/baluster/components/PronouncementCard.vue new file mode 100644 index 0000000..76eca1d --- /dev/null +++ b/src/app/baluster/components/PronouncementCard.vue @@ -0,0 +1,17 @@ + + + \ No newline at end of file diff --git a/src/app/baluster/components/index.ts b/src/app/baluster/components/index.ts new file mode 100644 index 0000000..c02008d --- /dev/null +++ b/src/app/baluster/components/index.ts @@ -0,0 +1,4 @@ +export { default as BalusterMasterCard } from './BalusterMasterCard.vue'; +export { default as ParamountCard } from './ParamountCard.vue'; +export { default as PronouncementCard } from './PronouncementCard.vue'; +export { default as DefaultCard } from './DefaultCard.vue'; diff --git a/src/app/baluster/index.ts b/src/app/baluster/index.ts new file mode 100644 index 0000000..1646055 --- /dev/null +++ b/src/app/baluster/index.ts @@ -0,0 +1,2 @@ +export { default as routes } from './routes'; +export { jamb as vuex } from './vuex'; diff --git a/src/app/baluster/routes.ts b/src/app/baluster/routes.ts new file mode 100644 index 0000000..e0e723a --- /dev/null +++ b/src/app/baluster/routes.ts @@ -0,0 +1,19 @@ +import { DefaultCard, BalusterMasterCard, ParamountCard, PronouncementCard } from './components'; + +export default [ + { + path: '/baluster', + component: BalusterMasterCard, + children: [ + { + path: '/', + components: { + default: DefaultCard, + paramount: ParamountCard, + pronouncement: PronouncementCard, + }, + name: 'baluster', + }, + ], + }, +]; diff --git a/src/app/baluster/vuex/actions.ts b/src/app/baluster/vuex/actions.ts new file mode 100644 index 0000000..e2f72ba --- /dev/null +++ b/src/app/baluster/vuex/actions.ts @@ -0,0 +1,11 @@ +import { ActionTree } from 'vuex'; +import { JambState } from './types'; +import { RootState } from '@/app/types'; +import { api } from '../api'; +export const actions: ActionTree = { + pickets({commit}): any { + api.fetchPickets({}).then((response: any) => { + console.log(response); + }); + }, +}; diff --git a/src/app/baluster/vuex/getters.ts b/src/app/baluster/vuex/getters.ts new file mode 100644 index 0000000..67a8527 --- /dev/null +++ b/src/app/baluster/vuex/getters.ts @@ -0,0 +1,10 @@ +import { GetterTree } from 'vuex'; +import { JambState } from './types'; +import { RootState } from '../../types'; + +export const getters: GetterTree = { + columns(state): string { + const {message} = state; + return message; + }, +}; diff --git a/src/app/baluster/vuex/index.ts b/src/app/baluster/vuex/index.ts new file mode 100644 index 0000000..e991815 --- /dev/null +++ b/src/app/baluster/vuex/index.ts @@ -0,0 +1,22 @@ +import { Module } from 'vuex'; +import { getters } from './getters'; +import { actions } from './actions'; +import { mutations } from './mutations'; + +import { RootState } from '../../types'; +import { JambState } from './types'; + +export const state: JambState = { + message: '', + error: false, +}; + +const namespaced: boolean = true; + +export const jamb: Module = { + namespaced, + state, + getters, + actions, + mutations, +}; diff --git a/src/app/baluster/vuex/mutations.ts b/src/app/baluster/vuex/mutations.ts new file mode 100644 index 0000000..153e481 --- /dev/null +++ b/src/app/baluster/vuex/mutations.ts @@ -0,0 +1,14 @@ +import { MutationTree } from 'vuex'; +import { JambState } from './types'; + +export const mutations: MutationTree = { + sampleDataLoaded(state, payload: string) { + state.message = payload; + state.error = false; + }, + + sampleError(state) { + state.error = true; + state.message = ''; + }, +}; diff --git a/src/app/baluster/vuex/types.ts b/src/app/baluster/vuex/types.ts new file mode 100644 index 0000000..3fe9f90 --- /dev/null +++ b/src/app/baluster/vuex/types.ts @@ -0,0 +1,4 @@ +export interface JambState { + message: string; + error: boolean; +} diff --git a/src/app/mixins/vuex/mutations.ts b/src/app/mixins/vuex/mutations.ts index 9a2c143..1faf5c8 100644 --- a/src/app/mixins/vuex/mutations.ts +++ b/src/app/mixins/vuex/mutations.ts @@ -3,7 +3,6 @@ import { MixinState, QuoteState, FeedState, CountryState } from './types'; export const mutations: MutationTree = { sampleLocationLoaded(state, payload: any) { - console.log(payload); for (const c of payload) { const country: CountryState = { name: c.name, diff --git a/src/app/routes.ts b/src/app/routes.ts index 9b49756..3739afc 100644 --- a/src/app/routes.ts +++ b/src/app/routes.ts @@ -1,7 +1,9 @@ import { routes as login } from './login'; import { routes as sample } from './sample'; +import { routes as jamb } from './baluster'; export default [ ...login, ...sample, + ...jamb, ]; diff --git a/src/app/sample/components/SampleComponent.vue b/src/app/sample/components/SampleComponent.vue index 00e5562..36efeb9 100644 --- a/src/app/sample/components/SampleComponent.vue +++ b/src/app/sample/components/SampleComponent.vue @@ -6,7 +6,7 @@

{{message}}

- Second Module + Login Component { + next(); + }, + }) export default class SampleComponent extends Mixins(LocationMixin) { @Action('sampleData', {namespace}) private sampleData: any; @State('sample') private sample!: SampleState; diff --git a/src/app/sample/routes.ts b/src/app/sample/routes.ts index 18d0e14..ec35c1d 100644 --- a/src/app/sample/routes.ts +++ b/src/app/sample/routes.ts @@ -1,9 +1,14 @@ import { SampleComponent } from './components'; +import { Route } from 'vue-router'; export default [ { path: '/sample-component', component: SampleComponent, + name: 'sample.component', + beforeEnter: (to: Route, from: Route, next: any) => { + next(); + }, }, { path: '', diff --git a/src/app/vuex.ts b/src/app/vuex.ts index 3ccc6b6..9a96679 100644 --- a/src/app/vuex.ts +++ b/src/app/vuex.ts @@ -1,8 +1,11 @@ import { vuex as login } from './login'; import { vuex as sample } from './sample'; import { vuex as mixins } from './mixins'; +import { vuex as jamb } from './baluster'; + export default { login, sample, mixins, + jamb, }; diff --git a/src/router.ts b/src/router.ts index 067df4d..4306db4 100644 --- a/src/router.ts +++ b/src/router.ts @@ -1,5 +1,5 @@ import Vue from 'vue'; -import Router from 'vue-router'; +import Router, { Route } from 'vue-router'; import { routes } from './app'; Vue.use(Router); @@ -14,8 +14,16 @@ const router = new Router({ * Configure pre request checks and router validations. * Access control. */ -router.beforeEach((to, from, next) => { +router.beforeEach((to: Route, from: Route, next: any) => { next(); }); +router.beforeResolve((to: Route, from: Route, next: any) => { + next(); +}); + +router.afterEach((to: Route, from: Route) => { + // Here do something after everything is ready. +}); + export default router;