-
@@ -46,9 +83,17 @@ export default {
data(){
return {
user: null,
- enabled_bot: false,
+ configs: {
+ enabled: false,
+ loading: true,
+ checkins: {
+ enabled: false,
+ loading: true,
+ venues: {},
+ }
+ },
+ venue_search: '',
bot_enabled_spinner: '',
- enabled_auto_checki_in: false,
auto_check_in_enabled_spinner: '',
}
},
@@ -56,11 +101,22 @@ export default {
if(this.$auth.user?.user?.firstName){
this.user = this.$auth.user.user;
}
+
+ console.log('before mutlaq expierment')
+ this.$MFO_UTILS.setCheckInVenueInformation({id: 123})
console.log("mounted");
this.saveUser();
},
watch: {
- enabled_bot: async function(val, oldVal) {
+ venue_search: async function(val){
+ if(val.length != 0){
+ //console.log(val);
+ let venue_name = await this.$MFO_UTILS.searchVenues(val);
+ console.log(venue_name[0]?.name);
+ }
+
+ },
+ 'configs.enabled': async function(val, oldVal) {
this.bot_enabled_spinner = '';
console.log(val);
try {
@@ -71,7 +127,7 @@ export default {
this.bot_enabled_spinner = 'd-none';
},
- enabled_auto_checki_in: async function(val, oldVal) {
+ 'configs.checkins.enabled': async function(val, oldVal) {
this.auto_check_in_enabled_spinner = '';
console.log(val);
try {
@@ -83,7 +139,6 @@ export default {
this.auto_check_in_enabled_spinner = 'd-none';
}
},
-
methods: {
async saveUser() {
//console.log(this.$auth.strategy.token.get());
@@ -96,15 +151,15 @@ export default {
const userConfigs = await this.$MFO_UTILS.getConfigsFromFirebase();
if(userConfigs){
if(userConfigs?.enabled == true){
- this.enabled_bot = true;
+ this.configs.enabled = true;
}
- if(userConfigs?.settings?.auto_check_in?.enabled == true){
- this.enabled_auto_checki_in = true;
+ if(userConfigs?.settings?.checkins?.enabled == true){
+ this.configs.checkins.enabled = true;
}
- this.auto_check_in_enabled_spinner = 'd-none';
- this.bot_enabled_spinner = 'd-none';
+ this.configs.loading = false;
+ this.configs.checkins.loading = false;
}
console.log(userConfigs)
diff --git a/layouts/default.vue b/layouts/default.vue
index bfda147..ca2e4a4 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -1,7 +1,7 @@
-
+
@@ -9,10 +9,7 @@
diff --git a/pages/login.vue b/pages/login.vue
index 40333bd..608ab0b 100644
--- a/pages/login.vue
+++ b/pages/login.vue
@@ -19,7 +19,7 @@ export default {
async loginSwarm() {
console.log('before call');
await this.$auth.loginWith('social').catch(e => {
- console.log('hello')
+ console.log('hello error login')
})
},
},
diff --git a/utils/utils.js b/utils/utils.js
index 70b7883..dc21e21 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -1,4 +1,6 @@
// * with help of Alexander Lichter, Apr 18, 2020, https://blog.lichter.io/posts/nuxt-api-call-organization-and-decoupling/
+const axios = require('axios').default;
+
export default ($firebase, $auth) => () => ({
async createUserInFirebase() {
@@ -60,7 +62,7 @@ export default ($firebase, $auth) => () => ({
try {
const configsRef = $firebase.firestore.collection("configs").doc($auth.user.user.id);
await configsRef.update({settings: {
- auto_check_in: {
+ checkins: {
enabled: value
}
} });
@@ -69,6 +71,57 @@ export default ($firebase, $auth) => () => ({
console.log(error);
return false;
}
+ },
+
+ async searchVenues(name){
+ try {
+ let venues_result = await axios.get('https://api.foursquare.com/v3/places/search', {
+ params: {
+ near: 'Saudi Arabia',
+ query: name
+ },
+ headers:{
+ Authorization: 'fsq3mvJJUXXc2bwnfvTp3/YZfKabrAfiORz2rTyxJHTwEPQ='
+ }
+ });
+
+ if(venues_result.data.results.length > 0){
+ return venues_result.data.results;
+ }
+
+ return {};
+ } catch (error) {
+ console.log(error);
+ return false;
+ }
+
+
+
+ },
+
+ async setCheckInVenueInformation(venue_info){
+ try {
+ let venue_id = venue_info.id
+
+ let venue_settings = {
+ settings: {
+ checkins: {
+ venues: {}
+ }
+ }
+ };
+
+ venue_settings.settings.checkins.venues[venue_id] = {
+ id: 123
+ }
+
+ const configsRef = $firebase.firestore.collection("configs").doc($auth.user.user.id);
+ await configsRef.update(venue_settings);
+ return true;
+ } catch (error) {
+ console.log(error);
+ return false;
+ }
}