basicInformation.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { View, Text, StyleSheet } from "react-native";
  2. import NormalInput from "../../../global/normal_input";
  3. import { useState } from "react";
  4. import DateModal from "../../../global/date_input";
  5. import NormalButton from "../../../global/normal_button";
  6. import { SignUpFormData, HandleSignUpFormDataChange } from "../../../../types/signup";
  7. import useSignUpStore from "../../../../providers/signup_form_store";
  8. type basicInformationProps = {
  9. goToNextPage: () => void;
  10. handleFormDataChange: HandleSignUpFormDataChange;
  11. formData: SignUpFormData;
  12. };
  13. const BasicInformation: React.FC<basicInformationProps> = ({ handleFormDataChange, goToNextPage, formData }) => {
  14. const { signUpFormData, setSignUpFormData } = useSignUpStore();
  15. const [error, setError] = useState("");
  16. const handleNext = () => {
  17. if (signUpFormData.name === "" || signUpFormData.password === "" || signUpFormData.birthDate === "") {
  18. setError("請確保所有資料都已填寫。");
  19. } else {
  20. setError("");
  21. goToNextPage();
  22. }
  23. };
  24. return (
  25. <>
  26. <View style={styles.container}>
  27. <Text style={styles.text}>請填妥以下資料</Text>
  28. <View
  29. style={{
  30. display: "flex",
  31. flexDirection: "column",
  32. gap: 10,
  33. }}
  34. >
  35. {/* <NormalInput placeholder="姓名" onChangeText={(text) => handleFormDataChange("name", text)} /> */}
  36. <NormalInput
  37. placeholder="姓名"
  38. onChangeText={(text) => {
  39. setSignUpFormData({ ...signUpFormData, name: text });
  40. }}
  41. />
  42. {/* <NormalInput
  43. placeholder="帳戶密碼"
  44. onChangeText={(text) => handleFormDataChange("password", text)}
  45. secureTextEntry={true}
  46. /> */}
  47. <NormalInput
  48. placeholder="帳戶密碼"
  49. onChangeText={(text) => {
  50. setSignUpFormData({ ...signUpFormData, password: text });
  51. }}
  52. secureTextEntry={true}
  53. />
  54. <View style={{ display: "flex", flexDirection: "row", gap: 10 }}>
  55. {/* await YoYo's code review for gender */}
  56. <NormalInput
  57. placeholder="性別"
  58. onChangeText={(t) => console.log(t)}
  59. extendedStyle={{ width: "50%" }}
  60. />
  61. {/* <DateModal
  62. placeholder={formData.birthDate ? formData.birthDate : "DD/MM/YY"}
  63. onDateChange={(date) => {
  64. handleFormDataChange("birthDate", date);
  65. }}
  66. /> */}
  67. <DateModal
  68. placeholder={signUpFormData.birthDate ? signUpFormData.birthDate : "DD/MM/YY"}
  69. onDateChange={(date) => {
  70. setSignUpFormData({ ...signUpFormData, birthDate: date });
  71. }}
  72. />
  73. </View>
  74. <NormalButton
  75. title={<Text style={{ color: "#fff" }}>下一步</Text>}
  76. onPress={handleNext}
  77. extendedStyle={{}}
  78. />
  79. </View>
  80. {error && <Text style={styles.errorMessage}>{error}</Text>}
  81. </View>
  82. </>
  83. );
  84. };
  85. const styles = StyleSheet.create({
  86. container: {
  87. flex: 1,
  88. marginHorizontal: 20,
  89. },
  90. text: {
  91. fontSize: 20,
  92. paddingBottom: 10,
  93. },
  94. errorMessage: {
  95. fontSize: 14,
  96. color: "#ff0033",
  97. fontWeight: "400",
  98. marginLeft: 10,
  99. marginTop: 10,
  100. },
  101. });
  102. export default BasicInformation;