Açıklama Yok

eventSearch.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { alignProperty } from '@mui/material/styles/cssUtils';
  2. import React,{Component} from 'react';
  3. import {View, Text, TextInput, Button, StyleSheet} from 'react-native';
  4. export default class EventSearch extends Component
  5. {
  6. constructor(props)
  7. {
  8. super(props);
  9. this.state={UID:'',acc_type:'',name:'',email:'',phone:''};
  10. }
  11. SearchEvent=()=>
  12. {
  13. var UID=this.state.UID;
  14. if(UID.length==0)
  15. {
  16. alert('Field is blank');
  17. }
  18. else
  19. {
  20. var SearchAPIURL="https://ada.uprrp.edu/~pablo.puig1/TPMG/testusersearch.php";
  21. var header={
  22. 'Accept':'application/json',
  23. 'Content-Type':'application/json'
  24. };
  25. var Data={
  26. UID:UID
  27. };
  28. fetch(
  29. SearchAPIURL,
  30. {
  31. method:'POST',
  32. headers:header,
  33. body: JSON.stringify(Data)
  34. }
  35. )
  36. .then((response)=>response.json())
  37. // .then(console.log(response))
  38. .then((response)=>
  39. {
  40. this.setState({UID:response[0].id});
  41. this.setState({acc_type:response[0].acc_type});
  42. this.setState({name:response[0].name});
  43. this.setState({email:response[0].email});
  44. this.setState({phone:response[0].phone});
  45. })
  46. .catch((error)=>
  47. {
  48. alert("Error: " + error);
  49. })
  50. }
  51. }
  52. render()
  53. {
  54. return(
  55. <View style={styles.viewSyle}>
  56. <TextInput
  57. placeholder={"Enter UID"}
  58. placeholderTextColor={"red"}
  59. keyboardType={"numeric"}
  60. style={styles.txtStyle}
  61. onChangeText={UID=>this.setState({UID})}
  62. />
  63. <Button
  64. title={"Find Event"}
  65. onPress={this.SearchEvent}
  66. />
  67. <Text>{"\n\n"}</Text>
  68. <TextInput
  69. style={styles.txtStyle}
  70. value={this.state.UID}
  71. />
  72. <TextInput
  73. style={styles.txtStyle}
  74. value={this.state.acc_type}
  75. />
  76. <TextInput
  77. style={styles.txtStyle}
  78. value={this.state.name}
  79. />
  80. <TextInput
  81. style={styles.txtStyle}
  82. value={this.state.email}
  83. />
  84. <TextInput
  85. style={styles.txtStyle}
  86. value={this.state.phone}
  87. />
  88. </View>
  89. );
  90. }
  91. }
  92. const styles=StyleSheet.create({
  93. viewSyle:
  94. {
  95. flex:1,
  96. padding:1,
  97. marginTop:90
  98. },
  99. txtStyle:
  100. {
  101. borderBottomWidth:1,
  102. borderBottonColor:'red',
  103. marginBottom:20
  104. }
  105. });