Açıklama Yok

eventSearch.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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={EID:'',Name:'',Sdate:'',Edate:'',Pcount:'',Plimit:'',Description:''};
  10. }
  11. SearchEvent=()=>
  12. {
  13. var EID=this.state.EID;
  14. if(EID.length==0)
  15. {
  16. alert('Field is blank');
  17. }
  18. else
  19. {
  20. var SearchAPIURL="https://ada.uprrp.edu/~pablo.puig1/TPMG/React.php";
  21. var header={
  22. 'Accept':'application/json',
  23. 'Content-Type':'application/json'
  24. };
  25. var Data={
  26. EID:EID
  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((response)=>
  38. {
  39. this.setState({EID:response[0].EID});
  40. this.setState({Name:response[0].Name});
  41. this.setState({Sdate:response[0].Sdate});
  42. this.setState({Edate:response[0].Edate});
  43. this.setState({Pcount:response[0].Pcount});
  44. this.setState({Plimit:response[0].Plimit});
  45. this.setState({Description:response[0].Description});
  46. })
  47. .catch((error)=>
  48. {
  49. alert("Error: " + error);
  50. })
  51. }
  52. }
  53. render()
  54. {
  55. return(
  56. <View style={styles.viewSyle}>
  57. <TextInput
  58. placeholder={"Enter EID"}
  59. placeholderTextColor={"red"}
  60. keyboardType={"numeric"}
  61. style={styles.txtStyle}
  62. onChangeText={EID=>this.setState({EID})}
  63. />
  64. <Button
  65. title={"Find Event"}
  66. onPress={this.SearchEvent}
  67. />
  68. <TextInput
  69. style={styles.txtStyle}
  70. value={this.state.EID}
  71. />
  72. <TextInput
  73. style={styles.txtStyle}
  74. value={this.state.Name}
  75. />
  76. <TextInput
  77. style={styles.txtStyle}
  78. value={this.state.Sdate}
  79. />
  80. <TextInput
  81. style={styles.txtStyle}
  82. value={this.state.Edate}
  83. />
  84. <TextInput
  85. style={styles.txtStyle}
  86. value={this.state.Pcount}
  87. />
  88. <TextInput
  89. style={styles.txtStyle}
  90. value={this.state.Plimit}
  91. />
  92. <TextInput
  93. style={styles.txtStyle}
  94. value={this.state.Description}
  95. />
  96. </View>
  97. );
  98. }
  99. }
  100. const styles=StyleSheet.create({
  101. viewSyle:
  102. {
  103. flex:1,
  104. padding:1,
  105. marginTop:90
  106. },
  107. txtStyle:
  108. {
  109. borderBottomWidth:1,
  110. borderBottonColor:'red',
  111. marginBottom:20
  112. }
  113. });