Guest User

Untitled

a guest
Jan 10th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Card, CardSection, Button, Input } from './common';
  3. import { connect } from 'react-redux';
  4. import { Picker, Text } from 'react-native';
  5. import { employeeUpdate } from '../actions';
  6.  
  7. class EmployeeCreate extends Component {
  8. render(){
  9. return (
  10. <Card>
  11. <CardSection>
  12. <Input
  13. label="Name"
  14. placeholder="Ashish"
  15. value={this.props.name}
  16. onChangeText={value => this.props.employeeUpdate({prop:'name', value})}
  17. />
  18.  
  19.  
  20. </CardSection>
  21.  
  22. <CardSection>
  23. <Input
  24. label="Phone"
  25. placeholder="+91-8800545355"
  26. value={this.props.phone}
  27. onChangeText={value => this.props.employeeUpdate({prop:'phone', value})}
  28. />
  29. </CardSection>
  30.  
  31. <CardSection style={{ flexDirection: 'column'}}>
  32. <Text style={styles.pickerTextStyle}>Shift</Text>
  33. <Picker
  34. style={{flex:1}}
  35. selectedValue = {this.props.shift}
  36. onValueChange={value => this.props.employeeUpdate({prop:'shift',value})}
  37. >
  38. <Picker.Item label="Monday" value="Monday" />
  39. <Picker.Item label="Tuesday" value="Tuesday" />
  40. <Picker.Item label="Wednesday" value="Wednesday" />
  41. <Picker.Item label="Thursday" value="Thursday" />
  42. <Picker.Item label="Friday" value="Friday" />
  43. <Picker.Item label="Saturday" value="Saturday" />
  44. <Picker.Item label="Sunday" value="Sunday" />
  45. </Picker>
  46. </CardSection>
  47.  
  48. <CardSection>
  49. <Button>
  50. Create
  51. </Button>
  52. </CardSection>
  53. </Card>
  54. );
  55. }
  56. }
  57.  
  58. const styles = {
  59. pickerTextStyle: {
  60. fontSize: 18,
  61. paddingLeft: 20
  62. }
  63. };
  64.  
  65. const mapStateToProps = (state) => {
  66. const { name, phone, shift } = state.employeeForm;
  67.  
  68. return { name, phone, shift };
  69. }
  70.  
  71. export default connect(mapStateToProps,{ employeeUpdate })(EmployeeCreate);
  72.  
  73. import React from 'react';
  74. import { View } from 'react-native';
  75.  
  76. const CardSection = (props) => {
  77.  
  78. return (
  79. <View style = {[styles.containerStyle, props.style]}>
  80. {props.children}
  81. </View>
  82. );
  83. };
  84.  
  85. const styles = {
  86. containerStyle : {
  87. borderBottomWidth: 1,
  88. padding: 5,
  89. backgroundColor: '#fff',
  90. justifyContent: 'flex-start',
  91. flexDirection: 'row',
  92. borderColor: '#ddd',
  93. position: 'relative'
  94. }
  95. };
  96.  
  97. export { CardSection};
Add Comment
Please, Sign In to add comment