Browse Source

quick fix

Zander Cuz 3 years ago
parent
commit
c6ed3cf20c

+ 2
- 2
screens/auth/RegisterScreen.js View File

13
             username: '',
13
             username: '',
14
             email: '',
14
             email: '',
15
             password: '',
15
             password: '',
16
-            interpreter: '',
16
+            interpreter: false,
17
         };
17
         };
18
         this.onRegister = this.onRegister.bind(this)
18
         this.onRegister = this.onRegister.bind(this)
19
     };
19
     };
23
         firebase.auth().createUserWithEmailAndPassword(email, password)
23
         firebase.auth().createUserWithEmailAndPassword(email, password)
24
             .then((result) => {
24
             .then((result) => {
25
                 if (interpreter) {
25
                 if (interpreter) {
26
-                    firebase.firestore().collection("Interprete")
26
+                    firebase.firestore().collection("Interpreters")
27
                         .doc(firebase.auth().currentUser.uid)
27
                         .doc(firebase.auth().currentUser.uid)
28
                         .set({
28
                         .set({
29
                             username,
29
                             username,

+ 134
- 0
screens/main/AvailabilityScreen.js View File

1
+import React, { Component } from "react";
2
+import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground, Image, View, Text, Button } from "react-native";
3
+import firebase from "firebase";
4
+import { Calendar } from "react-native-calendars";
5
+import { ScrollView } from "react-native-gesture-handler";
6
+import SectionedMultiSelect from 'react-native-sectioned-multi-select';
7
+import Icon from 'react-native-vector-icons/MaterialIcons';
8
+import { connect } from 'react-redux';
9
+import { bindActionCreators } from 'redux';
10
+
11
+import { fetchUser } from "../../redux/actions";
12
+import { styles } from "../../config/styles";
13
+import { availability } from "../../config/availability";
14
+
15
+export class AvailabilityScreen extends Component {
16
+    constructor(props) {
17
+        super(props);
18
+        this.state = {
19
+            english: false,
20
+            spanish: false,
21
+            virtual: false,
22
+            face_to_face: false,
23
+            personal: false,
24
+            group: false,
25
+            cities: [],
26
+            selectedItems: [],
27
+            markedDates: {}
28
+        };
29
+        this.onSelectedItemsChange = this.onSelectedItemsChange.bind(this);
30
+        this.onDaySelect = this.onDaySelect.bind(this);
31
+        this.onSave = this.onSave.bind(this);
32
+        this.handleUpdate = this.handleUpdate.bind(this);
33
+    };
34
+
35
+    componentDidMount(){
36
+        this.props.fetchUser();
37
+        this.forceUpdate(() => {this.handleUpdate()})
38
+    };
39
+
40
+    handleUpdate(){
41
+        const { currentUser } = this.props;
42
+        if (currentUser != undefined){
43
+            if (currentUser.hasOwnProperty('selectedItems') && currentUser.hasOwnProperty('markedDates'))
44
+            this.setState( {selectedItems: currentUser.selectedItems});
45
+            this.setState( {markedDates: currentUser.markedDates});
46
+        }    
47
+    };
48
+
49
+    onSave(){
50
+        const { selectedItems } = this.state;
51
+    
52
+        selectedItems.forEach((value) => {
53
+            if(value === 'English'){
54
+                this.setState({english : true}, () => firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).set({english : true}, {merge : true}));
55
+            }
56
+            else if(value === 'Spanish'){
57
+                this.setState({spanish : true}, () => firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).set({spanish : true}, {merge : true}));
58
+            }
59
+            else if(value === 'Virtual'){
60
+                this.setState({virtual : true}, () => firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).set({virtual : true}, {merge : true}));
61
+            }
62
+            else if(value === 'Face-to-Face'){
63
+                this.setState({face_to_face : true}, () => firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).set({face_to_face : true}, {merge : true}));
64
+            }
65
+            else if(value === 'Personal Session'){
66
+                this.setState({personal : true}, () => firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).set({personal : true}, {merge : true}));
67
+            }
68
+            else if(value === 'Group Session'){
69
+                this.setState({group : true}, () => firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).set({group : true}, {merge : true}));
70
+            }
71
+            else if(!isNaN(value.charAt(0))){
72
+                for (let key in this.state.markedDates) {
73
+                    if(this.state.markedDates[key].hasOwnProperty('timeSlot')){
74
+                        this.state.markedDates[key].timeSlot.push(value);
75
+                    }
76
+                    else{
77
+                        this.state.markedDates[key].timeSlot = [];
78
+                        this.state.markedDates[key].timeSlot.push(value);
79
+                    }
80
+                }
81
+            }
82
+            else{
83
+                this.state.cities.push(value);
84
+            }
85
+        })
86
+        firebase.firestore().collection('Interpreters')
87
+            .doc(firebase.auth().currentUser.uid)
88
+            .set(this.state, {merge : true})
89
+            .then(() => {this.props.navigation.goBack()});
90
+    };
91
+
92
+    onSelectedItemsChange = (selectedItems) => {
93
+        this.setState({selectedItems});
94
+    };
95
+
96
+    onDaySelect = (day) => {
97
+        const selectedDay = day.dateString;
98
+        let selected = true;
99
+
100
+        if (this.state.markedDates[selectedDay]) {
101
+            selected = !this.state.markedDates[selectedDay].selected;
102
+        }
103
+        const updatedMarkedDates = {...this.state.markedDates, ...{ [selectedDay]: { selected } } }
104
+        this.setState({ markedDates : updatedMarkedDates });
105
+    };
106
+
107
+    render() {
108
+        return (
109
+            <ScrollView contentContainerstyle={styles.stdcontainer}>
110
+                <Calendar
111
+                    onDayPress={this.onDaySelect}
112
+                    style={styles.calendar}
113
+                    markedDates={this.state.markedDates}
114
+                    theme={{selectedDayBackgroundColor: 'green'}}
115
+                />
116
+                <SectionedMultiSelect 
117
+                    items={availability}
118
+                    IconRenderer={Icon}
119
+                    readOnlyHeadings={true}
120
+                    uniqueKey='name'
121
+                    subKey='children'
122
+                    selectText='Choose your availability...'
123
+                    onSelectedItemsChange={this.onSelectedItemsChange}
124
+                    selectedItems={this.state.selectedItems}
125
+                />
126
+                <Button title='Save' onPress={() => {this.onSave()}}/>
127
+            </ScrollView>
128
+        );
129
+    }
130
+}
131
+
132
+const mapStateProps = (store) => ({currentUser : store.userState.currentUser})
133
+const mapDispatchProps = (dispatch) => bindActionCreators({fetchUser}, dispatch)
134
+export default connect(mapStateProps, mapDispatchProps)(AvailabilityScreen)

+ 3
- 3
screens/main/Home_page.js View File

56
     const user_email = firebase.auth().currentUser.email;
56
     const user_email = firebase.auth().currentUser.email;
57
 
57
 
58
   const Iuser_data = firebase.firestore()
58
   const Iuser_data = firebase.firestore()
59
-  .collection('Interprete')
59
+  .collection('Interpreters')
60
   .where("email", "==", user_email)
60
   .where("email", "==", user_email)
61
   .onSnapshot(snapShot => {
61
   .onSnapshot(snapShot => {
62
     const user = snapShot.docs.map(docSnap => {
62
     const user = snapShot.docs.map(docSnap => {
156
   function check_user_type_INT(){ 
156
   function check_user_type_INT(){ 
157
 
157
 
158
     firebase.firestore()
158
     firebase.firestore()
159
-    .collection("Interprete")
159
+    .collection("Interpreters")
160
     .doc(firebase.auth().currentUser.uid)
160
     .doc(firebase.auth().currentUser.uid)
161
     .get()
161
     .get()
162
     .then((snapshot) => {
162
     .then((snapshot) => {
412
     });
412
     });
413
   }
413
   }
414
 
414
 
415
-  firebase.firestore().collection('Interprete').doc(firebase.auth().currentUser.uid).update({'push_token': token})
415
+  firebase.firestore().collection('Interpreters').doc(firebase.auth().currentUser.uid).update({'push_token': token})
416
   firebase.firestore().collection('Users').doc(firebase.auth().currentUser.uid).update({'push_token': token})
416
   firebase.firestore().collection('Users').doc(firebase.auth().currentUser.uid).update({'push_token': token})
417
 
417
 
418
   return token;
418
   return token;

+ 8
- 8
screens/main/Search.js View File

106
     
106
     
107
 
107
 
108
     const db = firebase.firestore()
108
     const db = firebase.firestore()
109
-    var query = db.collection('Interprete')
109
+    var query = db.collection('Interpreters')
110
     
110
     
111
     for (let i = 0; i < tags.length; i++) {
111
     for (let i = 0; i < tags.length; i++) {
112
 
112
 
116
       //check which tags where called in the search 
116
       //check which tags where called in the search 
117
       if (tags[i].id === 'PL') {
117
       if (tags[i].id === 'PL') {
118
         console.log('Presencial')
118
         console.log('Presencial')
119
-        query = query.where('Modalidad.Presencial', '==', true)
119
+        query = query.where('face_to_face', '==', true)
120
         mapflag = true
120
         mapflag = true
121
       }
121
       }
122
       if (tags[i].id == 'ON') {
122
       if (tags[i].id == 'ON') {
123
-        query = query.where('Modalidad.Online', '==', true)
123
+        query = query.where('virtual', '==', true)
124
       }
124
       }
125
       if (tags[i].id == 'IL') {
125
       if (tags[i].id == 'IL') {
126
-        query = query.where('Cantidad.Individual', '==', true)
126
+        query = query.where('personal', '==', true)
127
       }
127
       }
128
       if (tags[i].id == 'GL') {
128
       if (tags[i].id == 'GL') {
129
-        query = query.where('Cantidad.Grupal', '==', true)
129
+        query = query.where('group', '==', true)
130
       }
130
       }
131
       if (tags[i].id == 'ESP') {
131
       if (tags[i].id == 'ESP') {
132
-        query = query.where('Lenguaje.Esp', '==', true)
132
+        query = query.where('spanish', '==', true)
133
       }
133
       }
134
       if (tags[i].id == 'ING') {
134
       if (tags[i].id == 'ING') {
135
-        query = query.where('Lenguaje.Ing', '==', true)
135
+        query = query.where('english', '==', true)
136
       }
136
       }
137
   }
137
   }
138
   for(let i = 0; i < days.length; i++) {
138
   for(let i = 0; i < days.length; i++) {
252
           <View>
252
           <View>
253
             <View style={{ flexDirection: "row", paddingBottom: 20, paddingTop: 20,  justifyContent: "space-between" }}>
253
             <View style={{ flexDirection: "row", paddingBottom: 20, paddingTop: 20,  justifyContent: "space-between" }}>
254
               <Text>{item.data.username}</Text>
254
               <Text>{item.data.username}</Text>
255
-              <Text>{item.data.Precio}</Text>
255
+              <Text>{item.data.precio}</Text>
256
               <Button title='Buscar' onPress={() => { dothing(item.id, item.data.push_token, u_token, item.data.username) }}/>
256
               <Button title='Buscar' onPress={() => { dothing(item.id, item.data.push_token, u_token, item.data.username) }}/>
257
             </View>
257
             </View>
258
             <View style={{ borderBottomColor: 'black', borderBottomWidth: 1 }} />
258
             <View style={{ borderBottomColor: 'black', borderBottomWidth: 1 }} />