Advertisement
Guest User

CardWhite

a guest
Feb 25th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. import * as React from 'react';
  2. import { connect } from 'react-redux'
  3. import { View, Text, Image, TouchableOpacity } from 'react-native';
  4. import { Grid, Col, Icon } from 'native-base'
  5. import gStyle from '../styles/StylesGlobal';
  6. import { Actions } from 'react-native-router-flux';
  7. import { styles } from './Styles/StylesPromote';
  8. import { formattedTimeAgo } from '../../utils/textUtils'
  9. import { formatNumber, formatKm, formatDistance, formatScore } from '../../utils/Numbers'
  10. class TalentSearchPromote extends React.Component {
  11. onGoesTo = (data) => {
  12.  
  13. const {
  14. saveEmployee
  15. } = this.props
  16.  
  17. saveEmployee(data).then(() => {
  18. if (this.props.blocked === 'block') {
  19. Actions.DetailBlocked()
  20. } else if (this.props.blocked === 'unblock') {
  21. Actions.DetailNonBlocked()
  22. } else if (this.props.act === 'DetailPelamar') {
  23. Actions.DetailPelamar({ status: this.props.status })
  24. }
  25. })
  26.  
  27. }
  28.  
  29. renderBirth(data) {
  30. let result = formattedTimeAgo(data)
  31. let split = result.split(' ')
  32. return split[0] + " Tahun"
  33. }
  34.  
  35. medaliAsisten = (data) => {
  36. let medaliZero = 5
  37. let dataMedali = []
  38. const medali = parseInt(data);
  39. // let html = <Image source={require('./medali.png')} style={styles.widthImgMedal} />;
  40.  
  41. let medaliHtml = (
  42. <View >
  43. <Image source={require('./medali.png')} style={styles.widthImgMedal} />
  44. </View>
  45. )
  46.  
  47. let medaliZeroHtml = (
  48. <View >
  49. <View style={styles.widthImgMedal} />
  50. </View>
  51. )
  52.  
  53.  
  54. if (medali > 0) {
  55. medaliZero -= medali
  56. for (let i = 0; i < medali; i++) {
  57. dataMedali.push(medaliHtml)
  58. }
  59.  
  60. for (let i = 0; i < medaliZero; i++) {
  61. // dataMedali.push(medaliZeroHtml)
  62. }
  63. } else if (medaliZero == 5) {
  64. for (let i = 0; i < medaliZero; i++) {
  65. // dataMedali.push(medaliZeroHtml)
  66. }
  67. }
  68.  
  69.  
  70. return dataMedali;
  71. }
  72.  
  73. render() {
  74. // const { data } = this.props
  75. console.log('Props Card', this.props)
  76.  
  77. const {
  78. data
  79. } = this.props
  80.  
  81. const {
  82. user, expectedSalary, medal, score, currentSelfPromotion, distance, random, expectedJobCategories
  83. } = data ? data : {}
  84.  
  85. const {
  86. fullname, village, birthdate, photo, photoUrl, employeePsychotestResult, gender, maritalStatus
  87. } = user ? user : {}
  88.  
  89. const {
  90. district
  91. } = village ? village : {}
  92.  
  93. const {
  94. city
  95. } = district ? district : {}
  96.  
  97. const {
  98. name
  99. } = city ? city : {}
  100.  
  101. return (
  102. <View>
  103. <TouchableOpacity style={styles.marginTop10} onPress={() => this.onGoesTo(data)}>
  104. <View style={[gStyle.globalWrapper, styles.shadowCard]}>
  105. <Grid>
  106. <Col style={{ width: 105 }}>
  107. <View style={styles.wrapperImgProfil}>
  108. <Image source={photo ? { uri: photoUrl } : require('../../assets/user-profile.png')} style={styles.profilImg} resizeMode='cover' />
  109. </View>
  110. </Col>
  111. <Col>
  112. <View style={gStyle.globalFlexLeft}>
  113. <Text
  114. numberOfLines={1}
  115. style={[gStyle.globalTextQuicksandsSemi, gStyle.globalFont16, gStyle.FONT_CAPITALIZE]} >
  116. {fullname ? fullname.substring(0, 14) : "Tidak ada nama"}
  117. </Text>
  118. </View>
  119. <View style={{ marginTop: 6 }}>
  120. <Text
  121. numberOfLines={1}
  122. style={[gStyle.globalTextGray]}>
  123. {distance ? formatDistance(distance) + " - " : null} {name ? name : ""}
  124. </Text>
  125. </View>
  126. <View style={[gStyle.globalFlexLeft, { marginTop: 0 }]}>
  127. <Text numberOfLines={1}
  128. style={[gStyle.globalFont14, { color: 'gray' }]}>
  129. {gender && gender === 'female' ? 'Wanita, ' : 'Pria, '}
  130. </Text>
  131. <Text numberOfLines={1}
  132. style={[gStyle.globalFont14, { color: 'gray' }]}>
  133. {maritalStatus && maritalStatus === 'single' ? 'Lajang, ' : 'Menikah, '}
  134. </Text>
  135. <Text
  136. numberOfLines={1}
  137. style={[gStyle.globalFont14, { color: 'gray' }]}>
  138. {birthdate ? this.renderBirth(birthdate) : ""}
  139. </Text>
  140. </View>
  141. <View style={{ marginTop: 10 }} />
  142. <View style={gStyle.globalFlexLeft}>
  143. <View>
  144. <Text>
  145. {medal}/5
  146. </Text>
  147. </View>
  148. <View style={{ marginLeft: 5 }}>
  149. <View style={gStyle.globalFlexLeft}>
  150. {medal ? this.medaliAsisten(medal).reverse() : this.medaliAsisten(0)}
  151. </View>
  152. </View>
  153. </View>
  154. <View style={{ marginTop: 2, display: 'none' }}>
  155. <Text style={[gStyle.globalTextQuicksandsSemi]} >
  156. Rp. {expectedSalary ? formatNumber(expectedSalary) : 0}
  157. </Text>
  158. </View>
  159. </Col>
  160. </Grid>
  161. <View style={[gStyle.UNDERLINE, { marginBottom: 10 }]} />
  162. <View style={gStyle.globalSpaceBetween}>
  163. <View>
  164. <View>
  165. <Text style={gStyle.TEXT_REGULAR_BLACK}>Skor Pekerja : <Text style={styles.skorPoint}>{score ? formatScore(score) : 0}</Text></Text>
  166. </View>
  167. </View>
  168.  
  169. <View style={styles.bgCheckmark}>
  170. <Icon name="md-checkmark" style={styles.chekMark} />
  171. </View>
  172. {/* <View style={[gStyle.globalMarginLeft15]}>
  173. <View style={gStyle.globalFlexRight}>
  174. <View style={{ marginRight: 5 }}>
  175. <Text>
  176. {medal}/5
  177. </Text>
  178. </View>
  179. <View style={gStyle.globalFlexLeft}>
  180. {medal ? this.medaliAsisten(medal).reverse() : this.medaliAsisten(0)}
  181. </View>
  182. </View>
  183. </View> */}
  184. </View>
  185. <View style={[gStyle.UNDERLINE, { marginTop: 10, marginBottom: 10 }]} />
  186. <View>
  187. <Text style={gStyle.TEXT_REGULAR_BLACK}>Tipe Kepribadian :
  188. <Text style={styles.skorPoint}>
  189. {employeePsychotestResult && employeePsychotestResult.personality && employeePsychotestResult.personality.title ? employeePsychotestResult.personality.title : " -"}
  190. </Text>
  191. </Text>
  192. </View>
  193. <View style={{ marginTop: 5 }}>
  194. <Text>
  195. {expectedJobCategories.map((item, i) =>
  196. <Text style={styles.jobCategory}>
  197. {item && item.jobCategory && item.jobCategory.name ? item.jobCategory.name + ', ' : '-'}
  198. </Text>
  199. )}
  200. </Text>
  201. </View>
  202. </View>
  203. </TouchableOpacity>
  204. </View>
  205. )
  206. }
  207. }
  208.  
  209. const mapDispatch = ({ employees }) => ({
  210. saveEmployee: (data) => employees.saveEmployee(data),
  211. })
  212.  
  213. export default connect(null, mapDispatch)(TalentSearchPromote)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement