選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ViewPrescription.js 15 KiB

3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
3年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. import React, {Component} from 'react';
  2. import { StyleSheet, Text, Image, View, Alert, TouchableOpacity } from 'react-native';
  3. import { Container, Header, Content, Left, Body, Right, Title, Button as Btn, Icon, Card, CardItem, Col, Footer, Row } from 'native-base';
  4. import { api_url, img_url, reject_order,font_title,font_description } from '../config/Constants';
  5. import * as colors from '../assets/css/Colors';
  6. import {captureScreen} from 'react-native-view-shot';
  7. import { Loader } from '../components/GeneralComponents';
  8. import { Divider, Button } from 'react-native-elements';
  9. import axios from 'axios';
  10. import ViewShot from "react-native-view-shot";
  11. import { connect } from 'react-redux';
  12. import { serviceActionPending, serviceActionError, serviceActionSuccess } from '../actions/ViewPrescriptionActions';
  13. import ImageView from 'react-native-image-view';
  14. import back from "../assets/icons/back1.png";
  15. import download from "../assets/icons/download.png";
  16. import rx from "../assets/icons/rx.jpg";
  17. class ViewPrescription extends Component<Props> {
  18. constructor(props) {
  19. super(props)
  20. this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
  21. this.reject_order = this.reject_order.bind(this);
  22. this.state = {
  23. data:this.props.route.params.data,
  24. image:[],
  25. isImageViewVisible:false,
  26. imageURI:'',
  27. dataExist:false
  28. }
  29. }
  30. componentDidMount(){
  31. // this.refs.viewShot.capture().then(uri => {
  32. // console.log("do something with ", uri);
  33. // });
  34. }
  35. handleBackButtonClick= () => {
  36. this.props.navigation.goBack(null);
  37. }
  38. accept_order = () => {
  39. this.props.navigation.navigate('Payment',{ from : 'prescription', prescription_id:this.state.data.id, prescription_total:this.state.data.total });
  40. }
  41. takeScreenShot = () => {
  42. // To capture Screenshot
  43. captureScreen({
  44. // Either png or jpg (or webm Android Only), Defaults: png
  45. format: 'jpg',
  46. // Quality 0.0 - 1.0 (only available for jpg)
  47. quality: 0.8,
  48. }).then(
  49. //callback function to get the result URL of the screnshot
  50. (uri) => {
  51. this.setState({imageUri:uri});
  52. console.log(uri)
  53. alert(uri);
  54. // setSavedImagePath(uri);
  55. // setImageURI(uri);
  56. },
  57. (error) => console.error('Oops, Something Went Wrong', error),
  58. );
  59. };
  60. reject_order = async () => {
  61. this.props.serviceActionPending();
  62. await axios({
  63. method: 'post',
  64. url: api_url + reject_order,
  65. data:{ prescription_id : this.state.data.id }
  66. })
  67. .then(async response => {
  68. await this.props.serviceActionSuccess(response.data)
  69. if(response.data.status == 1){
  70. Alert.alert(
  71. "Rejected",
  72. "This prescription successfully rejected.",
  73. [
  74. { text: "OK", onPress: () => this.props.navigation.goBack(null) }
  75. ],
  76. { cancelable: false }
  77. );
  78. }else{
  79. alert(response.data.message);
  80. }
  81. })
  82. .catch(error => {
  83. this.props.serviceActionError(error);
  84. });
  85. }
  86. onCapture = uri => {
  87. console.log("do something with ", uri);
  88. }
  89. view_image = (data) =>{
  90. let image = [
  91. {
  92. source: {
  93. uri: img_url + data,
  94. },
  95. title: 'Prescription Image',
  96. width: 806,
  97. height: 720
  98. }
  99. ]
  100. this.setState({ image : image, isImageViewVisible : true });
  101. }
  102. close_popup = () =>{
  103. this.setState({ isImageViewVisible : false });
  104. }
  105. render() {
  106. const { isLoding, error, data, message, status } = this.props
  107. return (
  108. <Container>
  109. {/* <ViewShot onCapture={this.onCapture} captureMode="mount"> */}
  110. <View>
  111. <View style={styles.view_style1}>
  112. <TouchableOpacity style={styles.view_style2} onPress={this.handleBackButtonClick} activeOpacity={1} >
  113. <Image
  114. style={{
  115. width: 20,
  116. height: 20,
  117. backgroundColor: "white",
  118. marginVertical: 6,
  119. marginLeft: 2,
  120. }}
  121. source={back}
  122. />
  123. </TouchableOpacity>
  124. <TouchableOpacity style={{}} onPress={this.takeScreenShot} activeOpacity={1} >
  125. <Image
  126. style={{
  127. width: 40,
  128. height: 40,
  129. backgroundColor: "white",
  130. marginTop: 6,
  131. marginLeft:11
  132. }}
  133. source={download}
  134. />
  135. </TouchableOpacity>
  136. {/* <View style={styles.view_style4} /> */}
  137. </View>
  138. </View>
  139. <View
  140. style={{marginLeft:12}}
  141. >
  142. <Text style={styles.view_style5}>View Prescription</Text>
  143. </View>
  144. <View style={styles.view_style6}/>
  145. <Content>
  146. <ImageView
  147. images={this.state.image}
  148. imageIndex={0}
  149. isVisible={this.state.isImageViewVisible}
  150. onClose={() => this.close_popup() }
  151. />
  152. <Card>
  153. <Text style={styles.view_style7}>Dr</Text>
  154. <CardItem>
  155. <Image
  156. style={{
  157. width: 60,
  158. height: 60,
  159. backgroundColor: "white",
  160. marginVertical: 6,
  161. marginLeft: 2,
  162. }}
  163. source={rx}
  164. />
  165. <Text style={styles.view_style11}>{this.state.data.doctor.name}</Text>
  166. <Text>{"\n"}</Text>
  167. {/* <Text style={styles.view_style7}>{this.state.data.doctor.qualification}</Text> */}
  168. </CardItem>
  169. <View
  170. style={{
  171. left:'20%',
  172. marginTop:-30
  173. }}
  174. >
  175. <Text style={styles.view_style7}>{this.state.data.doctor.qualification}</Text>
  176. <Text style={styles.view_style7}>{this.state.data.doctor.description}</Text>
  177. <Text style={styles.view_style7}>{this.state.data.doctor.email}</Text>
  178. </View>
  179. <CardItem>
  180. {/* {this.state.data.images.map((row, index) => (
  181. <Col onPress={ ()=> this.view_image(row) }>
  182. <Image
  183. style={styles.view_style8}
  184. resizeMode='cover'
  185. source={{ uri : img_url + row}}
  186. />
  187. </Col>
  188. ))} */}
  189. </CardItem>
  190. </Card>
  191. {this.state.data.customer_notes &&
  192. <Card>
  193. <CardItem header>
  194. <Text style={styles.view_style9}>Your Notes</Text>
  195. </CardItem>
  196. <CardItem>
  197. <Text style={styles.view_style10}>{this.state.data.customer_notes}</Text>
  198. </CardItem>
  199. </Card>
  200. }
  201. <Card>
  202. <Text style={styles.view_style7}>Patient Detail</Text>
  203. <CardItem >
  204. <Text style={styles.view_style11}>{global.name}</Text>
  205. </CardItem>
  206. <View style={styles.view_style12}>
  207. <Text style={styles.view_style7}>Problem title </Text>
  208. <Text style={styles.view_style9}>{this.state.data.booking.title},</Text>
  209. <Text style={styles.view_style7}>Problem description</Text>
  210. <Text style={styles.view_style9}>{this.state.data.booking.description}</Text>
  211. </View>
  212. </Card>
  213. {/* <ViewShot onCapture={this.onCapture} captureMode="mount">
  214. <Text>...The Scroll View Content Goes Here...</Text>
  215. </ViewShot> */}
  216. {this.state.data.status != 1 &&
  217. <Card>
  218. <CardItem header>
  219. <Text style={styles.view_style7}>Prescription Medicine</Text>
  220. </CardItem>
  221. {this.state.data.medicines.map((row, index) => (
  222. <CardItem>
  223. <Row>
  224. <Col style={styles.view_style16} >
  225. <Text style={styles.view_style17} >{row.name}</Text>
  226. </Col>
  227. <Col style={styles.view_style18}>
  228. </Col>
  229. <Col style={styles.view_style20} >
  230. <Text style={styles.view_style19}>Take for {row.days} days</Text>
  231. {/* <Text style={styles.view_style21}>{global.currency}{row.price}</Text> */}
  232. </Col>
  233. </Row>
  234. </CardItem>
  235. ))}
  236. <Divider style={styles.view_style22} />
  237. {/* <Row style={styles.view_style23} >
  238. <Col>
  239. <Text style={styles.view_style24}>Subtotal</Text>
  240. </Col>
  241. <Col style={styles.view_style25} >
  242. <Text style={styles.view_style26}>{global.currency}{this.state.data.sub_total}</Text>
  243. </Col>
  244. </Row>
  245. <Row style={styles.view_style27} >
  246. <Col>
  247. <Text style={styles.view_style28}>Delivery Charge</Text>
  248. </Col>
  249. <Col style={styles.view_style29} >
  250. <Text style={styles.view_style30}>{global.currency}{this.state.data.delivery_charge}</Text>
  251. </Col>
  252. </Row>
  253. <Row style={styles.view_style31} >
  254. <Col>
  255. <Text style={styles.view_style32}>Tax</Text>
  256. </Col> */}
  257. {/* <Col style={styles.view_style33} >
  258. <Text style={styles.view_style34}>{global.currency}{this.state.data.tax}</Text>
  259. </Col>
  260. </Row> */}
  261. <View style={styles.view_style35} />
  262. {/* <Divider style={styles.view_style36} /> */}
  263. <Row style={styles.view_style37} >
  264. {/* <Col>
  265. <Text style={styles.view_style38}>Total</Text>
  266. </Col> */}
  267. {/* <Col style={styles.view_style39} >
  268. <Text style={styles.view_style40} >{global.currency}{this.state.data.total}</Text>
  269. </Col> */}
  270. </Row>
  271. {/* <View style={styles.view_style41} /> */}
  272. </Card>
  273. }
  274. </Content>
  275. {this.state.data.status == 9 &&
  276. <Footer style={styles.view_style42} >
  277. <Row style={styles.view_style43}>
  278. <Col>
  279. <Button
  280. title="Reject"
  281. onPress={this.reject_order}
  282. buttonStyle={styles.view_style44}
  283. />
  284. </Col>
  285. <Col style={styles.view_style45} />
  286. <Col>
  287. <Button
  288. title="Accept"
  289. onPress={this.accept_order}
  290. buttonStyle={styles.view_style46}
  291. />
  292. </Col>
  293. </Row>
  294. </Footer>
  295. }
  296. <Loader visible={isLoding} />
  297. {/* </ViewShot> */}
  298. </Container>
  299. );
  300. }
  301. }
  302. function mapStateToProps(state){
  303. return{
  304. isLoding : state.view_prescription.isLoding,
  305. error : state.view_prescription.error,
  306. data : state.view_prescription.data,
  307. message : state.view_prescription.message,
  308. status : state.view_prescription.status,
  309. };
  310. }
  311. const mapDispatchToProps = (dispatch) => ({
  312. serviceActionPending: () => dispatch(serviceActionPending()),
  313. serviceActionError: (error) => dispatch(serviceActionError(error)),
  314. serviceActionSuccess: (data) => dispatch(serviceActionSuccess(data))
  315. });
  316. export default connect(mapStateToProps,mapDispatchToProps)(ViewPrescription);
  317. const styles = StyleSheet.create({
  318. view_style1:{ margin:10,flexDirection:'row',justifyContent:'space-between'},
  319. view_style2:{width:100, justifyContent:'center'},
  320. view_style3:{color:colors.theme_fg_two, fontSize:30},
  321. view_style4:{ margin:5 },
  322. view_style5:{ fontSize:25, color:colors.theme_fg_two, fontFamily: font_title,marginLeft:12},
  323. view_style6:{margin:5},
  324. view_style7:{ fontFamily:font_title, color:'grey' },
  325. view_style8:{
  326. width: 100,
  327. height: 70,
  328. alignSelf:'center',
  329. borderColor: colors.theme_bg_three,
  330. borderWidth: 1
  331. },
  332. view_style9:{ fontFamily:font_title, color:colors.theme_fg_two },
  333. view_style10:{fontFamily:font_description},
  334. view_style11:{ fontFamily:font_title, color:colors.theme_fg_two,fontSize:20, },
  335. view_style12:{ paddingLeft:20, paddingRight:20, paddingBottom:10 },
  336. view_style13:{fontFamily:font_description},
  337. view_style14:{fontFamily:font_description},
  338. view_style15:{ fontFamily:font_title, color:colors.theme_fg_two },
  339. view_style16:{ width:40 },
  340. view_style17:{fontFamily:font_title,width:100},
  341. view_style18:{ width:'70%' },
  342. view_style19:{fontFamily:font_description,width:'100%',paddingHorizontal:12},
  343. view_style20:{ width:80 },
  344. view_style21:{fontFamily:font_description},
  345. view_style22:{
  346. backgroundColor: colors.theme_fg_two,
  347. width:'90%',
  348. alignSelf:'center'
  349. },
  350. view_style23:{
  351. marginLeft:20,
  352. marginRight:20,
  353. marginTop:10
  354. },
  355. view_style24:{fontFamily:font_title},
  356. view_style25:{ width:80 },
  357. view_style26:{fontFamily:font_description},
  358. view_style27:{
  359. backgroundColor: colors.theme_fg_two,
  360. width:'90%',
  361. alignSelf:'center'
  362. },
  363. view_style28:{fontFamily:font_title},
  364. view_style29:{ width:80 },
  365. view_style30:{fontFamily:font_description},
  366. view_style31:{
  367. backgroundColor: colors.theme_fg_two,
  368. width:'90%',
  369. alignSelf:'center'
  370. },
  371. view_style32:{fontFamily:font_title},
  372. view_style33:{ width:80 },
  373. view_style34:{fontFamily:font_description},
  374. view_style35:{ marginBottom:20 },
  375. view_style36:{
  376. marginLeft:20,
  377. marginRight:20,
  378. marginTop:10
  379. },
  380. view_style37:{
  381. backgroundColor: colors.theme_fg_two,
  382. width:'90%',
  383. alignSelf:'center'
  384. },
  385. view_style38:{fontFamily:font_title},
  386. view_style39:{ width:80 },
  387. view_style40:{fontFamily:font_title },
  388. view_style41:{ marginBottom:20 },
  389. view_style42:{backgroundColor:'transparent'},
  390. view_style43:{ padding:10 },
  391. view_style44:{ backgroundColor:colors.red ,fontFamily:font_title},
  392. view_style45:{ width:10 },
  393. view_style46:{ backgroundColor:colors.theme_fg,fontFamily:font_title },
  394. header: {
  395. justifyContent: "flex-start",
  396. height: "10%",
  397. backgroundColor: colors.theme_bg,
  398. borderBottomLeftRadius: 45,
  399. borderBottomRightRadius: 45,
  400. shadowOffset: { width: 0, height: 15 },
  401. shadowColor: colors.theme_bg,
  402. shadowOpacity: 0.1,
  403. shadowRadius: 8,
  404. elevation: 10,
  405. },
  406. header_card: {
  407. alignItems: "center",
  408. borderRadius: 15,
  409. justifyContent: "center",
  410. },
  411. header_card_item: {
  412. borderTopLeftRadius: 15,
  413. borderTopRightRadius: 15,
  414. borderBottomLeftRadius: 15,
  415. borderBottomRightRadius: 15,
  416. shadowOffset: { width: 0, height: 15 },
  417. shadowColor: colors.theme_bg,
  418. shadowOpacity: 0.1,
  419. shadowRadius: 8,
  420. elevation: 10,
  421. },
  422. icon:{
  423. color:colors.theme_fg_two
  424. },
  425. header_body: {
  426. flex: 3,
  427. justifyContent: 'center'
  428. },
  429. title:{
  430. alignSelf:'center',
  431. color:colors.theme_fg_two,
  432. alignSelf:'center',
  433. fontSize:16,
  434. fontFamily:font_title
  435. },
  436. footer_container:{
  437. width:'100%',
  438. backgroundColor:colors.theme_bg
  439. },
  440. btn_cart:{
  441. color:colors.theme_fg_three,
  442. fontWeight:'bold',
  443. backgroundColor:colors.theme_bg
  444. }
  445. });