StepStart.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /**
  2. * 新充电流程:充电前的模块
  3. * @邠心vbe on 2023/06/20
  4. */
  5. import React from 'react';
  6. import { View, Image, StyleSheet, ScrollView, Pressable } from 'react-native';
  7. import app from '../../../app.json';
  8. import Button, { ElevationObject } from '../../components/Button';
  9. import TextView from '../../components/TextView';
  10. import { ChargeStyle } from '../chargeV2/Charging';
  11. import { PaymentList } from '../chargeV2/Payment';
  12. import DiscountView from './DiscountView';
  13. import PaymentListV2 from '../chargeV2/PaymentListV2';
  14. import PagerUtil from '../chargeV2/PagerUtil';
  15. import utils from '../../utils/utils';
  16. export default StepStart = ({
  17. idleFeeConfig,
  18. connectorInfo={},
  19. currentPayment,
  20. onPaymentMethodChanged,
  21. onAuthenticate,
  22. selectedVoucher={}
  23. }) => {
  24. return (
  25. <ScrollView
  26. style={ui.flex1}
  27. contentContainerStyle={$padding(16)}>
  28. <View style={ui.center}>
  29. <Image
  30. style={styles.stepImage}
  31. resizeMode="contain"
  32. source={require('../../images/site/charging-status-unknow.png')}/>
  33. <TextView style={styles.stepTitle}>{$t('charging.stepInsertConnector')}</TextView>
  34. <TextView style={styles.stepDesc}>{$t('charging.stepInsertConnectorDesc')}</TextView>
  35. </View>
  36. <View style={styles.infoRow}>
  37. <View style={styles.infoCard}>
  38. <TextView style={styles.infoTitle}>{$t('charging.labelType')}</TextView>
  39. <TextView
  40. numberOfLines={1}
  41. ellipsizeMode="tail"
  42. style={styles.infoText}>{connectorInfo.chargeType}{connectorInfo.wattage || "AC22"}</TextView>
  43. <TextView style={styles.infoDesc}></TextView>
  44. </View>
  45. <View style={styles.infoCard}>
  46. <TextView style={styles.infoTitle}>{$t('charging.labelPower')}</TextView>
  47. <TextView
  48. numberOfLines={1}
  49. ellipsizeMode="tail"
  50. style={styles.infoText}>{connectorInfo.wattage || "0"} kW{/*connectorInfo.rateType*/}</TextView>
  51. <TextView style={styles.infoDesc}></TextView>
  52. </View>
  53. </View>
  54. <View style={styles.infoRow}>
  55. <View style={styles.infoCard}>
  56. <DiscountView visible={connectorInfo.hasDiscount}/>
  57. <TextView style={styles.infoTitle}>{$t('charging.labelRate')}</TextView>
  58. {/* <Text
  59. numberOfLines={1}
  60. ellipsizeMode="tail"
  61. style={styles.infoText}>{connectorInfo.rate || "0.00"}/{connectorInfo.rateType || "kWh"}</Text> */}
  62. <TextView
  63. numberOfLines={2}
  64. ellipsizeMode="tail"
  65. style={styles.infoText}>{connectorInfo.rates || "S$0.00/kWh"}</TextView>
  66. {(app.modules.nationally && connectorInfo.rates != connectorInfo.userRates) && (
  67. <TextView
  68. numberOfLines={1}
  69. ellipsizeMode="tail"
  70. style={styles.infoDesc}>({connectorInfo.userRates || "S$0.00/kWh"})</TextView>)
  71. }
  72. </View>
  73. <View style={styles.infoCard}>
  74. <TextView style={styles.infoTitle}>{$t('charging.labelStatus')}</TextView>
  75. <TextView
  76. style={[ChargeStyle.statusAuthenticated, styles.infoStatus]}>
  77. {$t('charging.statusAvailable')}
  78. </TextView>
  79. </View>
  80. </View>
  81. <EndView/>
  82. { (idleFeeConfig && idleFeeConfig.idleFee) &&
  83. <View>
  84. <TextView style={styles.label}>Idle Fee Detail</TextView>
  85. { utils.isNotEmpty(idleFeeConfig.repeatDay) &&
  86. <TextView style={styles.idleFeeText}>
  87. Effective Days: {utils.join(idleFeeConfig.repeatDay, ", ")}
  88. </TextView>
  89. }
  90. { idleFeeConfig.allDay
  91. ? <TextView style={styles.idleFeeText}>Effective Time:All day</TextView>
  92. : (utils.isNotEmpty(idleFeeConfig.startTime) && utils.isNotEmpty(idleFeeConfig.endTime)) &&
  93. <TextView style={styles.idleFeeText}>Effective Time:{idleFeeConfig.startTime + " - " + idleFeeConfig.endTime}</TextView>
  94. }
  95. { utils.isNotEmpty(idleFeeConfig.idleGracePeriod) &&
  96. <TextView style={styles.idleFeeText}>Grace Period: {idleFeeConfig.idleGracePeriod} min</TextView>
  97. }
  98. <TextView style={styles.idleFeeText}>Charging Rate: {idleFeeConfig.idleFee}/{idleFeeConfig.idleInterval} min </TextView>
  99. { utils.isNotEmpty(idleFeeConfig.idleFeeCap) &&
  100. <TextView style={styles.idleFeeText}>Idle Fee Cap: {idleFeeConfig.idleFeeCap}</TextView>
  101. }
  102. </View>
  103. }
  104. <EndView half/>
  105. <View style={ui.flexc}>
  106. <TextView style={[styles.label, ui.flex1]}>{$t('charging.paymentMethod')}</TextView>
  107. { app.v3.vouchers &&
  108. <TextView style={[styles.label, {flex: 1, paddingLeft: 16}]}>{$t('voucher.vouchers')}</TextView>
  109. }
  110. </View>
  111. <View style={ui.flexc}>
  112. <View style={ui.flex1}>
  113. { app.charge.paymentMethod
  114. ? <PaymentListV2
  115. payType={currentPayment}
  116. chargeBoxId={connectorInfo.chargeBoxId}
  117. onMethodChange={onPaymentMethodChanged}/>
  118. : <PaymentList
  119. payType={currentPayment}
  120. onMethodChange={onPaymentMethodChanged}/>
  121. }
  122. </View>
  123. { app.v3.vouchers &&
  124. <Pressable
  125. style={styles.voucherLayout}
  126. onPress={() => PagerUtil.toSelectVoucher(connectorInfo.chargeBoxId, connectorInfo.connectorId)}>
  127. <MaterialCommunityIcons
  128. name="ticket-percent"
  129. size={35}
  130. color={colorAccent}/>
  131. { utils.isNotEmpty(selectedVoucher.userVoucherId)
  132. ? <View style={styles.vouchersView}>
  133. <TextView
  134. style={styles.voucherName}
  135. numberOfLines={1}>
  136. {selectedVoucher.voucherName}
  137. </TextView>
  138. <TextView
  139. style={styles.voucherDesc}
  140. numberOfLines={1}>
  141. {selectedVoucher.voucherDesc}
  142. </TextView>
  143. </View>
  144. : <View style={styles.vouchersView}>
  145. <TextView style={styles.selectText}>{$t("voucher.selectVoucher")}</TextView>
  146. </View>
  147. }
  148. <FontAwesome6
  149. name={"angle-right"}
  150. size={16}
  151. color={colorCancel}
  152. />
  153. </Pressable>
  154. }
  155. </View>
  156. <Button
  157. style={styles.buttonView}
  158. text={$t('charging.btnAuthenticate')}
  159. elevation={1.5}
  160. borderRadius={6}
  161. onClick={onAuthenticate}/>
  162. </ScrollView>
  163. );
  164. }
  165. const styles = StyleSheet.create({
  166. stepImage: {
  167. width: $vw(70),
  168. height: $vw(16),
  169. margin: 16
  170. },
  171. stepTitle: {
  172. fontSize: 24,
  173. fontWeight: 'bold',
  174. color: colorAccent
  175. },
  176. stepDesc: {
  177. color: textPrimary,
  178. fontSize: 16,
  179. textAlign: 'center',
  180. ...$padding(0, 32, 48)
  181. },
  182. infoRow: {
  183. marginLeft: 16,
  184. marginBottom: 16,
  185. flexDirection: 'row'
  186. },
  187. infoCard: {
  188. flex: 1,
  189. paddingTop: 12,
  190. paddingBottom: 12,
  191. borderRadius: 10,
  192. marginRight: 16,
  193. overflow: 'hidden',
  194. alignItems: 'center',
  195. ...ElevationObject(5),
  196. backgroundColor: colorLight,
  197. },
  198. infoTitle: {
  199. color: textPrimary,
  200. fontSize: 12,
  201. paddingTop: 1
  202. },
  203. infoText: {
  204. color: textPrimary,
  205. fontSize: 15,
  206. textAlign: 'center',
  207. fontWeight: 'bold',
  208. ...$padding(12, 6)
  209. },
  210. infoDesc: {
  211. color: textPrimary,
  212. fontSize: 12,
  213. marginTop: -12,
  214. paddingBottom: 8
  215. },
  216. infoStatus: {
  217. fontSize: 16,
  218. fontWeight: 'bold',
  219. ...$padding(16, 8)
  220. },
  221. label: {
  222. color: '#000',
  223. fontSize: 14,
  224. fontWeight: 'bold',
  225. paddingTop: 16,
  226. paddingBottom: 8
  227. },
  228. buttonView: {
  229. marginTop: 8,
  230. marginBottom: 16
  231. },
  232. voucherLayout: {
  233. flex: 1,
  234. padding: 12,
  235. maxWidth: $vw(50) - 24,
  236. borderRadius: 10,
  237. marginLeft: 16,
  238. marginBottom: 12,
  239. alignItems: 'center',
  240. flexDirection: 'row',
  241. ...ElevationObject(5),
  242. backgroundColor: colorLight,
  243. },
  244. vouchersView: {
  245. flex: 1,
  246. paddingLeft: 8,
  247. flexWrap: 'wrap',
  248. alignItems: 'center',
  249. flexDirection: 'row'
  250. },
  251. selectText: {
  252. flex: 1,
  253. color: textSecondary,
  254. fontSize: 15,
  255. fontWeight: 'bold'
  256. },
  257. voucherName: {
  258. color: textPrimary,
  259. fontSize: 15,
  260. paddingLeft: 8,
  261. fontWeight: 'bold'
  262. },
  263. voucherDesc: {
  264. color: textSecondary,
  265. fontSize: 12,
  266. paddingLeft: 8,
  267. paddingRight: 16
  268. },
  269. idleFeeText: {
  270. color: textSecondary,
  271. fontSize: 12,
  272. paddingLeft: 4,
  273. paddingBottom: 4
  274. }
  275. })