diff --git a/app.json b/app.json index 5c80269..c845742 100644 --- a/app.json +++ b/app.json @@ -6,7 +6,7 @@ "orientation": "portrait", "userInterfaceStyle": "automatic", "icon": "./assets/appLogo.png", - "scheme": "danovin", + "scheme": "dnvn", "splash": { "image": "", "resizeMode": "contain", diff --git a/src/redux/actions/transport.js b/src/redux/actions/transport.js index 22a5b5a..1221211 100644 --- a/src/redux/actions/transport.js +++ b/src/redux/actions/transport.js @@ -9,8 +9,8 @@ const transport = { set: (data = {}, data2 = {}, data3 = {}) => async (dispatch) => { - await proxy.post("transport/setTransport", data, { dispatch }); - await proxy.get("userFactor/info", data2, { dispatch }); + await proxy.post("transport/setTransportAndInfo", data, { dispatch }); + // await proxy.get("userFactor/info", data2); }, }; diff --git a/src/redux/actions/userAddress.js b/src/redux/actions/userAddress.js index 3ccd0b8..e2cf14c 100644 --- a/src/redux/actions/userAddress.js +++ b/src/redux/actions/userAddress.js @@ -15,19 +15,17 @@ const userAddress = { (data = {}, data2 = {}) => async (dispatch) => { await proxy.put("userAddress/update", data); - await proxy.get("userAddress/list", data2, { dispatch }); }, add: (data = {}, data2 = {}, data3 = {}) => async (dispatch) => { await proxy.post("userAddress/add", data, { dispatch }); - await proxy.get("userAddress/list", data2, { dispatch }); }, del: (data = {}, data2 = {}) => async (dispatch) => { - await proxy.delete("userAddress/delete", data); - await proxy.get("userAddress/list", data2, { dispatch }); + console.log(data); + await proxy.delete("userAddress/delete2", data); }, }; diff --git a/src/redux/actions/userFactor.js b/src/redux/actions/userFactor.js index a1064db..f739d9c 100644 --- a/src/redux/actions/userFactor.js +++ b/src/redux/actions/userFactor.js @@ -42,7 +42,6 @@ const userFactor = { (data = {}, data2 = {}) => async (dispatch) => { await proxy.put("userFactor/update", data, { dispatch }); - await proxy.get("userFactor/info", data2, { dispatch }); }, deleteUserOffCode: (data = {}, data2 = {}) => diff --git a/src/redux/reducers/transport.js b/src/redux/reducers/transport.js index 60446db..206e27f 100644 --- a/src/redux/reducers/transport.js +++ b/src/redux/reducers/transport.js @@ -13,6 +13,7 @@ export default function transport(state = initialState, action) { list: data, error: null, }; + case "transport/info": return { ...state, loading: false, error: null}; case "transport/loading": diff --git a/src/redux/reducers/userAddress.js b/src/redux/reducers/userAddress.js index 00ad9a9..e61407f 100644 --- a/src/redux/reducers/userAddress.js +++ b/src/redux/reducers/userAddress.js @@ -1,8 +1,9 @@ +import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; const initialState = { loading: false, error: null, list: [], - info : null, + info: null, }; export default function userAddress(state = initialState, action) { let { type, data } = action; @@ -17,14 +18,17 @@ export default function userAddress(state = initialState, action) { case "userAddress/info": return { ...state, loading: false, info: data, error: null }; case "userAddress/update": - return { ...state, loading: false, error: null }; + return { ...state, loading: false, list: data, error: null }; case "userAddress/add": - return { ...state, loading: false, error: null}; - case "userAddress/delete": - return { ...state, loading: false, error: null }; + return { ...state, loading: false, list: data.list, error: null }; + case "userAddress/delete2": + return { ...state, loading: false, list: data, error: null }; case "userAddress/loading": return { ...state, loading: true }; case "userAddress/error": + asyncAwesomeAlert("خطا", data.message, { + confirmText: "باشه", + }); return { ...state, loading: false, error: data.message }; default: return state; diff --git a/src/redux/reducers/userFactor.js b/src/redux/reducers/userFactor.js index b23f668..a07a884 100644 --- a/src/redux/reducers/userFactor.js +++ b/src/redux/reducers/userFactor.js @@ -16,6 +16,8 @@ export default function userFactor(state = initialState, action) { let { type, data } = action; switch (type) { //dnvn + case "transport/setTransportAndInfo": + return {...state, false : null, error: null, info : data.factorInfo } case "userFactor/list": const checkEmpty = data.filter( (item) => item.condition === 2 && item.product.productType === (1 || 3) @@ -46,7 +48,7 @@ export default function userFactor(state = initialState, action) { case "userFactor/myList": return { ...state, loading: false, list: data, error: null }; case "userFactor/update": - return { ...state, loading: false, error: null }; + return { ...state, loading: false, info: data.factorInfo, error: null }; case "userFactor/deleteUserOffCode": return { ...state, loading: false, error: null }; case "userFactor/paymentVOD": diff --git a/src/screens/DeliveryForm/Address/index.js b/src/screens/DeliveryForm/Address/index.js index afbfd76..d19ef93 100644 --- a/src/screens/DeliveryForm/Address/index.js +++ b/src/screens/DeliveryForm/Address/index.js @@ -8,6 +8,7 @@ import { } from "react-native"; import React from "react"; import { connect } from "react-redux"; +import { Ionicons, Entypo } from "@expo/vector-icons"; import { useNavigation } from "@react-navigation/native"; import { userFactor } from "../../../redux/actions"; @@ -28,61 +29,74 @@ const Address = ({ theme, }) => { const navigation = useNavigation(); + const [selectedItem, setSelectedItem] = React.useState(null); + + const light = React.useMemo(() => { + return theme === "light"; + }, [theme]); + + React.useEffect(() => { + if (!loading) { + setSelectedItem(null); + } + }, [loading]); const Location = ({ address, active }) => { return ( - userAddressId === address?.id - ? {} - : update({ userAddressId: address.id, userId }) - } + onPress={() => { + setSelectedItem(address.id); + active ? {} : update({ userAddressId: address.id, userId }); + }} > - {loading ? ( - userAddressId !== address?.id ? ( - - ) : ( - - ) - ) : null} + {selectedItem === address.id && loading ? ( + + ) : active ? ( + + ) : ( + + )} @@ -93,10 +107,6 @@ const Address = ({ ); }; - const light = React.useMemo(() => { - return theme === "light"; - }, [theme]); - return ( diff --git a/src/screens/DeliveryForm/TransportDate/index.js b/src/screens/DeliveryForm/TransportDate/index.js index d834dc0..0a31cc6 100644 --- a/src/screens/DeliveryForm/TransportDate/index.js +++ b/src/screens/DeliveryForm/TransportDate/index.js @@ -73,7 +73,7 @@ const TransportDate = ({ transportDate, mobile, theme }) => { }, []); return ( - + { return theme === "light"; }, [theme]); + React.useEffect(() => { + if (!loading) { + setSelectedItem(null); + } + }, [loading]); + const Method = useCallback( ({ method, active }) => { return ( @@ -46,26 +54,29 @@ const TransportMethod = ({ }` ), { - backgroundColor: light ? active - ? Colors.theme1.greenCF + "15" - : Colors.theme1.grayE3 + "44" : null, + backgroundColor: light + ? active + ? Colors.theme1.greenCF + "15" + : Colors.theme1.grayE3 + "44" + : null, borderWidth: 1.5, borderColor: active ? Colors.theme1.greenCF : Colors.theme1.grayE3, }, ]} - onPress={() => + onPress={() => { + setSelectedItem(method.id); !active ? setTransport( { factorId: factorInfo?.id, transportId: method?.id }, { userId }, {} ) - : {} - } + : {}; + }} > - {loading && !active ? ( + {loading && selectedItem === method.id ? ( - {list?.map((method, index) => ( + {factorInfo?.transports?.map((method, index) => ( ))} diff --git a/src/screens/DeliveryForm/index.js b/src/screens/DeliveryForm/index.js index 0bc19f6..cf7dab2 100644 --- a/src/screens/DeliveryForm/index.js +++ b/src/screens/DeliveryForm/index.js @@ -5,6 +5,7 @@ import { StyleSheet, StatusBar, Platform, + Dimensions, } from "react-native"; import React, { useEffect } from "react"; import { connect } from "react-redux"; @@ -23,6 +24,8 @@ import CustomPressable from "../../components/Pressable"; import tw from "tailwind-rn"; import Colors from "../../constants/Colors"; +const { height } = Dimensions.get("window"); + const DeliveryForm = ({ list, form, @@ -50,6 +53,8 @@ const DeliveryForm = ({ style={{ paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, position: "relative", + paddingHorizontal: 16, + flex: 1, }} > @@ -74,26 +80,30 @@ const DeliveryForm = ({ - - - - - factorInfo.transportId && factorInfo.userAddressId - ? payFactor({ userId }) - : asyncAwesomeAlert("خطا", "آدرس یا نحوه ارسال را وارد کنید", { - showCancelButton: false, - confirmText: "باشه", - }) - } - /> + {factorInfo.transportId === 2 ? ( + + + + ) : null} + + + factorInfo.transportId && factorInfo.userAddressId + ? payFactor({ userId }) + : asyncAwesomeAlert("خطا", "آدرس یا نحوه ارسال را وارد کنید", { + showCancelButton: false, + confirmText: "باشه", + }) + } + /> + ); }; @@ -104,7 +114,6 @@ const styles = StyleSheet.create({ }, container: { paddingVertical: 5, - paddingHorizontal: 16, }, }); diff --git a/src/screens/Home/components/MyBooks.js b/src/screens/Home/components/MyBooks.js index 873f64a..b5250b9 100644 --- a/src/screens/Home/components/MyBooks.js +++ b/src/screens/Home/components/MyBooks.js @@ -20,7 +20,6 @@ import fontSize from "../../../constants/fontSize"; const ios = Platform.OS === "ios"; function MyBooks({ books, grades, theme }) { - console.log(books); return books?.filter((book) => book.condition >= 2).length ? ( { const navigation = useNavigation(); - const [height, setHeight] = React.useState(Dimensions.get("window").height); + const [height, setHeight] = React.useState(height); const Location = ({ address, active }) => { return ( @@ -79,7 +84,12 @@ const ProfileAddress = ({ style={{ fontSize: fontSize.base, fontFamily: "bold", - color: Colors.theme1.gray20, + color: + theme === "light" + ? Colors.theme1.gray20 + : active + ? Colors.theme1.greenCF + : Colors.theme1.white, }} > آدرس انتخابی شما @@ -88,7 +98,12 @@ const ProfileAddress = ({ style={{ fontSize: fontSize.xs, fontFamily: "regular", - color: Colors.theme1.gray20, + color: + theme === "light" + ? Colors.theme1.gray20 + : active + ? Colors.theme1.greenCF + : Colors.theme1.white, marginRight: 10, }} > @@ -100,7 +115,13 @@ const ProfileAddress = ({ @@ -131,6 +158,12 @@ const ProfileAddress = ({ fontSize: mobile ? fontSize.sm : fontSize.lg, lineHeight: 22, textAlign: ios ? "right" : "auto", + color: + theme === "light" + ? Colors.theme1.gray20 + : active + ? Colors.theme1.greenCF + : Colors.theme1.white, }, ]} > @@ -144,6 +177,12 @@ const ProfileAddress = ({ fontSize: mobile ? fontSize.sm : fontSize.lg, lineHeight: 22, textAlign: ios ? "right" : "auto", + color: + theme === "light" + ? Colors.theme1.gray20 + : active + ? Colors.theme1.greenCF + : Colors.theme1.white, }, ]} > @@ -157,6 +196,12 @@ const ProfileAddress = ({ fontSize: mobile ? fontSize.sm : fontSize.lg, lineHeight: 22, textAlign: ios ? "right" : "auto", + color: + theme === "light" + ? Colors.theme1.gray20 + : active + ? Colors.theme1.greenCF + : Colors.theme1.white, }, ]} > @@ -170,6 +215,12 @@ const ProfileAddress = ({ fontSize: mobile ? fontSize.sm : fontSize.lg, lineHeight: 22, textAlign: ios ? "right" : "auto", + color: + theme === "light" + ? Colors.theme1.gray20 + : active + ? Colors.theme1.greenCF + : Colors.theme1.white, }, ]} > @@ -182,7 +233,13 @@ const ProfileAddress = ({ @@ -328,7 +391,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress); const styles = StyleSheet.create({ contentContainerStyle: { - paddingBottom: 100, + paddingBottom: height, position: "relative", }, container: { diff --git a/src/screens/Splash/index.js b/src/screens/Splash/index.js index 91ed301..70c247d 100644 --- a/src/screens/Splash/index.js +++ b/src/screens/Splash/index.js @@ -37,12 +37,13 @@ function Splash({ ); }, [theme]); - useEffect(async () => { - // console.log(isLogin); - // set theme + const getTheme = async () => { const theme = await AsyncStorage.getItem("theme"); setIsDark(theme); + }; + useEffect(() => { + getTheme(); if (isLogin !== null) { if (isLogin === false) { setOut(true); @@ -57,13 +58,11 @@ function Splash({ } else { setOut(true); navigation.navigate("Root"); - } } - }else{ - + } else { } - }, [isLogin]); + }, [isLogin, books, userProducts, blogs]); if (isFocused && out) { setOut(false);