Browse Source

Used to read events list from json

PabloPuig1 2 years 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
     constructor(props)
8
     constructor(props)
9
     {
9
     {
10
         super(props);
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
     SearchEvent=()=>
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
             alert('Field is blank');
19
             alert('Field is blank');
21
         }
20
         }
22
         else
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
             var header={
25
             var header={
27
                     'Accept':'application/json',
26
                     'Accept':'application/json',
29
             };
28
             };
30
 
29
 
31
             var Data={
30
             var Data={
32
-                EID:EID
31
+                UID:UID
33
             };
32
             };
34
 
33
 
35
             fetch(
34
             fetch(
40
                     body: JSON.stringify(Data)
39
                     body: JSON.stringify(Data)
41
                 }
40
                 }
42
             )
41
             )
42
+        
43
             .then((response)=>response.json())
43
             .then((response)=>response.json())
44
+            // .then(console.log(response))
44
             .then((response)=>
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
             .catch((error)=>
53
             .catch((error)=>
55
             {
54
             {
63
         return(
62
         return(
64
             <View style={styles.viewSyle}>
63
             <View style={styles.viewSyle}>
65
                 <TextInput
64
                 <TextInput
66
-                    placeholder={"Enter EID"}
65
+                    placeholder={"Enter UID"}
67
                     placeholderTextColor={"red"}
66
                     placeholderTextColor={"red"}
68
                     keyboardType={"numeric"}
67
                     keyboardType={"numeric"}
69
                     style={styles.txtStyle}
68
                     style={styles.txtStyle}
70
-                    onChangeText={EID=>this.setState({EID})}
69
+                    onChangeText={UID=>this.setState({UID})}
71
                 />
70
                 />
72
                 <Button
71
                 <Button
73
                     title={"Find Event"}
72
                     title={"Find Event"}
74
                     onPress={this.SearchEvent}
73
                     onPress={this.SearchEvent}
75
                 />
74
                 />
75
+                <Text>{"\n\n"}</Text>
76
                 <TextInput
76
                 <TextInput
77
                     style={styles.txtStyle}
77
                     style={styles.txtStyle}
78
-                    value={this.state.EID}
78
+                    value={this.state.UID}
79
                 />
79
                 />
80
 
80
 
81
                 <TextInput
81
                 <TextInput
82
                     style={styles.txtStyle}
82
                     style={styles.txtStyle}
83
-                    value={this.state.Name}
83
+                    value={this.state.acc_type}
84
                 />
84
                 />
85
 
85
 
86
                 <TextInput
86
                 <TextInput
87
                     style={styles.txtStyle}
87
                     style={styles.txtStyle}
88
-                    value={this.state.Sdate}
88
+                    value={this.state.name}
89
                 />
89
                 />
90
 
90
 
91
                 <TextInput
91
                 <TextInput
92
                     style={styles.txtStyle}
92
                     style={styles.txtStyle}
93
-                    value={this.state.Edate}
93
+                    value={this.state.email}
94
                 />
94
                 />
95
 
95
 
96
                 <TextInput
96
                 <TextInput
97
                     style={styles.txtStyle}
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
             </View>
101
             </View>