bookingSuccessPageComponent.tsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import { View, Text, ScrollView, StyleSheet } from 'react-native';
  2. import { SafeAreaView } from 'react-native-safe-area-context';
  3. import NormalButton from '../global/normal_button';
  4. import { TickLogoSvg } from '../global/SVG';
  5. import { router, useLocalSearchParams, useNavigation } from 'expo-router';
  6. import useBookingStore from '../../providers/booking_store';
  7. import { useEffect } from 'react';
  8. const BookingSuccessPageComponent = () => {
  9. const {
  10. bookTime,
  11. carID,
  12. date,
  13. chargingWatt,
  14. connectorID,
  15. price,
  16. stationID,
  17. user,
  18. paymentFee,
  19. carCapacitance,
  20. bookDateForDisplay,
  21. bookTimeForDisplay,
  22. chargeStationAddressForDisplay,
  23. chargeStationNameForDisplay,
  24. carNameForDisplay
  25. } = useBookingStore();
  26. const navigation = useNavigation();
  27. useEffect(() => {
  28. navigation.setOptions({
  29. gestureEnabled: false
  30. });
  31. }, [navigation]);
  32. const params = useLocalSearchParams();
  33. console.log('params', params);
  34. const formatOrderId = params.formatOrderId;
  35. return (
  36. <SafeAreaView style={{ flex: 1, backgroundColor: 'white' }} edges={['top', 'left', 'right']}>
  37. <ScrollView className="flex-1">
  38. <View>
  39. <View className="flex-row pl-8 pt-8 space-x-4 items-center">
  40. <TickLogoSvg />
  41. <Text className="text-3xl">成功預約</Text>
  42. </View>
  43. <View
  44. className="m-4"
  45. style={{
  46. borderWidth: 1,
  47. borderColor: '#EEEEEE',
  48. borderRadius: 12
  49. }}
  50. >
  51. <View className="space-y-3 py-4 mx-[5%]">
  52. <View className="flex-1 flex-row items-center ">
  53. <View className="flex-1 flex-column">
  54. <Text style={styles.grayColor} className="text-xs ">
  55. 時間日期
  56. </Text>
  57. <Text style={styles.greenColor} className="text-4xl pt-2 ">
  58. {bookDateForDisplay} · {bookTimeForDisplay}
  59. </Text>
  60. </View>
  61. </View>
  62. <View className="flex-1 flex-column justify-center">
  63. <Text style={styles.grayColor} className="text-xs">
  64. 充電地點
  65. </Text>
  66. <Text style={styles.greenColor} className="text-xl">
  67. {chargeStationNameForDisplay}
  68. </Text>
  69. <Text style={styles.grayColor} className="text-base">
  70. {chargeStationAddressForDisplay}
  71. </Text>
  72. </View>
  73. <View className="flex-1 flex-row items-center ">
  74. <View className="flex-column flex-1">
  75. <Text style={styles.grayColor} className="text-xs">
  76. 方案
  77. </Text>
  78. {chargingWatt === '' ? (
  79. <>
  80. <Text style={styles.greenColor} className="text-lg">
  81. 按每度電結算
  82. </Text>
  83. <Text style={styles.grayColor} className="text-sm">
  84. 充滿停機預估費用
  85. </Text>
  86. </>
  87. ) : (
  88. <>
  89. <Text style={styles.greenColor} className="text-lg">
  90. 按每度電結算
  91. </Text>
  92. <Text style={styles.grayColor} className="text-sm">
  93. 度數: {chargingWatt.split('~')[0]}
  94. </Text>
  95. </>
  96. )}
  97. </View>
  98. <View className="flex-column flex-1">
  99. <Text style={styles.grayColor} className="text-xs">
  100. 車輛
  101. </Text>
  102. <Text style={styles.greenColor} className="text-lg">
  103. {carNameForDisplay}
  104. </Text>
  105. </View>
  106. </View>
  107. </View>
  108. </View>
  109. </View>
  110. <View className="mx-[5%]">
  111. <Text className="text-xl py-4">收費概要</Text>
  112. <View className="flex-row justify-between">
  113. <Text className="text-base">充電費用</Text>
  114. <Text className="text-base">HK$ {paymentFee}</Text>
  115. </View>
  116. <Text style={styles.grayColor} className="text-base">
  117. 按每度電結算: {chargingWatt.split('~')[0]}
  118. </Text>
  119. <View className="h-0.5 my-3 bg-[#f4f4f4]" />
  120. <View className="flex-row justify-between ">
  121. <Text className="text-xl">總計</Text>
  122. <Text className="text-xl">HK$ {paymentFee}</Text>
  123. </View>
  124. <View className="w-full h-1 my-4 bg-[#DBE4E8]" />
  125. <View className="space-y-4">
  126. <Text className="text-xl ">付款資訊</Text>
  127. <View>
  128. <Text className="text-base" style={styles.grayColor}>
  129. 訂單編號
  130. </Text>
  131. <Text className="text-base">{formatOrderId}</Text>
  132. </View>
  133. <View>
  134. <Text className="text-base" style={styles.grayColor}>
  135. 付款方式
  136. </Text>
  137. <Text className="text-base">預付銀包</Text>
  138. </View>
  139. {/* <View>
  140. <Text
  141. className="text-base"
  142. style={styles.grayColor}
  143. >
  144. 電郵地址
  145. </Text>
  146. <Text className="text-base">
  147. mikechan123@gmail.com
  148. </Text>
  149. </View> */}
  150. </View>
  151. <View className="my-4 pb-8">
  152. <NormalButton
  153. title={
  154. <Text
  155. style={{
  156. color: 'white',
  157. fontSize: 16,
  158. fontWeight: '800'
  159. }}
  160. >
  161. 返回主頁
  162. </Text>
  163. }
  164. onPress={() => router.replace('bookingMenuPage')}
  165. extendedStyle={{ padding: 24 }}
  166. />
  167. </View>
  168. </View>
  169. </ScrollView>
  170. </SafeAreaView>
  171. );
  172. };
  173. export default BookingSuccessPageComponent;
  174. const styles = StyleSheet.create({
  175. grayColor: {
  176. color: '#888888'
  177. },
  178. greenColor: {
  179. color: '#02677D'
  180. }
  181. });