|
|
|
@ -8,6 +8,8 @@ import { |
|
|
|
|
Platform, |
|
|
|
|
Dimensions, |
|
|
|
|
Appearance, |
|
|
|
|
KeyboardAvoidingView, |
|
|
|
|
TouchableWithoutFeedback, |
|
|
|
|
} from "react-native"; |
|
|
|
|
import React, { useEffect, useState } from "react"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
@ -28,7 +30,9 @@ import tw from "tailwind-rn"; |
|
|
|
|
import Colors from "../../constants/Colors"; |
|
|
|
|
import fontSize from "../../constants/fontSize"; |
|
|
|
|
|
|
|
|
|
//variables
|
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
|
const { height } = Dimensions.get("window"); |
|
|
|
|
|
|
|
|
|
const Address = ({ |
|
|
|
|
user, |
|
|
|
@ -243,190 +247,204 @@ const Address = ({ |
|
|
|
|
<SafeAreaView |
|
|
|
|
style={{ |
|
|
|
|
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, |
|
|
|
|
position: "relative", |
|
|
|
|
// position: "relative",
|
|
|
|
|
flex: 1, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<Navbar |
|
|
|
|
headerOptions={{ |
|
|
|
|
logo: false, |
|
|
|
|
menu: profilePage ? false : false, |
|
|
|
|
hamburgerMenu: false, |
|
|
|
|
title: profilePage ? "اطلاعات کاربری" : "", |
|
|
|
|
bookmark: profilePage ? false : false, |
|
|
|
|
qr: false, |
|
|
|
|
back: true, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<ScrollView |
|
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
|
style={styles.container} |
|
|
|
|
> |
|
|
|
|
<View style={tw("w-full flex pb-4")}> |
|
|
|
|
{/* <MapSelector /> */} |
|
|
|
|
<Header |
|
|
|
|
title="اطلاعات هویتی" |
|
|
|
|
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="نام" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="right" |
|
|
|
|
name="firstName" |
|
|
|
|
maxlength="40" |
|
|
|
|
value={ |
|
|
|
|
profilePage ? profileFields.firstName : addressFields?.firstName |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, firstName: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(val) => val} |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="نام خانوادگی" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="right" |
|
|
|
|
name="lastName" |
|
|
|
|
maxlength="60" |
|
|
|
|
value={ |
|
|
|
|
profilePage ? profileFields.lastName : addressFields?.lastName |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, lastName: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(val) => val} |
|
|
|
|
/> |
|
|
|
|
{profilePage && ( |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="کد ملی" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="nationalId" |
|
|
|
|
maxlength="10" |
|
|
|
|
value={profileFields.nationalId} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
setProfileFields({ ...profileFields, nationalId: value }) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={onInput.numberOnly} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
<View style={tw("mt-4")}></View> |
|
|
|
|
<Header |
|
|
|
|
title="شماره تماس" |
|
|
|
|
text="( شماره موبایل و شماره تلفن ثابت خود را
|
|
|
|
|
<ScrollView style={tw("flex-1 px-4")}> |
|
|
|
|
<KeyboardAvoidingView behavior={"padding"} style={[{ height }]}> |
|
|
|
|
<TouchableWithoutFeedback> |
|
|
|
|
<View style={tw("flex-1")}> |
|
|
|
|
<Navbar |
|
|
|
|
headerOptions={{ |
|
|
|
|
logo: false, |
|
|
|
|
menu: profilePage ? false : false, |
|
|
|
|
hamburgerMenu: false, |
|
|
|
|
title: profilePage ? "اطلاعات کاربری" : "", |
|
|
|
|
bookmark: profilePage ? false : false, |
|
|
|
|
qr: false, |
|
|
|
|
back: true, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<Header |
|
|
|
|
title="اطلاعات هویتی" |
|
|
|
|
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="نام" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="right" |
|
|
|
|
name="firstName" |
|
|
|
|
maxlength="40" |
|
|
|
|
value={ |
|
|
|
|
profilePage |
|
|
|
|
? profileFields.firstName |
|
|
|
|
: addressFields?.firstName |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, firstName: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(val) => val} |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="نام خانوادگی" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="right" |
|
|
|
|
name="lastName" |
|
|
|
|
maxlength="60" |
|
|
|
|
value={ |
|
|
|
|
profilePage ? profileFields.lastName : addressFields?.lastName |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, lastName: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(val) => val} |
|
|
|
|
/> |
|
|
|
|
{profilePage && ( |
|
|
|
|
<CustomTextInput |
|
|
|
|
keyboardType="numeric" |
|
|
|
|
label="کد ملی" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="nationalId" |
|
|
|
|
maxlength="10" |
|
|
|
|
value={profileFields.nationalId} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
setProfileFields({ ...profileFields, nationalId: value }) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(text) => onInput.numberOnly(text)} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
<View style={tw("mt-4")}></View> |
|
|
|
|
<Header |
|
|
|
|
title="شماره تماس" |
|
|
|
|
text="( شماره موبایل و شماره تلفن ثابت خود را
|
|
|
|
|
به همراه پیش شماره وارد کنید )" |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="شماره موبایل" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="cellphone" |
|
|
|
|
maxlength="11" |
|
|
|
|
value={ |
|
|
|
|
profilePage ? profileFields.cellphone : addressFields?.cellphone |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, cellphone: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={onInput.phonenumber} |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="شماره تلفن" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="phone" |
|
|
|
|
maxlength="11" |
|
|
|
|
value={profilePage ? profileFields.phone : addressFields?.phone} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, phone: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={onInput.phonenumber} |
|
|
|
|
/> |
|
|
|
|
<View style={tw("mt-4")}></View> |
|
|
|
|
<Header |
|
|
|
|
title="آدرس" |
|
|
|
|
text="( لطفا نام استان و شهرستان و آدرس |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
keyboardType="numeric" |
|
|
|
|
label="شماره موبایل" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="cellphone" |
|
|
|
|
maxlength="11" |
|
|
|
|
value={ |
|
|
|
|
profilePage |
|
|
|
|
? profileFields.cellphone |
|
|
|
|
: addressFields?.cellphone |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, cellphone: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(text) => onInput.numberOnly(text)} |
|
|
|
|
/> |
|
|
|
|
<CustomTextInput |
|
|
|
|
keyboardType="numeric" |
|
|
|
|
label="شماره تلفن" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="phone" |
|
|
|
|
maxlength="11" |
|
|
|
|
value={profilePage ? profileFields.phone : addressFields?.phone} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, phone: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(text) => onInput.numberOnly(text)} |
|
|
|
|
/> |
|
|
|
|
<View style={tw("mt-4")}></View> |
|
|
|
|
<Header |
|
|
|
|
title="آدرس" |
|
|
|
|
text="( لطفا نام استان و شهرستان و آدرس |
|
|
|
|
خود را با دقت تکمیل نمایید )" |
|
|
|
|
/> |
|
|
|
|
<View style={tw("w-full mt-4")}> |
|
|
|
|
<Select |
|
|
|
|
defaultValue={ |
|
|
|
|
profilePage |
|
|
|
|
? provinces?.filter( |
|
|
|
|
(province) => province.id === profileFields.provinceId |
|
|
|
|
)[0]?.name || province[0] |
|
|
|
|
: city[0] |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
value === "استان" ? {} : onChange(name, value) |
|
|
|
|
} |
|
|
|
|
options={province} |
|
|
|
|
width={"100%"} |
|
|
|
|
name="provinceId" |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View style={tw("w-full mt-4")}> |
|
|
|
|
<Select |
|
|
|
|
defaultValue={ |
|
|
|
|
profilePage |
|
|
|
|
? cities?.filter( |
|
|
|
|
(city) => city.id === profileFields.cityId |
|
|
|
|
)[0]?.name || city[0] |
|
|
|
|
: city[0] |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
value === "شهر" ? {} : onChange(name, value) |
|
|
|
|
} |
|
|
|
|
options={city} |
|
|
|
|
width={"100%"} |
|
|
|
|
name="cityId" |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View style={tw("mb-4")}> |
|
|
|
|
<CustomTextInput |
|
|
|
|
label="کد پستی" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="postalCode" |
|
|
|
|
maxlength="60" |
|
|
|
|
value={ |
|
|
|
|
profilePage |
|
|
|
|
? profileFields.postalCode |
|
|
|
|
: addressFields?.postalCode |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ ...profileFields, postalCode: value }) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(val) => val} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
/> |
|
|
|
|
<View style={tw("w-full mt-4")}> |
|
|
|
|
<Select |
|
|
|
|
defaultValue={ |
|
|
|
|
profilePage |
|
|
|
|
? provinces?.filter( |
|
|
|
|
(province) => province.id === profileFields.provinceId |
|
|
|
|
)[0]?.name || province[0] |
|
|
|
|
: city[0] |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
value === "استان" ? {} : onChange(name, value) |
|
|
|
|
} |
|
|
|
|
options={province} |
|
|
|
|
width={"100%"} |
|
|
|
|
name="provinceId" |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View style={tw("w-full mt-4")}> |
|
|
|
|
<Select |
|
|
|
|
defaultValue={ |
|
|
|
|
profilePage |
|
|
|
|
? cities?.filter( |
|
|
|
|
(city) => city.id === profileFields.cityId |
|
|
|
|
)[0]?.name || city[0] |
|
|
|
|
: city[0] |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
value === "شهر" ? {} : onChange(name, value) |
|
|
|
|
} |
|
|
|
|
options={city} |
|
|
|
|
width={"100%"} |
|
|
|
|
name="cityId" |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View style={tw("mb-4")}> |
|
|
|
|
<CustomTextInput |
|
|
|
|
keyboardType="numeric" |
|
|
|
|
label="کد پستی" |
|
|
|
|
placeholder="" |
|
|
|
|
textAlign="left" |
|
|
|
|
name="postalCode" |
|
|
|
|
maxlength="10" |
|
|
|
|
value={ |
|
|
|
|
profilePage |
|
|
|
|
? profileFields.postalCode |
|
|
|
|
: addressFields?.postalCode |
|
|
|
|
} |
|
|
|
|
onChange={(name, value) => |
|
|
|
|
profilePage |
|
|
|
|
? setProfileFields({ |
|
|
|
|
...profileFields, |
|
|
|
|
postalCode: value, |
|
|
|
|
}) |
|
|
|
|
: onChange(name, value) |
|
|
|
|
} |
|
|
|
|
autoFocus={false} |
|
|
|
|
regex={(text) => onInput.numberOnly(text)} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<CustomPressable |
|
|
|
|
title={ |
|
|
|
|
profilePage ? "ذخیره اطلاعات و بازگشت به صفحه قبل" : "ثبت آدرس" |
|
|
|
|
} |
|
|
|
|
backgroundColor={Colors.theme1[colorScheme].greenCF} |
|
|
|
|
color={"white"} |
|
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
|
width={"100%"} |
|
|
|
|
onPress={() => (profilePage ? submitProfile() : submit())} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<CustomPressable |
|
|
|
|
title={ |
|
|
|
|
profilePage |
|
|
|
|
? "ذخیره اطلاعات و بازگشت به صفحه قبل" |
|
|
|
|
: "ثبت آدرس" |
|
|
|
|
} |
|
|
|
|
backgroundColor={Colors.theme1[colorScheme].greenCF} |
|
|
|
|
color={"white"} |
|
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
|
width={"100%"} |
|
|
|
|
onPress={() => (profilePage ? submitProfile() : submit())} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
</TouchableWithoutFeedback> |
|
|
|
|
</KeyboardAvoidingView> |
|
|
|
|
</ScrollView> |
|
|
|
|
</SafeAreaView> |
|
|
|
|
); |
|
|
|
@ -434,13 +452,14 @@ const Address = ({ |
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
|
contentContainerStyle: { |
|
|
|
|
paddingBottom: 100, |
|
|
|
|
paddingBottom: 0, |
|
|
|
|
}, |
|
|
|
|
container: { |
|
|
|
|
backgroundColor: "white", |
|
|
|
|
flexDirection: "column", |
|
|
|
|
paddingVertical: 5, |
|
|
|
|
paddingHorizontal: 16, |
|
|
|
|
flex: 1, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|