Browse Source

Used to read events list from json

PabloPuig1 1 year ago
parent
commit
b4adde9ce6
1 changed files with 20 additions and 30 deletions
  1. 20
    30
      screens/eventSearch.js

+ 20
- 30
screens/eventSearch.js View File

@@ -8,20 +8,19 @@ export default class EventSearch extends Component
8 8
     constructor(props)
9 9
     {
10 10
         super(props);
11
-        this.state={EID:'',Name:'',Sdate:'',Edate:'',Pcount:'',Plimit:'',Description:''};
11
+        this.state={UID:'',acc_type:'',name:'',email:'',phone:''};
12 12
     }
13 13
     SearchEvent=()=>
14 14
     {
15
-        var EID=this.state.EID;
15
+        var UID=this.state.UID;
16 16
 
17
-        if(EID.length==0)
17
+        if(UID.length==0)
18 18
         {
19
-            
20 19
             alert('Field is blank');
21 20
         }
22 21
         else
23 22
         { 
24
-            var SearchAPIURL="https://ada.uprrp.edu/~pablo.puig1/TPMG/React.php";
23
+            var SearchAPIURL="https://ada.uprrp.edu/~pablo.puig1/TPMG/testusersearch.php";
25 24
 
26 25
             var header={
27 26
                     'Accept':'application/json',
@@ -29,7 +28,7 @@ export default class EventSearch extends Component
29 28
             };
30 29
 
31 30
             var Data={
32
-                EID:EID
31
+                UID:UID
33 32
             };
34 33
 
35 34
             fetch(
@@ -40,16 +39,16 @@ export default class EventSearch extends Component
40 39
                     body: JSON.stringify(Data)
41 40
                 }
42 41
             )
42
+        
43 43
             .then((response)=>response.json())
44
+            // .then(console.log(response))
44 45
             .then((response)=>
45 46
             {
46
-                this.setState({EID:response[0].EID});
47
-                this.setState({Name:response[0].Name});
48
-                this.setState({Sdate:response[0].Sdate});
49
-                this.setState({Edate:response[0].Edate});
50
-                this.setState({Pcount:response[0].Pcount});
51
-                this.setState({Plimit:response[0].Plimit});
52
-                this.setState({Description:response[0].Description});
47
+                this.setState({UID:response[0].id});
48
+                this.setState({acc_type:response[0].acc_type});
49
+                this.setState({name:response[0].name});
50
+                this.setState({email:response[0].email});
51
+                this.setState({phone:response[0].phone});
53 52
             })
54 53
             .catch((error)=>
55 54
             {
@@ -63,49 +62,40 @@ export default class EventSearch extends Component
63 62
         return(
64 63
             <View style={styles.viewSyle}>
65 64
                 <TextInput
66
-                    placeholder={"Enter EID"}
65
+                    placeholder={"Enter UID"}
67 66
                     placeholderTextColor={"red"}
68 67
                     keyboardType={"numeric"}
69 68
                     style={styles.txtStyle}
70
-                    onChangeText={EID=>this.setState({EID})}
69
+                    onChangeText={UID=>this.setState({UID})}
71 70
                 />
72 71
                 <Button
73 72
                     title={"Find Event"}
74 73
                     onPress={this.SearchEvent}
75 74
                 />
75
+                <Text>{"\n\n"}</Text>
76 76
                 <TextInput
77 77
                     style={styles.txtStyle}
78
-                    value={this.state.EID}
78
+                    value={this.state.UID}
79 79
                 />
80 80
 
81 81
                 <TextInput
82 82
                     style={styles.txtStyle}
83
-                    value={this.state.Name}
83
+                    value={this.state.acc_type}
84 84
                 />
85 85
 
86 86
                 <TextInput
87 87
                     style={styles.txtStyle}
88
-                    value={this.state.Sdate}
88
+                    value={this.state.name}
89 89
                 />
90 90
 
91 91
                 <TextInput
92 92
                     style={styles.txtStyle}
93
-                    value={this.state.Edate}
93
+                    value={this.state.email}
94 94
                 />
95 95
 
96 96
                 <TextInput
97 97
                     style={styles.txtStyle}
98
-                    value={this.state.Pcount}
99
-                />
100
-
101
-                <TextInput
102
-                    style={styles.txtStyle}
103
-                    value={this.state.Plimit}
104
-                />
105
-
106
-                <TextInput
107
-                    style={styles.txtStyle}
108
-                    value={this.state.Description}
98
+                    value={this.state.phone}
109 99
                 />
110 100
 
111 101
             </View>