Browse Source

single city

Zander Cuz 2 years ago
parent
commit
43c3a4af4a
2 changed files with 98 additions and 324 deletions
  1. 1
    319
      config/availability.js
  2. 97
    5
      screens/main/AvailabilityScreen.js

+ 1
- 319
config/availability.js View File

@@ -1,323 +1,5 @@
1 1
 export const availability = [
2
-    {
3
-        name: 'Cities',
4
-        id: 0,
5
-        children: [
6
-            {
7
-                name: 'Adjuntas',
8
-                id: 0,
9
-            },
10
-            {
11
-                name: 'Aguada',
12
-                id: 1,
13
-            },
14
-            {
15
-                name: 'Aguadilla',
16
-                id: 2,
17
-            },
18
-            {
19
-                name: 'Aguas Buenas',
20
-                id: 3,
21
-            },
22
-            {
23
-                name: 'Aibonito',
24
-                id: 4,
25
-            },
26
-            {
27
-                name: 'Arecibo',
28
-                id: 5,
29
-            },
30
-            {
31
-                name: 'Arroyo',
32
-                id: 6,
33
-            },
34
-            {
35
-                name: 'Añasco',
36
-                id: 7,
37
-            },
38
-            {
39
-                name: 'Barceloneta',
40
-                id: 8,
41
-            },
42
-            {
43
-                name: 'Barranquitas',
44
-                id: 9,
45
-            },
46
-            {
47
-                name: 'Bayamón',
48
-                id: 10,
49
-            },
50
-            {
51
-                name: 'Cabo Rojo',
52
-                id: 11,
53
-            },
54
-            {
55
-                name: 'Caguas',
56
-                id: 12,
57
-            },
58
-            {
59
-                name: 'Camuy',
60
-                id: 13,
61
-            },
62
-            {
63
-                name: 'Canóvanas',
64
-                id: 14,
65
-            },
66
-            {
67
-                name: 'Carolina',
68
-                id: 15,
69
-            },
70
-            {
71
-                name: 'Cataño',
72
-                id: 16,
73
-            },
74
-            {
75
-                name: 'Cayey',
76
-                id: 17,
77
-            },
78
-            {
79
-                name: 'Ceiba',
80
-                id: 18,
81
-            },
82
-            {
83
-                name: 'Ciales',
84
-                id: 19,
85
-            },
86
-            {
87
-                name: 'Cidra',
88
-                id: 20,
89
-            },
90
-            {
91
-                name: 'Coamo',
92
-                id: 21,
93
-            },
94
-            {
95
-                name: 'Comerío',
96
-                id: 22,
97
-            },
98
-            {
99
-                name: 'Corozal',
100
-                id: 23,
101
-            },
102
-            {
103
-                name: 'Culebra',
104
-                id: 24,
105
-            },
106
-            {
107
-                name: 'Dorado',
108
-                id: 25,
109
-            },
110
-            {
111
-                name: 'Fajardo',
112
-                id: 26,
113
-            },
114
-            {
115
-                name: 'Florida',
116
-                id: 27,
117
-            },
118
-            {
119
-                name: 'Guayama',
120
-                id: 28,
121
-            },
122
-            {
123
-                name: 'Guayanilla',
124
-                id: 29,
125
-            },
126
-            {
127
-                name: 'Guaynabo',
128
-                id: 30,
129
-            },
130
-            {
131
-                name: 'Gurabo',
132
-                id: 31,
133
-            },
134
-            {
135
-                name: 'Guánica',
136
-                id: 32,
137
-            },
138
-            {
139
-                name: 'Hatillo',
140
-                id: 33,
141
-            },
142
-            {
143
-                name: 'Hormigueros',
144
-                id: 34,
145
-            },
146
-            {
147
-                name: 'Humacao',
148
-                id: 35,
149
-            },
150
-            {
151
-                name: 'Isabela',
152
-                id: 36,
153
-            },
154
-            {
155
-                name: 'Jayuya',
156
-                id: 37,
157
-            },
158
-            {
159
-                name: 'Juana Díaz',
160
-                id: 38,
161
-            },
162
-            {
163
-                name: 'Juncos',
164
-                id: 39,
165
-            },
166
-            {
167
-                name: 'Lajas',
168
-                id: 40,
169
-            },
170
-            {
171
-                name: 'Lares',
172
-                id: 41,
173
-            },
174
-            {
175
-                name: 'Las Marías',
176
-                id: 42,
177
-            },
178
-            {
179
-                name: 'Las Piedras',
180
-                id: 43,
181
-            },
182
-            {
183
-                name: 'Loíza',
184
-                id: 44,
185
-            },
186
-            {
187
-                name: 'Luquillo',
188
-                id: 45,
189
-            },
190
-            {
191
-                name: 'Manatí',
192
-                id: 46,
193
-            },
194
-            {
195
-                name: 'Maricao',
196
-                id: 47,
197
-            },
198
-            {
199
-                name: 'Maunabo',
200
-                id: 48,
201
-            },
202
-            {
203
-                name: 'Mayagüez',
204
-                id: 49,
205
-            },
206
-            {
207
-                name: 'Moca',
208
-                id: 50,
209
-            },
210
-            {
211
-                name: 'Morovis',
212
-                id: 51,
213
-            },
214
-            {
215
-                name: 'Naguabo',
216
-                id: 52,
217
-            },
218
-            {
219
-                name: 'Naranjito',
220
-                id: 53,
221
-            },
222
-            {
223
-                name: 'Orocovis',
224
-                id: 54,
225
-            },
226
-            {
227
-                name: 'Patillas',
228
-                id: 55,
229
-            },
230
-            {
231
-                name: 'Peñuelas',
232
-                id: 56,
233
-            },
234
-            {
235
-                name: 'Ponce',
236
-                id: 57,
237
-            },
238
-            {
239
-                name: 'Quebradillas',
240
-                id: 58,
241
-            },
242
-            {
243
-                name: 'Rincón',
244
-                id: 59,
245
-            },
246
-            {
247
-                name: 'Rio Grande',
248
-                id: 60,
249
-            },
250
-            {
251
-                name: 'Sabana Grande',
252
-                id: 61,
253
-            },
254
-            {
255
-                name: 'Salinas',
256
-                id: 62,
257
-            },
258
-            {
259
-                name: 'San Germán',
260
-                id: 63,
261
-            },
262
-            {
263
-                name: 'San Juan',
264
-                id: 64,
265
-            },
266
-            {
267
-                name: 'San Lorenzo',
268
-                id: 65,
269
-            },
270
-            {
271
-                name: 'San Sebastián',
272
-                id: 66,
273
-            },
274
-            {
275
-                name: 'Santa Isabel',
276
-                id: 67,
277
-            },
278
-            {
279
-                name: 'Toa Alta',
280
-                id: 68,
281
-            },
282
-            {
283
-                name: 'Toa Baja',
284
-                id: 69,
285
-            },
286
-            {
287
-                name: 'Trujillo Alto',
288
-                id: 70,
289
-            },
290
-            {
291
-                name: 'Utuado',
292
-                id: 71,
293
-            },
294
-            {
295
-                name: 'Vega Alta',
296
-                id: 72,
297
-            },
298
-            {
299
-                name: 'Vega Baja',
300
-                id: 73,
301
-            },
302
-            {
303
-                name: 'Vieques',
304
-                id: 74,
305
-            },
306
-            {
307
-                name: 'Villalba',
308
-                id: 75,
309
-            },
310
-            {
311
-                name: 'Yabucoa',
312
-                id: 76,
313
-            },
314
-            {
315
-                name: 'Yauco',
316
-                id: 77,
317
-            },
318
-        ],
319
-    },
320
-
2
+   
321 3
     {
322 4
         name: 'Languages',
323 5
         id: 1,

+ 97
- 5
screens/main/AvailabilityScreen.js View File

@@ -7,6 +7,7 @@ import SectionedMultiSelect from 'react-native-sectioned-multi-select';
7 7
 import Icon from 'react-native-vector-icons/MaterialIcons';
8 8
 import { connect } from 'react-redux';
9 9
 import { bindActionCreators } from 'redux';
10
+import { Picker } from "@react-native-picker/picker";
10 11
 
11 12
 import { fetchUser } from "../../redux/actions";
12 13
 import { styles } from "../../config/styles";
@@ -16,13 +17,16 @@ export class AvailabilityScreen extends Component {
16 17
     constructor(props) {
17 18
         super(props);
18 19
         this.state = {
20
+            //x : this.route.params.availabilityData.selectedItems,
21
+            //y : this.route.params.availabilityData.markedDates,
19 22
             english: false,
20 23
             spanish: false,
21 24
             virtual: false,
22 25
             face_to_face: false,
23 26
             personal: false,
24 27
             group: false,
25
-            cities: [],
28
+            city: 'San Juan',
29
+            //cities: [],
26 30
             selectedItems: [],
27 31
             markedDates: {}
28 32
         };
@@ -33,6 +37,12 @@ export class AvailabilityScreen extends Component {
33 37
     };
34 38
 
35 39
     componentDidMount(){
40
+        /*if (x != undefined){
41
+            this.setState({selectedItems : x});
42
+        };
43
+        if (y != undefined){
44
+            this.setState({markedDates : y});
45
+        }*/
36 46
         this.props.fetchUser();
37 47
         this.forceUpdate(() => {this.handleUpdate()})
38 48
     };
@@ -40,10 +50,11 @@ export class AvailabilityScreen extends Component {
40 50
     handleUpdate(){
41 51
         const { currentUser } = this.props;
42 52
         if (currentUser != undefined){
43
-            if (currentUser.hasOwnProperty('selectedItems') && currentUser.hasOwnProperty('markedDates'))
53
+            if (currentUser.hasOwnProperty('selectedItems') && currentUser.hasOwnProperty('markedDates') && currentUser.hasOwnProperty('city'))
44 54
             this.setState( {selectedItems: currentUser.selectedItems});
45 55
             this.setState( {markedDates: currentUser.markedDates});
46
-        }    
56
+            this.setState({city: currentUser.city})
57
+        }
47 58
     };
48 59
 
49 60
     onSave(){
@@ -79,9 +90,9 @@ export class AvailabilityScreen extends Component {
79 90
                     }
80 91
                 }
81 92
             }
82
-            else{
93
+            /*else{
83 94
                 this.state.cities.push(value);
84
-            }
95
+            }*/
85 96
         })
86 97
         firebase.firestore().collection('Interpreters')
87 98
             .doc(firebase.auth().currentUser.uid)
@@ -123,6 +134,87 @@ export class AvailabilityScreen extends Component {
123 134
                     onSelectedItemsChange={this.onSelectedItemsChange}
124 135
                     selectedItems={this.state.selectedItems}
125 136
                 />
137
+                <Picker selectedValue={this.state.city} onValueChange={(itemValue, itemIndex) => this.setState({city : itemValue})}>
138
+                    <Picker.Item label='Adjuntas' value={'Adjuntas'}/>
139
+                    <Picker.Item label='Aguada' value={'Aguada'}/>
140
+                    <Picker.Item label='Adjuntas' value={'Adjuntas'}/>
141
+                    <Picker.Item label='Aguadilla' value={'Aguadilla'}/>
142
+                    <Picker.Item label='Aguas Buenas' value={'Aguas Buenas'}/>
143
+                    <Picker.Item label='Aibonito' value={'Aibonito'}/>
144
+                    <Picker.Item label='Arecibo' value={'Arecibo'}/>
145
+                    <Picker.Item label='Arroyo' value={'Arroyo'}/>
146
+                    <Picker.Item label='Añasco' value={'Añasco'}/>
147
+                    <Picker.Item label='Barceloneta' value={'Barceloneta'}/>
148
+                    <Picker.Item label='Barranquitas' value={'Barranquitas'}/>
149
+                    <Picker.Item label='Bayamón' value={'Bayamón'}/>
150
+                    <Picker.Item label='Cabo Rojo' value={'Cabo Rojo'}/>
151
+                    <Picker.Item label='Caguas' value={'Caguas'}/>
152
+                    <Picker.Item label='Camuy' value={'Camuy'}/>
153
+                    <Picker.Item label='Canóvanas' value={'Canóvanas'}/>
154
+                    <Picker.Item label='Carolina' value={'Carolina'}/>
155
+                    <Picker.Item label='Cataño' value={'Cataño'}/>
156
+                    <Picker.Item label='Cayey' value={'Cayey'}/>
157
+                    <Picker.Item label='Ceiba' value={'Ceiba'}/>
158
+                    <Picker.Item label='Ciales' value={'Ciales'}/>
159
+                    <Picker.Item label='Cidra' value={'Cidra'}/>
160
+                    <Picker.Item label='Coamo' value={'Coamo'}/>
161
+                    <Picker.Item label='Comerío' value={'Comerío'}/>
162
+                    <Picker.Item label='Corozal' value={'Corozal'}/>
163
+                    <Picker.Item label='Culebra' value={'Culebra'}/>
164
+                    <Picker.Item label='Dorado' value={'Dorado'}/>
165
+                    <Picker.Item label='Fajardo' value={'Fajardo'}/>
166
+                    <Picker.Item label='Florida' value={'Florida'}/>
167
+                    <Picker.Item label='Guayama' value={'Guayama'}/>
168
+                    <Picker.Item label='Guayanilla' value={'Guayanilla'}/>
169
+                    <Picker.Item label='Guaynabo' value={'Guaynabo'}/>
170
+                    <Picker.Item label='Gurabo' value={'Gurabo'}/>
171
+                    <Picker.Item label='Guánica' value={'Guánica'}/>
172
+                    <Picker.Item label='Hatillo' value={'Hatillo'}/>
173
+                    <Picker.Item label='Hormigueros' value={'Hormigueros'}/>
174
+                    <Picker.Item label='Humacao' value={'Humacao'}/>
175
+                    <Picker.Item label='Isabela' value={'Isabela'}/>
176
+                    <Picker.Item label='Jayuya' value={'Jayuya'}/>
177
+                    <Picker.Item label='Juana Díaz' value={'Juana Díaz'}/>
178
+                    <Picker.Item label='Juncos' value={'Juncos'}/>
179
+                    <Picker.Item label='Lajas' value={'Lajas'}/>
180
+                    <Picker.Item label='Lares' value={'Lares'}/>
181
+                    <Picker.Item label='Las Marías' value={'Las Marías'}/>
182
+                    <Picker.Item label='Las Piedras' value={'Las Piedras'}/>
183
+                    <Picker.Item label='Loíza' value={'Loíza'}/>
184
+                    <Picker.Item label='Luquillo' value={'Luquillo'}/>
185
+                    <Picker.Item label='Manatí' value={'Manatí'}/>
186
+                    <Picker.Item label='Maricao' value={'Maricao'}/>
187
+                    <Picker.Item label='Maunabo' value={'Maunabo'}/>
188
+                    <Picker.Item label='Mayagüez' value={'Mayagüez'}/>
189
+                    <Picker.Item label='Moca' value={'Moca'}/>
190
+                    <Picker.Item label='Morovis' value={'Morovis'}/>
191
+                    <Picker.Item label='Naguabo' value={'Naguabo'}/>
192
+                    <Picker.Item label='Naranjito' value={'Naranjito'}/>
193
+                    <Picker.Item label='Orocovis' value={'Orocovis'}/>
194
+                    <Picker.Item label='Patillas' value={'Patillas'}/>
195
+                    <Picker.Item label='Peñuelas' value={'Peñuelas'}/>
196
+                    <Picker.Item label='Ponce' value={'Ponce'}/>
197
+                    <Picker.Item label='Quebradillas' value={'Quebradillas'}/>
198
+                    <Picker.Item label='Rincón' value={'Rincón'}/>
199
+                    <Picker.Item label='Rio Grande' value={'Rio Grande'}/>
200
+                    <Picker.Item label='Sabana Grande' value={'Sabana Grande'}/>
201
+                    <Picker.Item label='Salinas' value={'Salinas'}/>
202
+                    <Picker.Item label='San Germán' value={'San Germán'}/>
203
+                    <Picker.Item label='San Juan' value={'San Juan'}/>
204
+                    <Picker.Item label='San Lorenzo' value={'San Lorenzo'}/>
205
+                    <Picker.Item label='San Sebastián' value={'San Sebastián'}/>
206
+                    <Picker.Item label='Santa Isabel' value={'Santa Isabel'}/>
207
+                    <Picker.Item label='Toa Alta' value={'Toa Alta'}/>
208
+                    <Picker.Item label='Toa Baja' value={'Toa Baja'}/>
209
+                    <Picker.Item label='Trujillo Alto' value={'Trujillo Alto'}/>
210
+                    <Picker.Item label='Utuado' value={'Utuado'}/>
211
+                    <Picker.Item label='Vega Alta' value={'Vega Alta'}/>
212
+                    <Picker.Item label='Vega Baja' value={'Vega Baja'}/>
213
+                    <Picker.Item label='Vieques' value={'Vieques'}/>
214
+                    <Picker.Item label='Villalba' value={'Villalba'}/>
215
+                    <Picker.Item label='Yabucoa' value={'Yabucoa'}/>
216
+                    <Picker.Item label='Yauco' value={'Yauco'}/>
217
+                </Picker>
126 218
                 <Button title='Save' onPress={() => {this.onSave()}}/>
127 219
             </ScrollView>
128 220
         );