Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added pos register form in first user access #789

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 124 additions & 133 deletions src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,107 +4,112 @@
</div>

<div v-else class="app">
<div>
<sidebar class="sidebar" :unread-messages="unreadMessages" />
</div>
<div :class="['content', `theme-${theme}`]">
<Navbar class="navbar" />

<div class="page-container">
<warning-max-active-contacts />

<warning-verify-mail />

<router-view
v-show="!externalSystems.includes($route.name)"
class="page"
/>

<api-options
v-if="['apiFlows', 'apiIntelligence'].includes($route.name)"
/>

<external-system
ref="system-api-flows"
:routes="['apiFlows']"
class="page"
dont-update-when-changes-language
/>

<external-system
ref="system-api-intelligence"
:routes="['apiIntelligence']"
class="page"
dont-update-when-changes-language
/>

<external-system
v-if="['academy'].includes($route.name)"
ref="system-academy"
:routes="['academy']"
class="page"
dont-update-when-changes-language
/>

<external-system
ref="system-integrations"
:routes="['integrations']"
class="page"
dont-update-when-changes-language
/>

<external-system
ref="system-flows"
:routes="['studio', 'push']"
class="page"
/>

<external-system
ref="system-ia"
:routes="['bothub']"
class="page"
name="ai"
/>

<external-system
ref="system-agents"
:routes="['rocket']"
class="page"
/>

<external-system
ref="system-chats"
:routes="['chats']"
class="page"
dont-update-when-changes-language
name="chats"
/>
</div>
</div>

<modal
v-for="(modal, index) in modals"
:key="index"
v-on="modal.listeners"
v-bind="modal"
<pos-register
v-if="showPosRegister"
@success="isModalCreatedProjectOpen = true"
/>

<right-bar
v-for="rightBar in $store.state.RightBar.all"
:key="`right-bar-${rightBar.id}`"
:id="rightBar.id"
v-bind="rightBar.props"
v-on="rightBar.events"
/>

<!-- <know-user-modal
v-if="
$store.state.Account.profile &&
!$store.state.Account.profile.last_update_profile
"
/> -->
<template v-else>
<div>
<sidebar class="sidebar" :unread-messages="unreadMessages" />
</div>
<div :class="['content', `theme-${theme}`]">
<Navbar class="navbar" />

<div class="page-container">
<warning-max-active-contacts />

<warning-verify-mail />

<router-view
v-show="!externalSystems.includes($route.name)"
class="page"
/>

<api-options
v-if="['apiFlows', 'apiIntelligence'].includes($route.name)"
/>

<external-system
ref="system-api-flows"
:routes="['apiFlows']"
class="page"
dont-update-when-changes-language
/>

<external-system
ref="system-api-intelligence"
:routes="['apiIntelligence']"
class="page"
dont-update-when-changes-language
/>

<external-system
v-if="['academy'].includes($route.name)"
ref="system-academy"
:routes="['academy']"
class="page"
dont-update-when-changes-language
/>

<external-system
ref="system-integrations"
:routes="['integrations']"
class="page"
dont-update-when-changes-language
/>

<external-system
ref="system-flows"
:routes="['studio', 'push']"
class="page"
/>

<external-system
ref="system-ia"
:routes="['bothub']"
class="page"
name="ai"
/>

<external-system
ref="system-agents"
:routes="['rocket']"
class="page"
/>

<external-system
ref="system-chats"
:routes="['chats']"
class="page"
dont-update-when-changes-language
name="chats"
/>
</div>
</div>

<trial-period />
<modal
v-for="(modal, index) in modals"
:key="index"
v-on="modal.listeners"
v-bind="modal"
/>

<right-bar
v-for="rightBar in $store.state.RightBar.all"
:key="`right-bar-${rightBar.id}`"
:id="rightBar.id"
v-bind="rightBar.props"
v-on="rightBar.events"
/>

<trial-period />
</template>

<modal-registered
v-if="isModalCreatedProjectOpen"
@close="isModalCreatedProjectOpen = false"
/>
</div>
</template>

Expand All @@ -121,12 +126,13 @@ import { get } from 'lodash';
import getEnv from '@/utils/env';
import sendAllIframes from './utils/plugins/sendAllIframes';
import iframessa from 'iframessa';
import KnowUserModal from './components/KnowUserModal/Index.vue';
import RightBar from './components/common/RightBar/Index.vue';
import TrialPeriod from './modals/TrialPeriod.vue';
import { setUser } from '@sentry/browser';
import projects from './api/projects';
import WarningVerifyMail from './components/WarningVerifyMail.vue';
import PosRegister from './views/register/index.vue';
import ModalRegistered from './views/register/ModalRegistered.vue';

const favicons = {};

Expand All @@ -144,14 +150,17 @@ export default {
Modal,
WarningMaxActiveContacts,
ApiOptions,
KnowUserModal,
RightBar,
TrialPeriod,
WarningVerifyMail,
PosRegister,
ModalRegistered,
},

data() {
return {
isModalCreatedProjectOpen: false,

requestingLogout: false,
doingAthentication: false,
requestingProject: false,
Expand Down Expand Up @@ -181,6 +190,19 @@ export default {
modals: (state) => state.Modal.actives,
}),

firstAccessDataLoading() {
return (
this.$store.state.Account.additionalInformation.status === 'loading'
);
},

showPosRegister() {
return (
this.$store.state.Account.profile &&
!this.$store.state.Account.profile?.last_update_profile
);
},

unreadMessagesCompressed() {
if (this.unreadMessages > 9) {
return '9+';
Expand All @@ -207,6 +229,7 @@ export default {
loading() {
return (
this.accountLoading ||
this.firstAccessDataLoading ||
this.requestingLogout ||
this.doingAthentication ||
this.requestingProject ||
Expand Down Expand Up @@ -437,21 +460,6 @@ export default {

this.$store.dispatch('loadNews');

if (
this.$route.name === 'OrgsRequired' &&
this.accountProfile.last_update_profile
) {
// this.$router.push('/orgs');
} else if (
this.$route.name !== 'OrgsRequired' &&
!this.accountProfile.last_update_profile
) {
// this.$router.push({
// name: 'OrgsRequired',
// query: this.$route.query,
// });
}

iframessa.getter('userInfo', () => {
return {
first_name: this.accountProfile.first_name,
Expand Down Expand Up @@ -483,24 +491,7 @@ export default {
name,
email: this.accountProfile.email,
});
} else if (requiresAuth && this.accountProfile) {
if (
this.$route.name === 'OrgsRequired' &&
this.accountProfile.last_update_profile
) {
// this.$router.push('/orgs');
// return false;
} else if (
this.$route.name !== 'OrgsRequired' &&
!this.accountProfile.last_update_profile
) {
// this.$router.push({
// name: 'OrgsRequired',
// query: this.$route.query,
// });
// return false;
}
} else {
} else if (!(requiresAuth && this.accountProfile)) {
this.$store.state.Account.loading = false;
}
},
Expand Down
16 changes: 15 additions & 1 deletion src/store/account/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@ import account from '../../api/account';
import sendAllIframes from '../../utils/plugins/sendAllIframes';

export default {
async fetchProfile({ commit }) {
async fetchProfile({ commit, state }) {
commit('PROFILE_REQUEST');

try {
const response = await account.profile();

commit('PROFILE_SUCCESS', response.data);
commit('SET_ACCOUNT_LANGUAGE', response.data.language);

if (!response.data.last_update_profile) {
state.additionalInformation.status = 'loading';

account
.getCompanyInfo()
.then(({ data }) => {
state.additionalInformation.status = 'loaded';
state.additionalInformation.data = data;
})
.catch(() => {
state.additionalInformation.status = 'error';
});
}
} catch (e) {
commit('PROFILE_ERROR', e);
}
Expand Down
Loading