Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Invite module
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kokovin committed Apr 19, 2019
1 parent 4d8ec91 commit 6be24bf
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 2 deletions.
2 changes: 2 additions & 0 deletions source/RootStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DocumentsStore from '@/modules/documents/store';
import GameStore from '@/modules/gameCommon/store';
import GamesStore from '@/modules/games/store';
import HistoryStore from '@/modules/history/store';
import InviteStore from '@/modules/invite/store';
import NotificationsStore from '@/modules/notifications/store';
import RequestsStore from '@/modules/requests/store';
import RequestStore from '@/modules/request/store';
Expand Down Expand Up @@ -41,6 +42,7 @@ export default {
Game: GameStore(apiUrl),
Games: GamesStore(apiUrl),
History: HistoryStore(adminApiUrl),
Invite: InviteStore(apiUrl),
Notifications: NotificationsStore(apiUrl),
Request: RequestStore(adminApiUrl),
Requests: RequestsStore(adminApiUrl),
Expand Down
74 changes: 74 additions & 0 deletions source/modules/invite/Invite.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<div class="invite-wrapper">
<UiPageHeader :title="$t('title')">
<UiButton
slot="right"
v-text="$t('accept')"
@click="accept(currentVendorId)"
/>
</UiPageHeader>

<div class="content">
<IconDummy />
<span class="dummy-text">
{{ $t('dummy') }}
</span>
</div>
</div>
</template>

<script type="ts">
import Vue from 'vue';
import { mapGetters, mapState, mapActions } from 'vuex';
import { UiButton, UiPageHeader } from '@protocol-one/ui-kit';
import IconDummy from '@/components/IconDummy.vue';
import i18n from './i18n';
export default Vue.extend({
i18n,
components: { IconDummy, UiButton, UiPageHeader },
computed: {
...mapState('Invite', ['hasAccepted']),
currentVendorId() {
return this.$route.params.vendorId;
},
inviteId() {
return this.$route.params.inviteId;
},
},
mounted() {
this.initState(this.inviteId);
},
methods: {
...mapActions('Invite', ['initState', 'accept']),
},
watch: {
hasAccepted(val) {
console.error(val);
},
},
});
</script>

<style scoped lang="scss">
.invite-wrapper {
min-height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
}
.content {
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.dummy-text {
display: block;
color: #b1b1b1;
text-align: center;
margin-top: 20px;
}
</style>
19 changes: 19 additions & 0 deletions source/modules/invite/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default {
messages: {
de: {
accept: 'Accept Invite',
title: 'Invite module',
dummy: 'Dummy for invite module',
},
en: {
accept: 'Accept Invite',
title: 'Invite module',
dummy: 'Dummy for invite module',
},
ru: {
accept: 'Принять приглашение',
title: 'Модель инвайтинга',
dummy: 'Заглушка для страницы принятия инвайта',
},
},
}
40 changes: 40 additions & 0 deletions source/modules/invite/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import axios from 'axios';
import { GetterTree, ActionTree, MutationTree } from 'vuex';
import { State } from './types';

export default function HistoryStore(apiUrl: string) {
const state: State = {
hasAccepted: false,
inviteId: null,
};
const getters: GetterTree<State, any> = {};
const actions: ActionTree<State, any> = {
async initState({ commit }, inviteId) {
commit('inviteId', inviteId);
},
async accept({ commit, state }, vendorId) {
const resp = await axios
.put(`${apiUrl}/vendors/${vendorId}/memberships/invites/${state.inviteId}`, {
method: 'accept',
})
.then(() => {
commit('hasAccepted', true);
})
.catch(e => e);

console.error(resp);
},
};
const mutations: MutationTree<State> = {
hasAccepted: (state, value) => state.hasAccepted = value,
inviteId: (state, value) => state.inviteId = value,
};

return {
state,
getters,
actions,
mutations,
namespaced: true,
};
}
4 changes: 4 additions & 0 deletions source/modules/invite/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface State {
hasAccepted: boolean;
inviteId: number;
}
7 changes: 7 additions & 0 deletions source/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import GameSales from '@/modules/gameSales/Sales.vue';
import GameDescriptions from '@/modules/gameDescriptions/Descriptions.vue';
import Games from '@/modules/games/Games.vue';
import History from '@/modules/history/History.vue';
import Invite from '@/modules/invite/Invite.vue';
import OnBoarding from '@/modules/onBoarding/OnBoarding.vue';
import Notifications from '@/modules/notifications/Notifications.vue';
import Requests from '@/modules/requests/Requests.vue';
Expand All @@ -31,6 +32,12 @@ const routes: RouteConfig[] = [
component: AuthBoard,
meta: { requiresAuth: false, requiresPermissions: false },
},
{
path: '/vendors/:vendorId/invite/:inviteId',
name: 'invite',
component: Invite,
meta: { requiresAuth: false, requiresPermissions: false },
},
{
path: '/vendor/on-boarding',
name: 'onBoarding',
Expand Down
2 changes: 0 additions & 2 deletions source/stores/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ export default function UserStore(apiUrl: string, authApiUrl: string, router: Vu
if (vendors && vendors.length) {
commit('vendors', vendors);
commit('currentVendor', vendors[0]);
} else {
router.push({ name: 'onBoarding' });
}

await dispatch('fetchPermissions');
Expand Down

0 comments on commit 6be24bf

Please sign in to comment.