reza fixed login bug

master
Reza_ashrafi 3 years ago
parent 388573268f
commit df449885cd
  1. 1
      src/components/CustomTextInput.js
  2. 10
      src/components/Drawer.js
  3. 2
      src/redux/reducers/user.js
  4. 2
      src/redux/store.js
  5. 13
      src/screens/Home/index.js
  6. 5
      src/screens/Login/index.js
  7. 20
      src/screens/Otp/index.js
  8. 2
      src/screens/Product/components/Book.js
  9. 2
      src/screens/Profile/components/List.js
  10. 2
      src/screens/Profile/components/User.js
  11. 2
      src/screens/QR/Scan/index.js
  12. 2
      src/screens/ShoppingCart/components/Code.js
  13. 2
      src/screens/ShoppingCart/index.js
  14. 2
      src/screens/Video/index.js
  15. 2
      src/screens/VideoDisplay/components/Season/index.js
  16. 12
      src/utils/onInput.js

@ -51,6 +51,7 @@ const FloatingLabelInput = ({
textAlign: textAlign, textAlign: textAlign,
fontFamily: "regular", fontFamily: "regular",
fontWeight: "900", fontWeight: "900",
direction: direction ? direction : "rtl"
}, },
}); });
return ( return (

@ -31,7 +31,7 @@ if (
UIManager.setLayoutAnimationEnabledExperimental(true); UIManager.setLayoutAnimationEnabledExperimental(true);
} }
const Drawer = ({ position, setBoxPosition, user }) => { const Drawer = ({ position, setBoxPosition, user = JSON.parse(user) }) => {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
const [routes, setRoutes] = useState([ const [routes, setRoutes] = useState([
{ {
@ -142,7 +142,7 @@ const Drawer = ({ position, setBoxPosition, user }) => {
{ backgroundColor: Colors.theme1[colorScheme].greenCF }, { backgroundColor: Colors.theme1[colorScheme].greenCF },
]} ]}
> >
{user.picFileId ? ( {user?.picFileId ? (
<Image <Image
source={{ uri: "https://dnvn.ir/api/v1/" + user.picFileId }} source={{ uri: "https://dnvn.ir/api/v1/" + user.picFileId }}
style={[tw("rounded-full"), { width: 60, height: 60 }]} style={[tw("rounded-full"), { width: 60, height: 60 }]}
@ -151,7 +151,7 @@ const Drawer = ({ position, setBoxPosition, user }) => {
<View <View
style={[ style={[
tw("rounded-full bg-gray-200"), tw("rounded-full bg-gray-200"),
{ width: 60, height: 60, zIndex : 1 }, { minWidth: 60, minHeight: 60, zIndex : 1 },
]} ]}
></View> ></View>
)} )}
@ -210,11 +210,11 @@ const Drawer = ({ position, setBoxPosition, user }) => {
}; };
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
user: JSON.parse(state.user.status), user: state.user.status,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
logout: user.logout, logout: user.logout,
}; };
export default connect(mapStateToProps)(Drawer); export default connect(mapStateToProps, mapDispatchToProps)(Drawer);

@ -23,7 +23,7 @@ const user = (state = initialState, action) => {
case "public/sendOTP": case "public/sendOTP":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "user/getStatus": case "user/getStatus":
return { ...state, status: data.status, error: null }; return { ...state, status: JSON.parse(data.status), error: null };
case "user/login": case "user/login":
case "user/otp/login": case "user/otp/login":
return { return {

@ -65,6 +65,8 @@ try {
console.log(e); console.log(e);
} }
AsyncStorage.clear();
console.disableYellowBox = true; console.disableYellowBox = true;
export default store; export default store;

@ -26,8 +26,6 @@ const Home = ({
getBlogs, getBlogs,
books, books,
getBooks, getBooks,
videos,
getVideos,
userProducts, userProducts,
getUserProducts, getUserProducts,
}) => { }) => {
@ -35,7 +33,7 @@ const Home = ({
useEffect(() => { useEffect(() => {
getBlogs(); getBlogs();
getBooks(); getBooks({vod : true});
getUserProducts(); getUserProducts();
}, []); }, []);
@ -68,13 +66,13 @@ const Home = ({
contentContainerStyle={styles.contentContainerStyle} contentContainerStyle={styles.contentContainerStyle}
style={[styles.container, tw("flex")]} style={[styles.container, tw("flex")]}
> >
{userProducts.length > 0 && <MyBooks books={userProducts} />} {userProduct?.length > 0 && <MyBooks books={userProducts} />}
<View style={tw("px-4 w-full")}> <View style={tw("px-4 w-full")}>
<Header title={"فروشگاه"} route={"Products"} /> <Header title={"فروشگاه"} route={"Products"} />
</View> </View>
{books.length > 0 && <Scroll books={books} />} {books?.length > 0 && <Scroll books={books} />}
{books.length > 0 && <Videos videos={books} />} {books?.length > 0 && <Videos videos={books} />}
{blogs.length > 0 && <Blogs blogs={blogs} />} {blogs?.length > 0 && <Blogs blogs={blogs} />}
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
); );
@ -96,7 +94,6 @@ const mapStateToProps = (state) => ({
blogs: state.blog.list, blogs: state.blog.list,
books: state.book.list, books: state.book.list,
userProducts: state.userProduct.list, userProducts: state.userProduct.list,
videos: state.product.listVOD,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {

@ -77,7 +77,7 @@ function Login(props) {
</Text> </Text>
<Text <Text
style={[ style={[
tw(`w-full ${ios ? "text-right mb-5" : "mt-5"}`), tw(`w-full mb-5 ${ios ? "text-right" : ""}`),
{ {
fontSize: fontSize.xl2, fontSize: fontSize.xl2,
fontFamily: "bold", fontFamily: "bold",
@ -92,10 +92,11 @@ function Login(props) {
label="شماره موبایل" label="شماره موبایل"
textAlign="left" textAlign="left"
name="phone" name="phone"
maxlength="11" maxLength={11}
value={phone} value={phone}
onChange={onChangePhone} onChange={onChangePhone}
autoFocus={true} autoFocus={true}
direction="ltr"
regex={onInput.phonenumber} regex={onInput.phonenumber}
/> />
</View> </View>

@ -87,7 +87,7 @@ function Otp(props) {
const submit = async () => { const submit = async () => {
setLoading(true); setLoading(true);
props.sendOtp({ props.sendOtp({
cellphone: props.route.params.phone, cellphone: props.route.params?.phone,
otp: String(getEnCode()), otp: String(getEnCode()),
applicationToken: "1", applicationToken: "1",
userToken: "1", userToken: "1",
@ -139,7 +139,7 @@ function Otp(props) {
color: "#6f7074", color: "#6f7074",
}, },
]} ]}
>{`یک کد تائیدیه به شماره ${props.route.params.phone} ارسال شد. آن را در قسمت زیر وارد کنید`}</Text> >{`یک کد تائیدیه به شماره ${props.route.params?.phone} ارسال شد. آن را در قسمت زیر وارد کنید`}</Text>
<View <View
style={[ style={[
tw("w-full px-4 pt-6 flex flex-row items-center justify-center"), tw("w-full px-4 pt-6 flex flex-row items-center justify-center"),
@ -152,7 +152,7 @@ function Otp(props) {
fontSize: fontSize.xl3, fontSize: fontSize.xl3,
fontFamily: "bold", fontFamily: "bold",
color: Colors.theme1[colorScheme].green79, color: Colors.theme1[colorScheme].green79,
width : ios ? fontSize.xl3 + 40 : "" // width : ios ? fontSize.xl3 + 40 : ""
}, },
]} ]}
underlineColorAndroid={"transparent"} underlineColorAndroid={"transparent"}
@ -160,6 +160,8 @@ function Otp(props) {
maxLength={1} maxLength={1}
ref={(ref) => (ref1 = ref)} ref={(ref) => (ref1 = ref)}
onChangeText={(text) => onChangeCode(text, "1")} onChangeText={(text) => onChangeCode(text, "1")}
regex={onInput.numberOnly}
direction="ltr"
/> />
<TextInput <TextInput
style={[ style={[
@ -168,7 +170,7 @@ function Otp(props) {
fontSize: fontSize.xl3, fontSize: fontSize.xl3,
fontFamily: "bold", fontFamily: "bold",
color: Colors.theme1[colorScheme].green79, color: Colors.theme1[colorScheme].green79,
width : ios ? fontSize.xl3 + 40 : "" // width : ios ? fontSize.xl3 + 40 : ""
}, },
]} ]}
underlineColorAndroid={"transparent"} underlineColorAndroid={"transparent"}
@ -176,6 +178,8 @@ function Otp(props) {
maxLength={1} maxLength={1}
ref={(ref) => (ref2 = ref)} ref={(ref) => (ref2 = ref)}
onChangeText={(text) => onChangeCode(text, "2")} onChangeText={(text) => onChangeCode(text, "2")}
regex={onInput.numberOnly}
direction="ltr"
/> />
<TextInput <TextInput
style={[ style={[
@ -184,7 +188,7 @@ function Otp(props) {
fontSize: fontSize.xl3, fontSize: fontSize.xl3,
fontFamily: "bold", fontFamily: "bold",
color: Colors.theme1[colorScheme].green79, color: Colors.theme1[colorScheme].green79,
width : ios ? fontSize.xl3 + 40 : "" // width : ios ? fontSize.xl3 + 40 : ""
}, },
]} ]}
underlineColorAndroid={"transparent"} underlineColorAndroid={"transparent"}
@ -192,6 +196,8 @@ function Otp(props) {
maxLength={1} maxLength={1}
ref={(ref) => (ref3 = ref)} ref={(ref) => (ref3 = ref)}
onChangeText={(text) => onChangeCode(text, "3")} onChangeText={(text) => onChangeCode(text, "3")}
regex={onInput.numberOnly}
direction="ltr"
/> />
<TextInput <TextInput
style={[ style={[
@ -200,7 +206,7 @@ function Otp(props) {
fontSize: fontSize.xl3, fontSize: fontSize.xl3,
fontFamily: "bold", fontFamily: "bold",
color: Colors.theme1[colorScheme].green79, color: Colors.theme1[colorScheme].green79,
width : ios ? fontSize.xl3 + 40 : "" // width : ios ? fontSize.xl3 + 40 : ""
}, },
]} ]}
underlineColorAndroid={"transparent"} underlineColorAndroid={"transparent"}
@ -208,6 +214,8 @@ function Otp(props) {
maxLength={1} maxLength={1}
ref={(ref) => (ref4 = ref)} ref={(ref) => (ref4 = ref)}
onChangeText={(text) => onChangeCode(text, "4")} onChangeText={(text) => onChangeCode(text, "4")}
regex={onInput.numberOnly}
direction="ltr"
/> />
</View> </View>
<TouchableOpacity <TouchableOpacity

@ -308,7 +308,7 @@ function Book({ book, grades, pushToCart, userId, loading }) {
} }
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
userId: state.user.status.id, userId: state.user.status?.id,
loading: state.userProduct.loading, loading: state.userProduct.loading,
}); });

@ -109,7 +109,7 @@ const List = ({}) => {
}, },
{ {
icon: ( icon: (
<Svg xmlns="http://www.w3.org/2000/svg" width={24.613} height={21.519}> <Svg xmlns="http://www.w3.org/2000/svg" width={25.613} height={22.519}>
<G data-name="Group 2005"> <G data-name="Group 2005">
<Path <Path
d="M18.085 20.769H6.528c-3.467 0-5.778-2-5.778-6.673V7.423C.75 2.75 3.061.75 6.528.75h11.557c3.467 0 5.778 2 5.778 6.673v6.673c0 4.671-2.313 6.673-5.778 6.673Z" d="M18.085 20.769H6.528c-3.467 0-5.778-2-5.778-6.673V7.423C.75 2.75 3.061.75 6.528.75h11.557c3.467 0 5.778 2 5.778 6.673v6.673c0 4.671-2.313 6.673-5.778 6.673Z"

@ -150,7 +150,7 @@ const User = ({ user }) => {
}; };
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
user: JSON.parse(state.user.status), user: state.user.status,
}); });
export default connect(mapStateToProps)(User); export default connect(mapStateToProps)(User);

@ -96,4 +96,4 @@ export default function Scan({}) {
{/* )} */} {/* )} */}
</ImageBackground> </ImageBackground>
); );
} }

@ -70,7 +70,7 @@ function Code({ codeId, setCodeId, userId, factorId }) {
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
codeId: state.userFactor.info?.codeId, codeId: state.userFactor.info?.codeId,
userId: state.user.status.id, userId: state.user.status?.id,
factorId: state.userFactor.info?.id, factorId: state.userFactor.info?.id,
}); });

@ -247,7 +247,7 @@ const mapStateToProps = (state) => ({
list: state.userProduct.list, list: state.userProduct.list,
payPrice: state.userProduct.sum, payPrice: state.userProduct.sum,
factorInfo: state.userFactor.info, factorInfo: state.userFactor.info,
userId: state.user.status.id, userId: state.user.status?.id,
hasPhysical: state.userProduct.hasPhysical, hasPhysical: state.userProduct.hasPhysical,
loading: state.userProduct.loading, loading: state.userProduct.loading,
}); });

@ -173,7 +173,7 @@ const mapStateToProps = (state) => ({
seasons: state.publicApi.categories, seasons: state.publicApi.categories,
grades: state.publicApi.grades, grades: state.publicApi.grades,
isLogin: state.user.status, isLogin: state.user.status,
userId: state.user.status.id, userId: state.user.status?.id,
loading: state.userProduct.loading, loading: state.userProduct.loading,
}); });

@ -123,7 +123,7 @@ const mapStateToProps = (state) => ({
selectedVideo: state.publicApi.selectedVideo, selectedVideo: state.publicApi.selectedVideo,
realSeasons: state.publicApi.bookInfo?.categories, realSeasons: state.publicApi.bookInfo?.categories,
vods: state.publicApi.bookSection?.vods, vods: state.publicApi.bookSection?.vods,
userid: state.user.status.id, userid: state.user.status?.id,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {

@ -147,6 +147,16 @@ class onInput {
newText = newText.replace(/7/g, "7"); newText = newText.replace(/7/g, "7");
newText = newText.replace(/8/g, "8"); newText = newText.replace(/8/g, "8");
newText = newText.replace(/9/g, "9"); newText = newText.replace(/9/g, "9");
newText = newText.replace(/۰/g, "0");
newText = newText.replace(/۱/g, "1");
newText = newText.replace(/۲/g, "2");
newText = newText.replace(/۳/g, "3");
newText = newText.replace(/۴/g, "4");
newText = newText.replace(/۵/g, "5");
newText = newText.replace(/۶/g, "6");
newText = newText.replace(/۷/g, "7");
newText = newText.replace(/۸/g, "8");
newText = newText.replace(/۹/g, "9");
newText = newText.replace(/ا/g, ""); newText = newText.replace(/ا/g, "");
newText = newText.replace(/ب/g, ""); newText = newText.replace(/ب/g, "");
newText = newText.replace(/پ/g, ""); newText = newText.replace(/پ/g, "");
@ -237,7 +247,7 @@ class onInput {
newText = newText.replace(/N/g, ""); newText = newText.replace(/N/g, "");
newText = newText.replace(/M/g, ""); newText = newText.replace(/M/g, "");
if (!newText && newText.length !== 0) { if (!newText && newText.length !== 0) {
// toast.info("از اعداداستفاده کنید"); toast.info("از اعداداستفاده کنید");
} }
return newText; return newText;
}; };

Loading…
Cancel
Save