carInformation.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import { View, Text, StyleSheet, Pressable, TextInput } from 'react-native';
  2. import NormalInput from '../../../global/normal_input';
  3. import NormalButton from '../../../global/normal_button';
  4. import { useState } from 'react';
  5. import useSignUpStore from '../../../../providers/signup_form_store';
  6. type CarInformationProps = {
  7. goToNextPage: () => void;
  8. goToChooseCarPage: () => void;
  9. };
  10. const CarInformation: React.FC<CarInformationProps> = ({
  11. goToNextPage,
  12. goToChooseCarPage
  13. }) => {
  14. const { signUpFormData } = useSignUpStore();
  15. const [error, setError] = useState('');
  16. const handleNext = () => {
  17. if (
  18. signUpFormData.selectedCarBrand === '0000' ||
  19. signUpFormData.selectedCarSeries === '0000' ||
  20. signUpFormData.selectedCarModel === '0000'
  21. ) {
  22. setError('請確保所有資料都已填寫。');
  23. } else {
  24. setError('');
  25. goToNextPage();
  26. }
  27. };
  28. // const vehicleTypeFieldPlaceholder = signUpFormData.selectedCarBrand
  29. // ? signUpFormData.selectedCarBrand
  30. // : '車輛品牌';
  31. // const vehicleModelFieldPlaceholder = signUpFormData.selectedCarSeries
  32. // ? signUpFormData.selectedCarSeries
  33. // : '車輛型號';
  34. // const licensePlateFieldPlaceholder = signUpFormData.selectedCarModel
  35. // ? signUpFormData.selectedCarModel
  36. // : '車輛號碼';
  37. return (
  38. <>
  39. <View style={styles.container}>
  40. <Text style={styles.text}>您的車輛</Text>
  41. <View
  42. style={{
  43. display: 'flex',
  44. flexDirection: 'column',
  45. gap: 10
  46. }}
  47. >
  48. <Pressable
  49. style={styles.button}
  50. onPress={goToChooseCarPage}
  51. >
  52. <TextInput
  53. style={styles.fakeTextInput}
  54. placeholder="車輛品牌"
  55. editable={false}
  56. pointerEvents="none"
  57. ></TextInput>
  58. <TextInput
  59. style={styles.fakeTextInput}
  60. placeholder="車輛型號"
  61. editable={false}
  62. pointerEvents="none"
  63. ></TextInput>
  64. <TextInput
  65. style={styles.fakeTextInput}
  66. placeholder="車輛號碼"
  67. editable={false}
  68. pointerEvents="none"
  69. ></TextInput>
  70. </Pressable>
  71. <NormalButton
  72. title={<Text style={{ color: '#fff' }}>下一步</Text>}
  73. onPress={handleNext}
  74. extendedStyle={{}}
  75. />
  76. {error && <Text style={styles.errorMessage}>{error}</Text>}
  77. <NormalButton
  78. title={<Text style={{ color: '#888888' }}>略過</Text>}
  79. onPress={goToNextPage}
  80. extendedStyle={{ backgroundColor: 'transparent' }}
  81. />
  82. </View>
  83. </View>
  84. </>
  85. );
  86. };
  87. const styles = StyleSheet.create({
  88. container: {
  89. flex: 1,
  90. marginHorizontal: 20
  91. },
  92. button: { flex: 1, gap: 10, marginTop: 5 },
  93. fakeTextInput: {
  94. maxWidth: '100%',
  95. fontSize: 16,
  96. borderWidth: 1,
  97. padding: 20,
  98. borderRadius: 12,
  99. borderColor: '#bbbbbb'
  100. },
  101. text: {
  102. fontSize: 20,
  103. paddingBottom: 10
  104. },
  105. errorMessage: {
  106. fontSize: 14,
  107. color: '#ff0033',
  108. fontWeight: '400',
  109. marginLeft: 10,
  110. marginTop: 10
  111. }
  112. });
  113. export default CarInformation;