|
|
@ -8,9 +8,10 @@ import { |
|
|
|
} from "react-native"; |
|
|
|
} from "react-native"; |
|
|
|
import React from "react"; |
|
|
|
import React from "react"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
import {asyncAwesomeAlert} from "../../../utils/AsyncWrappers"; |
|
|
|
import { Ionicons, Entypo } from "@expo/vector-icons"; |
|
|
|
import { Ionicons, Entypo } from "@expo/vector-icons"; |
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
import { userFactor } from "../../../redux/actions"; |
|
|
|
import { userFactor, userAddress } from "../../../redux/actions"; |
|
|
|
|
|
|
|
|
|
|
|
//style
|
|
|
|
//style
|
|
|
|
import tw from "tailwind-rn"; |
|
|
|
import tw from "tailwind-rn"; |
|
|
@ -26,6 +27,7 @@ const Address = ({ |
|
|
|
userAddressId, |
|
|
|
userAddressId, |
|
|
|
loading, |
|
|
|
loading, |
|
|
|
mobile, |
|
|
|
mobile, |
|
|
|
|
|
|
|
deleteItem, |
|
|
|
theme, |
|
|
|
theme, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const navigation = useNavigation(); |
|
|
|
const navigation = useNavigation(); |
|
|
@ -70,16 +72,14 @@ const Address = ({ |
|
|
|
{selectedItem === address?.id && loading ? ( |
|
|
|
{selectedItem === address?.id && loading ? ( |
|
|
|
<ActivityIndicator size="small" color={Colors.theme1.greenC8} /> |
|
|
|
<ActivityIndicator size="small" color={Colors.theme1.greenC8} /> |
|
|
|
) : active ? ( |
|
|
|
) : active ? ( |
|
|
|
<Entypo |
|
|
|
<Entypo name="check" size={20} color={Colors.theme1.greenCF} /> |
|
|
|
name="check" |
|
|
|
|
|
|
|
size={20} |
|
|
|
|
|
|
|
color={Colors.theme1.greenCF} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<Entypo |
|
|
|
<Entypo |
|
|
|
name="circle" |
|
|
|
name="circle" |
|
|
|
size={20} |
|
|
|
size={20} |
|
|
|
color={theme === "light" ? Colors.theme1.grayE3 : Colors.theme1.white} |
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.grayE3 : Colors.theme1.white |
|
|
|
|
|
|
|
} |
|
|
|
/> |
|
|
|
/> |
|
|
|
)} |
|
|
|
)} |
|
|
|
<View style={tw(`flex flex-1 ${mobile ? "mr-2" : "mr-5"}`)}> |
|
|
|
<View style={tw(`flex flex-1 ${mobile ? "mr-2" : "mr-5"}`)}> |
|
|
@ -103,13 +103,71 @@ const Address = ({ |
|
|
|
{address?.address} |
|
|
|
{address?.address} |
|
|
|
</Text> |
|
|
|
</Text> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
|
|
|
|
<View style={tw("flex flex-row-reverse h-full")}> |
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
style={tw("ml-3 h-full")} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
navigation.navigate("CreateAddress", { |
|
|
|
|
|
|
|
type: "editAddress", |
|
|
|
|
|
|
|
form: address, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Ionicons |
|
|
|
|
|
|
|
name="ios-pencil-sharp" |
|
|
|
|
|
|
|
size={16} |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? "#52796F" |
|
|
|
|
|
|
|
: active |
|
|
|
|
|
|
|
? Colors.theme1.greenCF |
|
|
|
|
|
|
|
: Colors.theme1.white |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
asyncAwesomeAlert("", "آدرس مورد نظر حذف شود؟", { |
|
|
|
|
|
|
|
showCancelButton: true, |
|
|
|
|
|
|
|
confirmText: "بله", |
|
|
|
|
|
|
|
cancelText: "لغو", |
|
|
|
|
|
|
|
onConfirm: () => deleteItem({ id: address?.id }), |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
style={tw('h-full')} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Ionicons |
|
|
|
|
|
|
|
name="trash-bin" |
|
|
|
|
|
|
|
size={16} |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
theme === "light" |
|
|
|
|
|
|
|
? "#52796F" |
|
|
|
|
|
|
|
: active |
|
|
|
|
|
|
|
? Colors.theme1.greenCF |
|
|
|
|
|
|
|
: Colors.theme1.white |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
</View> |
|
|
|
</Pressable> |
|
|
|
</Pressable> |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View style={tw("w-full mt-2")}> |
|
|
|
<View style={tw("w-full mt-2")}> |
|
|
|
<View style={tw("p-0 m-0 flex ")}> |
|
|
|
{addresses?.length ? ( |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.base : fontSize.xl, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: light ? Colors.theme1.green79 : Colors.theme1.white, |
|
|
|
|
|
|
|
textAlign: ios ? "right" : "auto", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
لطفا آدرس مورد نظر را انتخاب کنید. |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
<View style={tw("p-0 mt-2 flex")}> |
|
|
|
{addresses?.map((address, index) => ( |
|
|
|
{addresses?.map((address, index) => ( |
|
|
|
<Location |
|
|
|
<Location |
|
|
|
address={address} |
|
|
|
address={address} |
|
|
@ -136,7 +194,7 @@ const Address = ({ |
|
|
|
<Text |
|
|
|
<Text |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
fontFamily: "regular", |
|
|
|
fontFamily: "regular", |
|
|
|
fontSize: mobile ? fontSize.sm : fontSize.lg, |
|
|
|
fontSize: mobile ? fontSize.tiny : fontSize.lg, |
|
|
|
color: light ? Colors.theme1.gray2077 : Colors.theme1.grayE3, |
|
|
|
color: light ? Colors.theme1.gray2077 : Colors.theme1.grayE3, |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
@ -166,6 +224,7 @@ const mapStateToProps = (state) => ({ |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|
update: userFactor.update, |
|
|
|
update: userFactor.update, |
|
|
|
|
|
|
|
deleteItem: userAddress.update |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Address); |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Address); |
|
|
|