diff --git a/navigation/index.js b/navigation/index.js index edd1d56..2f1619b 100644 --- a/navigation/index.js +++ b/navigation/index.js @@ -49,15 +49,15 @@ const BottomTabNavigator = () => { screenOptions={{ tabBarHideOnKeyboard: true, headerShown: false, - tabBarActiveTintColor: "#06BACE", + tabBarActiveTintColor: Colors.theme1[colorScheme].green79, tabBarInactiveTintColor: "grey", tabBarStyle: { backgroundColor: Colors.theme1[colorScheme].greenFF1, height: 70, }, tabBarLabelStyle: { - fontSize: fontSize.xs, - fontFamily: "regular", + fontSize: fontSize.sm, + fontFamily: "bold", transform: [{ translateY: -7 }], }, tabBarShowLabel: true, @@ -76,7 +76,7 @@ const BottomTabNavigator = () => { width={31.192} height={31.192} > - + { > { > { { data-name="Vector" d="m21.063 11.951.9 1.01 2.684-3.03M16.002 21.383H8.933M21.063 21.377l.9 1.01 2.684-3.03" fill="none" - stroke="#86a0b9" + stroke={Colors.theme1[colorScheme].green79} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} @@ -160,7 +160,7 @@ const BottomTabNavigator = () => { data-name="Vector" d="M20.852 29.624h-8.381c-6.984 0-9.778-2.693-9.778-9.426v-8.079c0-6.733 2.794-9.426 9.778-9.426h8.381c6.984 0 9.778 2.693 9.778 9.426v8.079c-.001 6.733-2.794 9.426-9.778 9.426Z" fill="none" - stroke="#86a0b9" + stroke={Colors.theme1[colorScheme].green79} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} @@ -180,14 +180,14 @@ const BottomTabNavigator = () => { focused ? ( { ) : ( { data-name="Vector" d="M12.427 14.995v-2.083c0-2.673 1.892-3.766 4.2-2.43l1.805 1.042 1.806 1.041c2.308 1.336 2.308 3.523 0 4.86l-1.806 1.041-1.805 1.046c-2.308 1.332-4.2.239-4.2-2.434v-2.083Z" fill="none" - stroke="#86a0b9" + stroke={Colors.theme1[colorScheme].green79} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} @@ -248,7 +248,7 @@ const BottomTabNavigator = () => { > { > { > { { data-name="Vector" d="M16.79 25.471v-6.693" fill="none" - stroke="#86a0b9" + stroke={Colors.theme1[colorScheme].green79} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} diff --git a/src/components/CustomTextInput.js b/src/components/CustomTextInput.js index b33e512..2bb1230 100644 --- a/src/components/CustomTextInput.js +++ b/src/components/CustomTextInput.js @@ -54,6 +54,14 @@ const FloatingLabelInput = ({ direction: direction ? direction : "rtl" }, }); + + React.useEffect(() => { + if(value) { + setIsFocused(true); + }else{ + setIsFocused(false); + } + },[value]); return ( async (dispatch) => { - await proxy.login("user/otp/login", data, { dispatch }); - }, + otp_login: + (data = {}) => + async (dispatch) => { + await proxy.login("user/otp/login", data, { dispatch }); + }, login: (data) => async (dispatch) => await proxy.login("user/login", data, { dispatch }), @@ -27,20 +29,6 @@ const user = { getUserRole: (data) => async (dispatch) => await proxy.get("user/getUserRole", data, { dispatch }), - // list: - // (data = {}) => - // async (dispatch : Dispatch) => - // await proxy.get("user/list", data, { dispatch }), - // domains: - // (data = {}) => - // async (dispatch : Dispatch) => - // await proxy.get("user/domains", data, { dispatch }), - // getmothers: - // (data = {}) => - // async (dispatch : Dispatch) => - // await proxy.get("mothers/list", data, { - // dispatch, - // }), getProfile: (data = {}) => async (dispatch) => @@ -51,6 +39,11 @@ const user = { await proxy.put("user/setProfile", data, { dispatch }); await proxy.get("user/getProfile", data2, { dispatch }); }, + setProfileFields: + (data = {}) => + async (dispatch) => { + await dispatch({ type: "user/setProfileFields", data }); + }, add: (data = {}, data2 = {}) => async (dispatch) => { diff --git a/src/redux/reducers/user.js b/src/redux/reducers/user.js index 2be1251..7fbd6ab 100644 --- a/src/redux/reducers/user.js +++ b/src/redux/reducers/user.js @@ -12,6 +12,9 @@ let initialState = { setDone: false, setLogin: false, check: "check", + profileFields : { + + }, }; const user = (state = initialState, action) => { @@ -43,7 +46,7 @@ const user = (state = initialState, action) => { return { ...state, loading: false, - status: JSON.parse(data), + status: data, error: null, setDone: false, }; @@ -52,8 +55,9 @@ const user = (state = initialState, action) => { case "user/getUserRole": return { ...state, loading: false, userRoles: data, error: null }; case "user/setProfile": - // toast.success("تغییرات اعمال شد."); return { ...state, loading: false, error: null, setDone: true }; + case "user/setProfileFields": + return { ...state, loading: false, error: null, profileFields: data }; case "loading": return { ...state, loading: true }; case "error": diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index c94d978..a9e755d 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -11,7 +11,8 @@ import { } from "react-native"; import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; -import { publicApi, userAddress } from "../../redux/actions"; +import { publicApi, user, userAddress } from "../../redux/actions"; +import onInput from "../../utils/onInput"; import { useNavigation } from "@react-navigation/native"; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; @@ -30,6 +31,8 @@ import fontSize from "../../constants/fontSize"; const ios = Platform.OS === "ios"; const Address = ({ + user, + route, city, province, getCity, @@ -37,18 +40,45 @@ const Address = ({ provinces, cities, createAddress, + profileFields, + setProfileFields, + setProfile, loading, setPhase, cityLoading, }) => { + const profilePage = route.params.type === "profile"; const colorScheme = Appearance.getColorScheme(); const navigation = useNavigation(); - const [addressFields, setAddressFields] = useState({}); const [mapAddress, setMapAddress] = useState(null); useEffect(() => { getProvince(); + setProfileFields({ + file: user.picFileId, + picFileId: user.picFileId, + docFileIds: user.docFileIds, + cellphone: user.cellphone, + firstName: user.firstName, + lastName: user.lastName, + password: user.password, + username: user.username, + address: user.address, + email: user.email, + birthDate: user.birthDate, + gender: user.gender, + status: user.status, + nationalId: user.nationalId, + phone: user.phone, + schools: user.schools, + zoneId: user.zoneId, + schoolId: user.schoolId, + postalCode: user.postalCode, + gradeIds: user.gradeIds, + provinceId: user.provinceId, + cityId: user.cityId, + }); }, []); useEffect(() => { @@ -135,6 +165,52 @@ const Address = ({ navigation.goBack(); }; + const submitProfile = () => { + const { + firstName, + lastName, + username, + password, + postalCode, + address, + email, + phone, + picFileId, + gender, + nationalId, + birthDate, + schools, + gradeIds, + status, + provinceId, + cityId, + docFileIds, + } = profileFields; + const data = { + firstName: firstName, + lastName: lastName, + username: username, + cellphone: user.cellphone, + password: password, + postalCode: postalCode, + address: address, + email: email, + phone: phone, + nationalId: nationalId, + picFileId: picFileId, + gender: gender, + birthDate: birthDate, + schools: schools, + gradeIds: gradeIds, + status: status, + provinceId: provinceId, + cityId: cityId, + docFileIds: docFileIds, + }; + setProfile(data); + navigation.goBack(); + } + const Header = ({ title, text }) => { return ( @@ -170,10 +246,10 @@ const Address = ({ onChange(name, value)} + value={ + profilePage ? profileFields.firstName : addressFields?.firstName + } + onChange={(name, value) => + profilePage + ? setProfileFields({ ...profileFields, firstName: value }) + : onChange(name, value) + } autoFocus={false} regex={(val) => val} /> @@ -205,11 +287,32 @@ const Address = ({ textAlign="right" name="lastName" maxlength="60" - value={addressFields?.lastName} - onChange={(name, value) => onChange(name, value)} + value={ + profilePage ? profileFields.lastName : addressFields?.lastName + } + onChange={(name, value) => + profilePage + ? setProfileFields({ ...profileFields, lastName: value }) + : onChange(name, value) + } autoFocus={false} regex={(val) => val} /> + {profilePage && ( + + setProfileFields({ ...profileFields, nationalId: value }) + } + autoFocus={false} + regex={onInput.numberOnly} + /> + )}
onChange(name, value)} + value={ + profilePage ? profileFields.cellphone : addressFields?.cellphone + } + onChange={(name, value) => + profilePage + ? setProfileFields({ ...profileFields, cellphone: value }) + : onChange(name, value) + } autoFocus={false} - regex={(val) => val} + regex={onInput.phonenumber} /> onChange(name, value)} + value={profilePage ? profileFields.phone : addressFields?.phone} + onChange={(name, value) => + profilePage + ? setProfileFields({ ...profileFields, phone: value }) + : onChange(name, value) + } autoFocus={false} - regex={(val) => val} + regex={onInput.phonenumber} />
- + onChange(name, value)} + value={ + profilePage + ? profileFields.postalCode + : addressFields?.postalCode + } + onChange={(name, value) => + profilePage + ? setProfileFields({ ...profileFields, postalCode: value }) + : onChange(name, value) + } autoFocus={false} regex={(val) => val} /> navigation.push("Address")} + onPress={() => profilePage ? submitProfile() : submit()} /> @@ -308,12 +445,16 @@ const mapStateToProps = (state) => ({ city: state.publicApi.city, loading: state.userAddress.loading, cityLoading: state.publicApi.loading, + user: state.user.status, + profileFields: state.user.profileFields, }); const mapDispatchToProps = { getProvince: publicApi.getProvince, getCity: publicApi.getCity, createAddress: userAddress.add, + setProfileFields: user.setProfileFields, + setProfile: user.setProfile }; export default connect(mapStateToProps, mapDispatchToProps)(Address);