fixed delivery from

master
Reza_ashrafi 3 years ago
parent bba4e1cb39
commit f629f48a40
  1. 2
      app.json
  2. 4
      src/redux/actions/transport.js
  3. 6
      src/redux/actions/userAddress.js
  4. 1
      src/redux/actions/userFactor.js
  5. 1
      src/redux/reducers/transport.js
  6. 12
      src/redux/reducers/userAddress.js
  7. 4
      src/redux/reducers/userFactor.js
  8. 80
      src/screens/DeliveryForm/Address/index.js
  9. 2
      src/screens/DeliveryForm/TransportDate/index.js
  10. 28
      src/screens/DeliveryForm/TransportMethod/index.js
  11. 13
      src/screens/DeliveryForm/index.js
  12. 1
      src/screens/Home/components/MyBooks.js
  13. 83
      src/screens/Profile/components/ProfileAddress/index.js
  14. 11
      src/screens/Splash/index.js

@ -6,7 +6,7 @@
"orientation": "portrait",
"userInterfaceStyle": "automatic",
"icon": "./assets/appLogo.png",
"scheme": "danovin",
"scheme": "dnvn",
"splash": {
"image": "",
"resizeMode": "contain",

@ -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);
},
};

@ -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);
},
};

@ -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 = {}) =>

@ -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":

@ -1,3 +1,4 @@
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
const initialState = {
loading: false,
error: null,
@ -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;

@ -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":

@ -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 (
<Pressable
style={[
{
backgroundColor:
userAddressId === address?.id
backgroundColor: active
? light
? Colors.theme1.greenCF + "15"
: Colors.theme1.grayE3 + "44",
: Colors.theme1.dark
: light
? Colors.theme1.grayE3 + "44"
: Colors.theme1.dark,
borderWidth: 1.5,
borderColor:
userAddressId === address?.id
? Colors.theme1.greenCF
: Colors.theme1.grayE3,
borderColor: active ? Colors.theme1.greenCF : Colors.theme1.grayE3,
},
tw(
`flex flex-row-reverse items-center w-full px-3 rounded-sm mt-2 ${
mobile ? "py-2" : "py-4"
mobile ? "py-3.5" : "py-4"
}`
),
]}
onPress={() =>
userAddressId === address?.id
? {}
: update({ userAddressId: address.id, userId })
}
onPress={() => {
setSelectedItem(address.id);
active ? {} : update({ userAddressId: address.id, userId });
}}
>
{loading ? (
userAddressId !== address?.id ? (
{selectedItem === address.id && loading ? (
<ActivityIndicator size="small" color={Colors.theme1.greenC8} />
) : active ? (
<Entypo
name="check"
size={20}
color={Colors.theme1.greenCF}
/>
) : (
<View
style={[
tw("w-5 h-5 rounded-full"),
{
backgroundColor: active ? Colors.theme1.greenCF : "white",
borderWidth: userAddressId === address?.id ? 4 : 1,
borderColor:
userAddressId === address?.id
? Colors.theme1.black
: Colors.theme1.gray20 + "33",
},
]}
></View>
)
) : null}
<Entypo
name="circle"
size={20}
color={theme === "light" ? Colors.theme1.grayE3 : Colors.theme1.white}
/>
)}
<View style={tw(`flex flex-1 ${mobile ? "mr-2" : "mr-5"}`)}>
<Text
style={[
{
fontFamily: "regular",
fontSize: mobile ? fontSize.sm : fontSize.lg,
fontSize: mobile ? fontSize.tiny : fontSize.lg,
lineHeight: 22,
textAlign: ios ? "right" : "auto",
color: active
? light
? Colors.theme1.gray20
: Colors.theme1.greenCF
: light
? Colors.theme1.gray20
: Colors.theme1.white,
},
]}
>
@ -93,10 +107,6 @@ const Address = ({
);
};
const light = React.useMemo(() => {
return theme === "light";
}, [theme]);
return (
<View style={tw("w-full mt-2")}>
<View style={tw("p-0 m-0 flex ")}>

@ -73,7 +73,7 @@ const TransportDate = ({ transportDate, mobile, theme }) => {
}, []);
return (
<View style={tw(`w-full ${mobile ? "mt-4" : "mt-4"}`)}>
<View style={tw(`w-full`)}>
<Text
style={{
fontSize: mobile ? fontSize.base : fontSize.xl2,

@ -31,10 +31,18 @@ const TransportMethod = ({
getList();
}, []);
const [selectedItem, setSelectedItem] = React.useState(null);
const light = React.useMemo(() => {
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
backgroundColor: light
? active
? Colors.theme1.greenCF + "15"
: Colors.theme1.grayE3 + "44" : null,
: 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 ? (
<ActivityIndicator
size="small"
color={
@ -127,6 +138,7 @@ const TransportMethod = ({
},
[factorInfo, loading]
);
return (
<View style={tw(`w-full ${mobile ? "mt-4" : "mt-4"}`)}>
<Text
@ -140,11 +152,11 @@ const TransportMethod = ({
لطفا یک روش ارسال انتخاب کنید.
</Text>
<View style={tw("p-0 m-0 flex w-full")}>
{list?.map((method, index) => (
{factorInfo?.transports?.map((method, index) => (
<Method
method={method}
active={factorInfo.transportId === method?.id}
key={index}
active={factorInfo?.transportId === method?.id}
/>
))}
</View>

@ -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,
}}
>
<Navbar
@ -64,6 +69,7 @@ const DeliveryForm = ({
}}
/>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.contentContainerStyle}
style={styles.container}
>
@ -74,9 +80,14 @@ const DeliveryForm = ({
<View style={tw("w-full flex flex-row mt-5")}>
<TransportMethod />
</View>
{factorInfo.transportId === 2 ? (
<View style={tw("w-full flex flex-row mt-5 mb-5")}>
<TransportDate transportDate={form.transportDate} />
</View>
) : null}
</View>
</ScrollView>
<View style={tw("w-full pt-4")}>
<CustomPressable
title={"پرداخت"}
backgroundColor={Colors.theme1.greenCF}
@ -93,7 +104,6 @@ const DeliveryForm = ({
}
/>
</View>
</ScrollView>
</SafeAreaView>
);
};
@ -104,7 +114,6 @@ const styles = StyleSheet.create({
},
container: {
paddingVertical: 5,
paddingHorizontal: 16,
},
});

@ -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 ? (
<View style={[tw("flex w-full mb-5")]}>
<View

@ -29,6 +29,7 @@ import Colors from "../../../../constants/Colors";
import fontSize from "../../../../constants/fontSize";
const ios = Platform.OS === "ios";
const { height, width } = Dimensions.get("window");
const ProfileAddress = ({
addresses,
@ -43,7 +44,7 @@ const ProfileAddress = ({
deleteItem,
}) => {
const navigation = useNavigation();
const [height, setHeight] = React.useState(Dimensions.get("window").height);
const [height, setHeight] = React.useState(height);
const Location = ({ address, active }) => {
return (
<Pressable
@ -51,8 +52,12 @@ const ProfileAddress = ({
{
backgroundColor:
userAddressId === address?.id
? theme === "light"
? Colors.theme1.greenCF + "0a"
: Colors.theme1.grayE3 + "44",
: Colors.theme1.dark
: theme === "light"
? Colors.theme1.grayE3 + "44"
: Colors.theme1.dark,
borderWidth: 2,
borderColor:
userAddressId === address?.id
@ -60,7 +65,7 @@ const ProfileAddress = ({
: Colors.theme1.grayE3,
},
tw(
`flex flex-row-reverse items-center w-full px-3 py-2 rounded-md mt-2`
`flex flex-row-reverse items-center w-full px-3 py-2 rounded-md mb-4`
),
]}
onPress={() =>
@ -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 = ({
<Ionicons
name="ios-pencil-sharp"
size={20}
color={theme === "light" ? "#52796F" : Colors.theme1.white}
color={
theme === "light"
? "#52796F"
: active
? Colors.theme1.greenCF
: Colors.theme1.white
}
/>
</Pressable>
<Pressable
@ -116,7 +137,13 @@ const ProfileAddress = ({
<Ionicons
name="trash-bin"
size={20}
color={theme === "light" ? "#52796F" : Colors.theme1.white}
color={
theme === "light"
? "#52796F"
: active
? Colors.theme1.greenCF
: Colors.theme1.white
}
/>
</Pressable>
</View>
@ -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 = ({
<Ionicons
name="ios-pencil-sharp"
size={20}
color={theme === "light" ? "#52796F" : Colors.theme1.white}
color={
theme === "light"
? "#52796F"
: active
? Colors.theme1.greenCF
: Colors.theme1.white
}
/>
</Pressable>
<Pressable
@ -198,7 +255,13 @@ const ProfileAddress = ({
<Ionicons
name="trash-bin"
size={20}
color={theme === "light" ? "#52796F" : Colors.theme1.white}
color={
theme === "light"
? "#52796F"
: active
? Colors.theme1.greenCF
: Colors.theme1.white
}
/>
</Pressable>
</View>
@ -328,7 +391,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress);
const styles = StyleSheet.create({
contentContainerStyle: {
paddingBottom: 100,
paddingBottom: height,
position: "relative",
},
container: {

@ -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 {
}
}, [isLogin]);
}, [isLogin, books, userProducts, blogs]);
if (isFocused && out) {
setOut(false);

Loading…
Cancel
Save