diff --git a/src/screens/AR/components/Book.js b/src/screens/AR/components/Book.js index 9003b75..a46cce0 100644 --- a/src/screens/AR/components/Book.js +++ b/src/screens/AR/components/Book.js @@ -17,10 +17,10 @@ const Book = ({ book, mobile, theme }) => { tw("flex items-end rounded-md p-2 my-2"), { width: mobile ? "48%" : width / 4.2 }, ]} - onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book.id}`)} + onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.id}`)} > { }, ]} > - {book.title} + {book?.title} ); diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index 4f4dbe8..a33e800 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -370,7 +370,7 @@ const Address = ({ maxlength="40" value={ profilePage - ? profileFields.firstName + ? profileFields?.firstName : addressFields?.firstName } onChange={(name, value) => @@ -390,7 +390,7 @@ const Address = ({ name="lastName" maxlength="60" value={ - profilePage ? profileFields.lastName : addressFields?.lastName + profilePage ? profileFields?.lastName : addressFields?.lastName } onChange={(name, value) => profilePage @@ -408,7 +408,7 @@ const Address = ({ textAlign="left" name="nationalId" maxLength={10} - value={profileFields.nationalId} + value={profileFields?.nationalId} onChange={(name, value) => setProfileFields({ ...profileFields, nationalId: value }) } @@ -433,7 +433,7 @@ const Address = ({ maxLength={11} value={ profilePage - ? profileFields.cellphone + ? profileFields?.cellphone : addressFields?.cellphone } onChange={(name, value) => @@ -451,7 +451,7 @@ const Address = ({ textAlign="left" name="phone" maxLength={11} - value={profilePage ? profileFields.phone : addressFields?.phone} + value={profilePage ? profileFields?.phone : addressFields?.phone} onChange={(name, value) => profilePage ? setProfileFields({ ...profileFields, phone: value }) @@ -471,7 +471,7 @@ const Address = ({ defaultValue={ profilePage ? provinces?.filter( - (province) => province.id === profileFields.provinceId + (province) => province.id === profileFields?.provinceId )[0]?.name || province[0] : province[0] } @@ -488,7 +488,7 @@ const Address = ({ defaultValue={ profilePage ? cities?.filter( - (city) => city.id === profileFields.cityId + (city) => city.id === profileFields?.cityId )[0]?.name || city[0] : city[0] } @@ -544,7 +544,7 @@ const Address = ({ maxLength={10} value={ profilePage - ? profileFields.postalCode + ? profileFields?.postalCode : addressFields?.postalCode } onChange={(name, value) => diff --git a/src/screens/Blog/index.js b/src/screens/Blog/index.js index 3fbb873..9fc6fb1 100644 --- a/src/screens/Blog/index.js +++ b/src/screens/Blog/index.js @@ -33,12 +33,12 @@ const { width } = Dimensions.get("window"); //func const renderNode = (node, index, siblings, parent, defaultRenderer) => { - if (node.name == "img") { - const a = node.attribs; + if (node?.name == "img") { + const a = node?.attribs; return ( ); } @@ -46,8 +46,8 @@ const renderNode = (node, index, siblings, parent, defaultRenderer) => { export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => { useEffect(() => { - getInfo({ id: route.params.id }); - if (blogs.length === 0) { + getInfo({ id: route?.params?.id }); + if (blogs?.length === 0) { getList(); } }, []); @@ -114,7 +114,7 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => { > - { textAlign: ios ? "right" : "auto", }} > - {/* {"نوشته از:" + " " + "کامران ایزدی"} */} - + {"نوشته از:" + " " + "کامران ایزدی"} + */} {
- {blogs.length ? ( + {blogs?.length ? ( blog.id !== route.params.id)} + data={blogs?.filter((blog) => blog?.id !== route?.params?.id)} renderItem={({ item }) => } keyExtractor={(item, index) => { - return item.id; + return item?.id; }} /> ) : null} @@ -300,10 +300,6 @@ const mapDispatchToProps = { setHeaderOptions: publicApi.setHeaderOptions, }; -const Tag = ({ tag }) => { - return; -}; - export default connect(mapStateToProps, mapDispatchToProps)(Blog); const styles = StyleSheet.create({ diff --git a/src/screens/Blogs/index.js b/src/screens/Blogs/index.js index bd700cd..64f6921 100644 --- a/src/screens/Blogs/index.js +++ b/src/screens/Blogs/index.js @@ -79,11 +79,11 @@ function Blogs({ getList, blogs, hashtag, setHashtag, theme }) { blog.tag === hashtag)} + data={blogs?.filter((blog) => blog?.tag === hashtag)} renderItem={({ item }) => ( )} - keyExtractor={(item) => item.id} + keyExtractor={(item) => item?.id} /> ) : ( } - keyExtractor={(item) => item.id} + keyExtractor={(item) => item?.id} />
} - keyExtractor={(item) => item.id} + keyExtractor={(item) => item?.id} />
- + )} diff --git a/src/screens/Blogs/layouts/More.js b/src/screens/Blogs/layouts/More.js index 379dd6e..3ecf297 100644 --- a/src/screens/Blogs/layouts/More.js +++ b/src/screens/Blogs/layouts/More.js @@ -65,7 +65,7 @@ const MoreBlog = ({ mobile, theme, blogs, blogsPage }) => { data={blogs} style={tw("px-4")} renderItem={({ item }) => } - keyExtractor={(item) => item.id} + keyExtractor={(item) => item?.id} contentContainerStyle={{ paddingBottom: height / 2 }} /> diff --git a/src/screens/Blogs/layouts/Single.js b/src/screens/Blogs/layouts/Single.js index 4c18cd5..b05b12f 100644 --- a/src/screens/Blogs/layouts/Single.js +++ b/src/screens/Blogs/layouts/Single.js @@ -10,6 +10,7 @@ import { import { connect } from "react-redux"; import { LinearGradient } from "expo-linear-gradient"; import { useNavigation } from "@react-navigation/native"; +import moment from "jalali-moment"; //style import tw from "tailwind-rn"; @@ -55,8 +56,8 @@ export const Single = ({ blog, theme }) => { tw("rounded-full ml-1"), ]} > - - + {/* { ]} > {"نوشته از:" + " " + "کامران ایزدی"} - + */} { - - - {"زمان مطالعه" + " " + "۳۰ دقیقه"} - + + {blog?.duration ? ( + + {"زمان مطالعه" + " " + blog?.duration + " دقیقه"} + + ) : null} - {"1400/11/24"} + {moment(blog?.createdAt).format("jYYYY/jMM/jDD")} diff --git a/src/screens/Blogs/layouts/Target.js b/src/screens/Blogs/layouts/Target.js index fae1f12..79b50e2 100644 --- a/src/screens/Blogs/layouts/Target.js +++ b/src/screens/Blogs/layouts/Target.js @@ -11,6 +11,7 @@ import { import { connect } from "react-redux"; import { useNavigation } from "@react-navigation/native"; import { LinearGradient } from "expo-linear-gradient"; +import moment from "jalali-moment"; //style import tw from "tailwind-rn"; @@ -71,7 +72,7 @@ const Target = ({ blogs, theme }) => { - { ]} > {"نوشته از:" + " " + "کامران ایزدی"} - + */} { + {blog?.duration ? ( + + {"زمان مطالعه" + " " + blog?.duration + " دقیقه"} + + ) : null} + - {"زمان مطالعه" + " " + "۳۰ دقیقه"} - - - {"1400/11/24"} + {moment(blog?.createdAt).format("jYYYY/jMM/jDD")} diff --git a/src/screens/Home/index.js b/src/screens/Home/index.js index 71a97ab..f4b1fd4 100644 --- a/src/screens/Home/index.js +++ b/src/screens/Home/index.js @@ -1,6 +1,7 @@ import React, { useState } from "react"; import { connect } from "react-redux"; import { blog, book, userProduct } from "../../redux/actions"; +import {useNavigation} from "@react-navigation/native"; import { View, @@ -37,6 +38,7 @@ const Home = ({ getBooks, getUserProducts, }) => { + const navigation = useNavigation(); const [position, setPosition] = useState("100%"); const setBoxPosition = () => { diff --git a/src/screens/Splash/index.js b/src/screens/Splash/index.js index 70c247d..71f2a32 100644 --- a/src/screens/Splash/index.js +++ b/src/screens/Splash/index.js @@ -30,6 +30,7 @@ function Splash({ }) { const isFocused = useIsFocused(); const [out, setOut] = React.useState(false); + React.useEffect(() => { StatusBar.setBarStyle( `${theme === "light" ? "dark" : "light"}-content`, @@ -42,12 +43,22 @@ function Splash({ setIsDark(theme); }; + const setOutHandler = React.useCallback( + (value) => { + setOut(value); + }, + [out] + ); + useEffect(() => { getTheme(); if (isLogin !== null) { if (isLogin === false) { - setOut(true); - navigation.navigate("Login"); + setOutHandler(true); + navigation.reset({ + index: 0, + routes: [{ name: "Login" }], + }); } else { if (blogs.length === 0) { getBlogs(); @@ -56,38 +67,40 @@ function Splash({ } else if (userProducts.length === 0) { getUserProducts(); } else { - setOut(true); - navigation.navigate("Root"); + setOutHandler(true); + navigation.reset({ + index: 0, + routes: [{ name: "Root" }], + }); } } - } else { } }, [isLogin, books, userProducts, blogs]); - if (isFocused && out) { - setOut(false); - BackHandler.exitApp(); - } + // if (isFocused && out) { + // setOutHandler(false); + // BackHandler.exitApp(); + // } - if (isFocused && !out) { - if (isLogin !== null) { - if (isLogin === false) { - setOut(true); - navigation.navigate("Login"); - } else { - if (blogs.length === 0) { - getBlogs(); - } else if (books.length === 0) { - getBooks({ vod: true }); - } else if (userProducts.length === 0) { - getUserProducts(); - } else { - setOut(true); - navigation.navigate("Root"); - } - } - } - } + // if (isFocused && !out) { + // if (isLogin !== null) { + // if (isLogin === false) { + // setOutHandler(true); + // navigation.push("Login"); + // } else { + // if (blogs.length === 0) { + // getBlogs(); + // } else if (books.length === 0) { + // getBooks({ vod: true }); + // } else if (userProducts.length === 0) { + // getUserProducts(); + // } else { + // setOutHandler(true); + // navigation.push("Root"); + // } + // } + // } + // } return (