From f772f827992cc6b5781e92cb440af888afabdf93 Mon Sep 17 00:00:00 2001 From: Bharat Agarwal Date: Sat, 27 Mar 2021 16:12:22 +0530 Subject: [PATCH 1/8] circle ci node version fixed --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ae176e..eefa7dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build-job: docker: # specify the version you desire here - - image: circleci/node:10.15.2 + - image: circleci/node:12.4 # Specify service dependencies here if necessary # CircleCI maintains a library of pre-built images @@ -36,7 +36,7 @@ jobs: deploy-job: docker: - - image: circleci/node:10.15.2 + - image: circleci/node:12.4 working_directory: ~/repo steps: - restore_cache: From f3cba4344a122d47f862e6f56eeedccb396aae48 Mon Sep 17 00:00:00 2001 From: Bharat Agarwal Date: Sat, 27 Mar 2021 17:37:08 +0530 Subject: [PATCH 2/8] onboard user first logic --- src/components/Core/Views.vue | 4 +- src/router/index.js | 87 ++++++++++++++++++++-------------- src/services/onboardService.js | 45 ++++++++++++++++++ src/views/TeamOnboard.vue | 86 +++++++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 38 deletions(-) create mode 100644 src/services/onboardService.js create mode 100644 src/views/TeamOnboard.vue diff --git a/src/components/Core/Views.vue b/src/components/Core/Views.vue index 228f9c7..ec92739 100644 --- a/src/components/Core/Views.vue +++ b/src/components/Core/Views.vue @@ -1,11 +1,11 @@ + + \ No newline at end of file From b73227fd3b9844b02dd4fbcec8d5517dd66ee47e Mon Sep 17 00:00:00 2001 From: Bharat Agarwal Date: Sat, 27 Mar 2021 18:59:47 +0530 Subject: [PATCH 3/8] add user in team management changed [Remove functions dependency] --- src/components/Users/addUser.vue | 216 ++++++++++++++++++------------- src/services/UsersServices.js | 31 +++-- src/services/onboardService.js | 7 + src/views/About.vue | 4 +- src/views/TeamOnboard.vue | 49 +++++-- 5 files changed, 198 insertions(+), 109 deletions(-) diff --git a/src/components/Users/addUser.vue b/src/components/Users/addUser.vue index 1354eb5..67c4663 100644 --- a/src/components/Users/addUser.vue +++ b/src/components/Users/addUser.vue @@ -2,15 +2,18 @@
Add User + >Add User @@ -31,55 +34,73 @@ {{ item.name }} - (+{{ selectedUser.length - 1 }} others) + (+{{ selectedUser.length - 1 }} others) - +
- - - Status - - - + + + Status + + + -

{{ output.data.msg }}

-

- {{ output.data.emailstatus.msg }} + {{ output }} + - - - + + + - + - -

- Close - -
-
+ +
+ Close +
+
+
@@ -95,7 +116,8 @@ @click="addUser" depressed :loading="loading" - >Add + >Add
@@ -103,74 +125,90 @@ diff --git a/src/services/UsersServices.js b/src/services/UsersServices.js index 7d5a814..1a81bc0 100644 --- a/src/services/UsersServices.js +++ b/src/services/UsersServices.js @@ -1,28 +1,39 @@ import firebase from '@/config/firebase' let usersServices = { + addUser: (data) => new Promise((resolve, reject) => { + firebase.firestore.collection("teamOnboard").doc(data.id).set({ + email: data.email, + userType: data.userType, + id: data.id, + }).then(res => { + resolve({success: true, message: "User Added Success"}); + }).catch(e=>{ + reject(e); + }); + }), + getCurrentUserDetails: () => { let uid = '' return new Promise((resolve, reject) => { - uid = firebase.auth.currentUser.uid + uid = firebase.auth.currentUser.uid; firebase.firestore.collection('team').where("uid", "==", uid).get().then(docs => { - // console.log(docs) docs.forEach(doc => { resolve({ success: true, data: doc.data(), uid: uid - }) - }) + }); + }); }).catch(e => { reject({ success: false, msg: e - }) + }); // console.log(e) - }) - }) + }); + }); }, getUserRole: () => { @@ -133,14 +144,14 @@ let usersServices = { }); }) }, - removeUser: (uid, name,communityName, communityEmail) => { + removeUser: (uid, name, communityName, communityEmail) => { return new Promise((resolve, reject) => { let appp = firebase.functions.httpsCallable('team-removeAuth') appp({ uid: uid, name: name, - communityName:communityName, - communityEmail:communityEmail + communityName: communityName, + communityEmail: communityEmail }).then(res => { resolve(res.data) }).catch(e => { diff --git a/src/services/onboardService.js b/src/services/onboardService.js index 1ca4238..7a571c8 100644 --- a/src/services/onboardService.js +++ b/src/services/onboardService.js @@ -39,6 +39,13 @@ let teamOnboard = { }).catch(e => { reject(e); }); + }), + updateTeamWithUID: (uid, id) => new Promise((resolve, reject) => { + firebase.firestore.collection("team").doc(id).update({uid}).then(res=>{ + resolve({success: true}); + }).catch(e=>{ + reject(e); + }); }) }; diff --git a/src/views/About.vue b/src/views/About.vue index 7e3f502..68dedd7 100644 --- a/src/views/About.vue +++ b/src/views/About.vue @@ -52,7 +52,7 @@ export default { { name: "Vrijraj Singh", photo: - "https://unavatar.now.sh/twitter/VrijrajSingh", + "https://avatars.githubusercontent.com/u/10599101", links: { github: "https://github.com/vrijraj/", linkedin: "https://www.linkedin.com/in/vrijraj/", @@ -62,7 +62,7 @@ export default { { name: "Bharat Agarwal", photo: - "https://unavatar.now.sh/twitter/bharatagsrwal", + "https://avatars.githubusercontent.com/u/43988371", links: { github: "https://github.com/bharatagsrwal/", linkedin: "https://www.linkedin.com/in/bharatagsrwal/", diff --git a/src/views/TeamOnboard.vue b/src/views/TeamOnboard.vue index 2701151..214bdb5 100644 --- a/src/views/TeamOnboard.vue +++ b/src/views/TeamOnboard.vue @@ -25,10 +25,25 @@ >Onboard - - {{error}} + + {{ error }} + + + + Success + + Your account is created + + + + + + Okay + + + @@ -39,6 +54,7 @@ export default { name: "teamonboard", data: () => ({ loading: false, + successDialog: false, isVisible: false, error: "", finalUser: {}, @@ -46,7 +62,7 @@ export default { password: "", }, }), - beforeMount() { + mounted() { teamOnboardService .getUserById(this.$route.params.id) .then((result) => { @@ -56,7 +72,7 @@ export default { this.isVisible = true; }) .catch((e) => { - this.isVisible = false + this.isVisible = false; this.error = e.message; console.log(e); }); @@ -65,19 +81,36 @@ export default { async onBoardUser() { this.loading = true; try { - const deleteData = await teamOnboardService.deleteTempUse(this.$route.params.id); + const deleteData = await teamOnboardService.deleteTempUse( + this.$route.params.id + ); if (!deleteData.success) throw { message: "Something went wrong" }; - const firebaseUser = await firebase.auth.createUserWithEmailAndPassword(this.finalUser.email, this.userData.password); + const firebaseUser = await firebase.auth.createUserWithEmailAndPassword( + this.finalUser.email, + this.userData.password + ); await firebase.auth.signOut(); const data = { uid: firebaseUser.user.uid, ...this.finalUser }; - const userAdd = await teamOnboardService.addOnBoardUserToUserManagement(data); + const userAdd = await teamOnboardService.addOnBoardUserToUserManagement( + data + ); + const updateTeamFields = await teamOnboardService.updateTeamWithUID( + data.uid, + data.id + ); + if (!updateTeamFields.success) throw updateTeamFields; this.loading = true; - this.$router.replace("/login"); + this.successDialog = true; } catch (e) { console.log(e); this.loading = false; } }, + + dialogOkay() { + this.successDialog = false; + this.$router.replace("/login"); + }, }, }; From 467ad947fdfeea9b8b444acba3eb8f8c91e105b3 Mon Sep 17 00:00:00 2001 From: Bharat Agarwal Date: Sat, 27 Mar 2021 22:11:44 +0530 Subject: [PATCH 4/8] firebase firestore and storage rules --- firebase-rules/firestore.indexes.json | 4 +++ firebase-rules/firestore.rules | 48 +++++++++++++++++++++++++++ firebase-rules/storage.rules | 8 +++++ firebase.json | 19 +++++++---- src/services/UsersServices.js | 7 ++-- 5 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 firebase-rules/firestore.indexes.json create mode 100644 firebase-rules/firestore.rules create mode 100644 firebase-rules/storage.rules diff --git a/firebase-rules/firestore.indexes.json b/firebase-rules/firestore.indexes.json new file mode 100644 index 0000000..415027e --- /dev/null +++ b/firebase-rules/firestore.indexes.json @@ -0,0 +1,4 @@ +{ + "indexes": [], + "fieldOverrides": [] +} diff --git a/firebase-rules/firestore.rules b/firebase-rules/firestore.rules new file mode 100644 index 0000000..c7c9268 --- /dev/null +++ b/firebase-rules/firestore.rules @@ -0,0 +1,48 @@ +rules_version = '2'; +service cloud.firestore { + match /databases/{database}/documents { + + // This rule allows anyone on the internet to view, edit, and delete + // all data in your Firestore database. It is useful for getting + // started, but it is configured to expire after 30 days because it + // leaves your app open to attackers. At that time, all client + // requests to your Firestore database will be denied. + // + // Make sure to write security rules for your app before that time, or else + // your app will lose access to your Firestore database + match /apiEnd/{apiEndpoint}{ + allow create : if true; + allow read : if request.auth.uid != null; + allow delete : if request.auth.uid != null; + allow update : if request.auth.uid != null; + allow list: if request.auth.uid != null; + } + match /teamOnboard/{doc}{ + allow create : if true; + allow read : if true; + allow delete : if true; + allow update : if true; + allow list: if true; + } + match /users/{database}{ + allow create : if true; + allow read : if true; + allow delete : if request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userType == "Super Admin"; + allow update : if request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userType == "Super Admin"; + allow list: if true; + } + match /team/{database}{ + allow create : if request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userType == "Super Admin"; + allow read : if true; + allow delete : if request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userType == "Super Admin"; + allow update : if true; + allow list: if true; + } + match /{document=**} { + allow read : if true; + allow delete : if request.auth.uid != null && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userType == "Super Admin"; + allow create : if request.auth.uid != null; + allow update : if request.auth.uid != null; + } + } +} \ No newline at end of file diff --git a/firebase-rules/storage.rules b/firebase-rules/storage.rules new file mode 100644 index 0000000..4eda34f --- /dev/null +++ b/firebase-rules/storage.rules @@ -0,0 +1,8 @@ +rules_version = '2'; +service firebase.storage { + match /b/{bucket}/o { + match /{allPaths=**} { + allow read, write: if request.auth!=null; + } + } +} diff --git a/firebase.json b/firebase.json index 0004f4f..c53f174 100644 --- a/firebase.json +++ b/firebase.json @@ -7,11 +7,16 @@ "**/.*", "**/node_modules/**" ], - "rewrites": [ - { - "source": "**", - "destination": "/index.html" - } - ] + "rewrites": [{ + "source": "**", + "destination": "/index.html" + }] + }, + "firestore": { + "rules": "firebase-rules/firestore.rules", + "indexes": "firebase-rules/firestore.indexes.json" + }, + "storage": { + "rules": "firebase-rules/storage.rules" } -} +} \ No newline at end of file diff --git a/src/services/UsersServices.js b/src/services/UsersServices.js index 1a81bc0..70ec030 100644 --- a/src/services/UsersServices.js +++ b/src/services/UsersServices.js @@ -7,8 +7,11 @@ let usersServices = { userType: data.userType, id: data.id, }).then(res => { - resolve({success: true, message: "User Added Success"}); - }).catch(e=>{ + resolve({ + success: true, + message: "User Added Success" + }); + }).catch(e => { reject(e); }); }), From 31e7d6a5b18404db1ae32cb8b511cd87f7db852a Mon Sep 17 00:00:00 2001 From: Bharat Agarwal Date: Sat, 27 Mar 2021 23:17:39 +0530 Subject: [PATCH 5/8] user management changed to no functions --- src/App.vue | 101 ++++++---- src/components/Users/DeleteUser.vue | 100 +++++++--- src/main.js | 12 +- src/services/TeamServices.js | 2 +- src/services/UsersServices.js | 278 +++++++++++++--------------- src/views/TeamOnboard.vue | 8 +- src/views/Users.vue | 23 ++- 7 files changed, 296 insertions(+), 228 deletions(-) diff --git a/src/App.vue b/src/App.vue index b3b5650..1f79594 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,14 +19,15 @@ - - - + + + - + @@ -43,11 +44,10 @@ diff --git a/src/components/Users/DeleteUser.vue b/src/components/Users/DeleteUser.vue index d93ceac..6528692 100644 --- a/src/components/Users/DeleteUser.vue +++ b/src/components/Users/DeleteUser.vue @@ -3,7 +3,17 @@ diff --git a/src/main.js b/src/main.js index bdb6937..456974b 100644 --- a/src/main.js +++ b/src/main.js @@ -5,12 +5,12 @@ import router from './router' import store from './store' import vuetify from './plugins/vuetify'; import firebase from './config/firebase' -import './style.css' -import VueChatScroll from 'vue-chat-scroll' +import './style.css'; +import VueChatScroll from 'vue-chat-scroll'; -Vue.config.productionTip = false +Vue.config.productionTip = false; -Vue.use(VueChatScroll) +Vue.use(VueChatScroll); firebase.auth.onAuthStateChanged(()=>{ new Vue({ @@ -18,5 +18,5 @@ firebase.auth.onAuthStateChanged(()=>{ store, vuetify, render: h => h(App) - }).$mount('#app') -}) + }).$mount('#app'); +}); diff --git a/src/services/TeamServices.js b/src/services/TeamServices.js index 80b8c0b..58d9592 100644 --- a/src/services/TeamServices.js +++ b/src/services/TeamServices.js @@ -110,7 +110,7 @@ let teamServices = { .delete() .then(() => { if(teamInfo.uid && teamInfo.uid.length>0){ - UserService.removeUser(teamInfo.uid, teamInfo.name).then(res=>{ + UserService.removeUser(teamInfo.uid).then(res=>{ resolve({ success:true, msg:'Team Member Removed Successfully', diff --git a/src/services/UsersServices.js b/src/services/UsersServices.js index 70ec030..929e919 100644 --- a/src/services/UsersServices.js +++ b/src/services/UsersServices.js @@ -1,4 +1,4 @@ -import firebase from '@/config/firebase' +import firebase from '@/config/firebase'; let usersServices = { addUser: (data) => new Promise((resolve, reject) => { @@ -16,174 +16,156 @@ let usersServices = { }); }), - getCurrentUserDetails: () => { - let uid = '' - return new Promise((resolve, reject) => { - uid = firebase.auth.currentUser.uid; - - firebase.firestore.collection('team').where("uid", "==", uid).get().then(docs => { - docs.forEach(doc => { - resolve({ - success: true, - data: doc.data(), - uid: uid - }); - }); - }).catch(e => { - reject({ - success: false, - msg: e + getCurrentUserDetails: () => new Promise((resolve, reject) => { + const uid = firebase.auth.currentUser.uid; + firebase.firestore.collection('team').where("uid", "==", uid).get().then(docs => { + docs.forEach(doc => { + resolve({ + success: true, + data: doc.data(), + uid: uid }); - // console.log(e) }); + }).catch(e => { + reject({ + success: false, + msg: e + }); + // console.log(e) }); - }, + }), - getUserRole: () => { - let uid = '' - return new Promise((resolve, reject) => { - uid = firebase.auth.currentUser.uid + getUserRole: () => new Promise((resolve, reject) => { + const uid = firebase.auth.currentUser.uid; + firebase.firestore.collection('users').doc(uid).get().then(docs => { + // console.log(docs) + resolve({ + success: true, + data: docs.data(), + exists: docs.exists + }); + }).catch(e => { + reject({ + success: false, + msg: e + }); + // console.log(e) + }); + }), + updateUser: (docid, userType) => new Promise((resolve, reject) => { + firebase.firestore.collection('users').doc(docid).update({ + userType: userType + }).then(() => { + // console.log(docs) + resolve({ + success: true, + msg: "User role updated" + }); + }).catch(e => { + reject({ + success: false, + msg: e + }); + }); + }), - firebase.firestore.collection('users').doc(uid).get().then(docs => { - // console.log(docs) - resolve({ - success: true, - data: docs.data(), - exists: docs.exists - }) - }).catch(e => { - reject({ - success: false, - msg: e - }) - // console.log(e) - }) - }) - }, - updateUser: (docid, userType) => { - return new Promise((resolve, reject) => { - firebase.firestore.collection('users').doc(docid).update({ - userType: userType - }).then(() => { - // console.log(docs) + updateUserPassword: (currentPassword, newPassword) => new Promise((resolve, reject) => { + var user = firebase.auth.currentUser; + var cred = firebase.authw.EmailAuthProvider.credential( + user.email, currentPassword); + user.reauthenticateWithCredential(cred).then(() => { + var user = firebase.auth.currentUser; + user.updatePassword(newPassword).then(() => { + // console.log("Password updated!"); resolve({ success: true, - msg: "User role updated" - }) - }).catch(e => { + msg: "Password updated!" + }); + }).catch((e) => { reject({ success: false, msg: e + }); + }); + }).catch((error) => { + reject({ + success: false, + msg: error + }); + }); + }), + + getAllUsers: () => new Promise((resolve, reject) => { + let users = []; + let teams = []; + let finaldata = []; + firebase.firestore + .collection("users") + .get() + .then(async (snapshot) => { + await snapshot.forEach(doc => { + users.push(doc.data()) }) - }) - }) - }, - updateUserPassword: (currentPassword, newPassword) => { - return new Promise((resolve, reject) => { - var user = firebase.auth.currentUser; - var cred = firebase.authw.EmailAuthProvider.credential( - user.email, currentPassword); - user.reauthenticateWithCredential(cred).then(() => { - var user = firebase.auth.currentUser; - user.updatePassword(newPassword).then(() => { - // console.log("Password updated!"); - resolve({ - success: true, - msg: "Password updated!" + await firebase.firestore.collection('team').get().then(docs => { + docs.forEach(teamdoc => { + teams.push(teamdoc.data()) }); - }).catch((e) => { - // console.log(e); - reject({ - success: false, - msg: e + }); + let asd = await users.map(user => { + teams.map(team => { + if (user.uid == team.uid) { + let fobj = { + ...team, + ...user + }; + finaldata.push(fobj); + } }); }); - }).catch((error) => { - reject({ - success: false, - msg: error + + resolve({ + success: true, + data: finaldata }); + }) + .catch(err => { + reject(err); }); - }); - }, + }), - getAllUsers: () => { - let users = [] - let teams = [] - let finaldata = [] - // console.log('calling') - return new Promise((resolve, reject) => { - firebase.firestore - .collection("users") - .get() - .then(async (snapshot) => { - await snapshot.forEach(doc => { - users.push(doc.data()) - }) - await firebase.firestore.collection('team').get().then(docs => { - docs.forEach(teamdoc => { - teams.push(teamdoc.data()) - }) - }) - let asd = await users.map(user => { - teams.map(team => { - if (user.uid == team.uid) { - let fobj = { - ...team, - ...user - } - finaldata.push(fobj) - } - }) - }) + removeUser: (uid) => new Promise((resolve, reject) => { + firebase.firestore.collection("users").doc(uid).delete().then(res => { + resolve({ + success: true + }); + }).catch(e => { + reject(e); + }); + }), - resolve({ - success: true, - data: finaldata - }) - }) - .catch(err => { - reject(err) - }); - }) - }, - removeUser: (uid, name, communityName, communityEmail) => { - return new Promise((resolve, reject) => { - let appp = firebase.functions.httpsCallable('team-removeAuth') - appp({ - uid: uid, - name: name, - communityName: communityName, - communityEmail: communityEmail - }).then(res => { - resolve(res.data) - }).catch(e => { - reject(e) - }) - }) - }, - enableUser: (uid) => { - return new Promise((resolve, reject) => { - let appp = firebase.functions.httpsCallable('team-enabledAuth') - appp(uid).then(res => { - resolve(res.data) - }).catch(e => { - // console.log(e) - reject(e) - }) + enableUser: (uid) => new Promise((resolve, reject) => { + firebase.firestore.collection('users').doc(uid).update({ + disabled: false + }).then(res => { + resolve({ + success: true + }); + }).catch(e => { + reject(e); }); - }, - disableUser: (uid) => { - return new Promise((resolve, reject) => { - let appp = firebase.functions.httpsCallable('team-disabledAuth'); - appp(uid).then(res => { - resolve(res.data); - }).catch(e => { - // console.log(e); - reject(e); + }), + + disableUser: (uid) => new Promise((resolve, reject) => { + firebase.firestore.collection('users').doc(uid).update({ + disabled: true + }).then(res => { + resolve({ + success: true }); + }).catch(e => { + reject(e); }); - } + }), }; export default usersServices; \ No newline at end of file diff --git a/src/views/TeamOnboard.vue b/src/views/TeamOnboard.vue index 214bdb5..d21efa7 100644 --- a/src/views/TeamOnboard.vue +++ b/src/views/TeamOnboard.vue @@ -81,15 +81,15 @@ export default { async onBoardUser() { this.loading = true; try { - const deleteData = await teamOnboardService.deleteTempUse( - this.$route.params.id - ); - if (!deleteData.success) throw { message: "Something went wrong" }; const firebaseUser = await firebase.auth.createUserWithEmailAndPassword( this.finalUser.email, this.userData.password ); await firebase.auth.signOut(); + const deleteData = await teamOnboardService.deleteTempUse( + this.$route.params.id + ); + if (!deleteData.success) throw { message: "Something went wrong" }; const data = { uid: firebaseUser.user.uid, ...this.finalUser }; const userAdd = await teamOnboardService.addOnBoardUserToUserManagement( data diff --git a/src/views/Users.vue b/src/views/Users.vue index 0fc3009..36a25c0 100644 --- a/src/views/Users.vue +++ b/src/views/Users.vue @@ -1,5 +1,5 @@ + + + + + + + + + + + + + diff --git a/src/services/UsersServices.js b/src/services/UsersServices.js index b70996f..2ec8cc6 100644 --- a/src/services/UsersServices.js +++ b/src/services/UsersServices.js @@ -128,6 +128,29 @@ let usersServices = { }); }), + // Get All Pending Users Info + + getAllPendingUsers: () => new Promise((resolve, reject) => { + let users = []; + firebase.firestore + .collection("teamOnboard") + .get() + .then(async (snapshot) => { + await snapshot.forEach(doc => { + users.push(doc.data()) + }) + + resolve({ + success: true, + data: users + }); + }) + .catch(err => { + reject(err); + }); + }), + + removeUser: (uid) => new Promise((resolve, reject) => { firebase.firestore.collection("users").doc(uid).delete().then(res => { resolve({ diff --git a/src/views/Users.vue b/src/views/Users.vue index 8a871af..bd4ef1b 100644 --- a/src/views/Users.vue +++ b/src/views/Users.vue @@ -9,6 +9,7 @@ @@ -67,277 +68,39 @@ @showSuccess="showSnakeBar" @failed="showFailedSnakeBar" /> + + + - - -
- -
+ + + + + +
- - - - - - - - - - - - - +
- -
-
+ + + + + +
+ +
+
+
@@ -366,12 +129,13 @@ export default { name: "TeamView", inject: ["theme"], components: { + UsersDataLayout: ()=> import("@/components/Users/UsersDataLayout"), + PendingUsersDataLayout: ()=> import("@/components/Users/PendingUsersData"), Snakebar: () => import("@/components/Common/Snakebar"), AddUser: () => import("@/components/Users/addUser"), - DeleteUser: () => import("@/components/Users/DeleteUser"), - EditUser: () => import("@/components/Users/editUser"), }, data: () => ({ + userModel:'onboardedUsers', dataView: 0, isSearch: false, search: "", @@ -379,17 +143,11 @@ export default { isSnakeBarVisible: false, snakeBarColor: "green", snakeBarTimeOut: 5000, - isLoading: false, + showDialog: false, usersData: [], - headers: [ - { text: "User Name", value: "name", width: "20%" }, - // { text: 'Email', value: 'email' }, - { text: "Role", value: "role" }, - { text: "User Type", value: "userType" }, - { text: "User Status", value: "disabled", sortable: true }, - { text: "Actions", value: "actions", sortable: false }, - ], + pendingUsersData:[] + }), computed: { ...mapState(["role"]) }, beforeMount() { @@ -420,10 +178,10 @@ export default { this.isSnakeBarVisible = true; this.showData(); }, - showData() { + async showData() { this.usersData = []; this.isLoading = true; - UsersServices.getAllUsers() + await UsersServices.getAllUsers() .then((res) => { this.usersData = res.data; this.isLoading = false; @@ -432,34 +190,14 @@ export default { this.isLoading = false; console.log("Error getting documents", e); }); - }, - gotoTeamDetails(id) { - this.$router.push("/team/" + id); - }, - disableUser(uid) { - this.showDialog = true; - UsersServices.disableUser(uid) - .then((res) => { - this.showDialog = false; - this.showSnakeBar("User Disabled"); - }) - .catch((e) => { - this.showDialog = false; - console.log(e); - }); - }, - enableUser(uid) { - this.showDialog = true; - UsersServices.enableUser(uid) - .then((res) => { - this.showDialog = false; - this.showSnakeBar("User Enabled"); - }) - .catch((e) => { - this.showDialog = false; - console.log(e); - }); - }, + + await UsersServices.getAllPendingUsers().then(res=>{ + if(res.success){ + this.pendingUsersData = res.data + } + }) + }, + }, };