|
|
@@ -9,17 +9,28 @@ import DropdownSelect from '../../../global/dropdown_select';
|
|
|
type basicInformationProps = {
|
|
|
goToNextPage: () => void;
|
|
|
};
|
|
|
+type BirthdaySelectProps = {
|
|
|
+ onSelect: (year: string, month: string, day: string) => void;
|
|
|
+};
|
|
|
|
|
|
-const BasicInformation: React.FC<basicInformationProps> = ({
|
|
|
- goToNextPage
|
|
|
-}) => {
|
|
|
+const BasicInformation: React.FC<basicInformationProps> = ({ goToNextPage }) => {
|
|
|
const { signUpFormData, setSignUpFormData } = useSignUpStore();
|
|
|
+ const [selectedYear, setSelectedYear] = useState('');
|
|
|
+ const [selectedMonth, setSelectedMonth] = useState('');
|
|
|
+ const [selectedDay, setSelectedDay] = useState('');
|
|
|
+ const [birthDate, setBirthDate] = useState('');
|
|
|
const [error, setError] = useState('');
|
|
|
const handleNext = () => {
|
|
|
+ setSignUpFormData({
|
|
|
+ ...signUpFormData,
|
|
|
+ birthDate: birthDate
|
|
|
+ });
|
|
|
if (
|
|
|
signUpFormData.nickName === '' ||
|
|
|
signUpFormData.password === '' ||
|
|
|
- signUpFormData.birthDate === ''
|
|
|
+ signUpFormData.gender === '' ||
|
|
|
+ signUpFormData.birthDateMonth === '' ||
|
|
|
+ signUpFormData.birthDateDay === ''
|
|
|
) {
|
|
|
setError('請確保所有資料都已填寫。');
|
|
|
} else {
|
|
|
@@ -28,19 +39,46 @@ const BasicInformation: React.FC<basicInformationProps> = ({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const nameFieldPlaceholder = signUpFormData.nickName
|
|
|
- ? signUpFormData.nickName
|
|
|
- : '暱稱';
|
|
|
+ const nameFieldPlaceholder = signUpFormData.nickName ? signUpFormData.nickName : '暱稱';
|
|
|
+
|
|
|
+ const birthMonthOptions = Array.from({ length: 12 }, (_, i) => {
|
|
|
+ const month = i + 1;
|
|
|
+ return { label: month.toString(), value: month.toString() };
|
|
|
+ });
|
|
|
+
|
|
|
+ const birthDayOptions = Array.from({ length: 31 }, (_, i) => {
|
|
|
+ const day = i + 1;
|
|
|
+ return { label: day.toString(), value: day.toString() };
|
|
|
+ });
|
|
|
|
|
|
const genderDropdownOptions = [
|
|
|
{ label: '男', value: 'man' },
|
|
|
{ label: '女', value: 'woman' }
|
|
|
];
|
|
|
+
|
|
|
+ const handleSelect = (type: string, value: string) => {
|
|
|
+ if (type === 'year') {
|
|
|
+ setSelectedYear(value);
|
|
|
+ } else if (type === 'month') {
|
|
|
+ setSelectedMonth(value);
|
|
|
+ } else if (type === 'day') {
|
|
|
+ setSelectedDay(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectedMonth && selectedDay) {
|
|
|
+ const day = selectedDay.padStart(2, '0');
|
|
|
+ const month = selectedMonth.padStart(2, '0');
|
|
|
+ const date = `${day}/${month}/11`;
|
|
|
+ setBirthDate(date);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<View style={styles.container}>
|
|
|
<Text style={styles.text}>請填妥以下資料</Text>
|
|
|
<View
|
|
|
+ className=""
|
|
|
style={{
|
|
|
display: 'flex',
|
|
|
flexDirection: 'column',
|
|
|
@@ -69,13 +107,7 @@ const BasicInformation: React.FC<basicInformationProps> = ({
|
|
|
secureTextEntry={true}
|
|
|
/>
|
|
|
|
|
|
- <View
|
|
|
- style={{
|
|
|
- display: 'flex',
|
|
|
- flexDirection: 'row',
|
|
|
- gap: 10
|
|
|
- }}
|
|
|
- >
|
|
|
+ <View className="">
|
|
|
<DropdownSelect
|
|
|
onSelect={(value) => {
|
|
|
setSignUpFormData({
|
|
|
@@ -85,23 +117,52 @@ const BasicInformation: React.FC<basicInformationProps> = ({
|
|
|
}}
|
|
|
dropdownOptions={genderDropdownOptions}
|
|
|
placeholder={'性別'}
|
|
|
- extendedStyle={{ paddingLeft: 10 }}
|
|
|
+ extendedStyle={{ paddingLeft: 10, paddingVertical: 13 }}
|
|
|
/>
|
|
|
|
|
|
- <DateModal
|
|
|
- placeholder={
|
|
|
- signUpFormData.birthDate
|
|
|
- ? signUpFormData.birthDate
|
|
|
- : 'DD/MM/YY'
|
|
|
- }
|
|
|
+ {/* <DateModal
|
|
|
+ placeholder={signUpFormData.birthDate ? signUpFormData.birthDate : 'DD/MM/YY'}
|
|
|
onDateChange={(date) => {
|
|
|
setSignUpFormData({
|
|
|
...signUpFormData,
|
|
|
birthDate: date
|
|
|
});
|
|
|
}}
|
|
|
+ /> */}
|
|
|
+ </View>
|
|
|
+
|
|
|
+ <View className=" flex flex-row ">
|
|
|
+ {/* <DropdownSelect
|
|
|
+ onSelect={(value) => handleSelect('month', value)}
|
|
|
+ dropdownOptions={birthMonthOptions}
|
|
|
+ placeholder={'生日月份'}
|
|
|
+ extendedStyle={{ paddingLeft: 10, paddingVertical: 13, marginRight: 6 }}
|
|
|
+ /> */}
|
|
|
+
|
|
|
+ <DropdownSelect
|
|
|
+ onSelect={(value) => {
|
|
|
+ setSignUpFormData({
|
|
|
+ ...signUpFormData,
|
|
|
+ birthDateMonth: value.padStart(2, '0')
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ dropdownOptions={birthMonthOptions}
|
|
|
+ placeholder={'生日月份'}
|
|
|
+ extendedStyle={{ paddingLeft: 10, paddingVertical: 13, marginRight: 6 }}
|
|
|
+ />
|
|
|
+ <DropdownSelect
|
|
|
+ onSelect={(value) => {
|
|
|
+ setSignUpFormData({
|
|
|
+ ...signUpFormData,
|
|
|
+ birthDateDay: value.padStart(2, '0')
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ dropdownOptions={birthDayOptions}
|
|
|
+ placeholder={'日期'}
|
|
|
+ extendedStyle={{ paddingLeft: 10, paddingVertical: 13, marginLeft: 6 }}
|
|
|
/>
|
|
|
</View>
|
|
|
+
|
|
|
<NormalButton
|
|
|
title={<Text style={{ color: '#fff' }}>下一步</Text>}
|
|
|
onPress={handleNext}
|