diff --git a/src/screens/DeliveryForm/Address/index.js b/src/screens/DeliveryForm/Address/index.js index b5ed183..a04f07c 100644 --- a/src/screens/DeliveryForm/Address/index.js +++ b/src/screens/DeliveryForm/Address/index.js @@ -8,9 +8,10 @@ import { } from "react-native"; import React from "react"; import { connect } from "react-redux"; +import {asyncAwesomeAlert} from "../../../utils/AsyncWrappers"; import { Ionicons, Entypo } from "@expo/vector-icons"; import { useNavigation } from "@react-navigation/native"; -import { userFactor } from "../../../redux/actions"; +import { userFactor, userAddress } from "../../../redux/actions"; //style import tw from "tailwind-rn"; @@ -26,6 +27,7 @@ const Address = ({ userAddressId, loading, mobile, + deleteItem, theme, }) => { const navigation = useNavigation(); @@ -70,16 +72,14 @@ const Address = ({ {selectedItem === address?.id && loading ? ( ) : active ? ( - + ) : ( )} @@ -103,13 +103,71 @@ const Address = ({ {address?.address} + + + navigation.navigate("CreateAddress", { + type: "editAddress", + form: address, + }) + } + > + + + + asyncAwesomeAlert("", "آدرس مورد نظر حذف شود؟", { + showCancelButton: true, + confirmText: "بله", + cancelText: "لغو", + onConfirm: () => deleteItem({ id: address?.id }), + }) + } + style={tw('h-full')} + > + + + ); }; return ( - + {addresses?.length ? ( + + لطفا آدرس مورد نظر را انتخاب کنید. + + ) : null} + {addresses?.map((address, index) => ( @@ -166,6 +224,7 @@ const mapStateToProps = (state) => ({ const mapDispatchToProps = { update: userFactor.update, + deleteItem: userAddress.update }; export default connect(mapStateToProps, mapDispatchToProps)(Address); diff --git a/src/screens/DeliveryForm/index.js b/src/screens/DeliveryForm/index.js index 66e869d..63fb046 100644 --- a/src/screens/DeliveryForm/index.js +++ b/src/screens/DeliveryForm/index.js @@ -96,7 +96,7 @@ const DeliveryForm = ({ width={"100%"} onPress={() => factorInfo?.transportId && factorInfo?.userAddressId - ? payFactor({ userId }) + ? payFactor({ userId, clientUrl: "dnvn://" }) : asyncAwesomeAlert("خطا", "آدرس یا نحوه ارسال را وارد کنید", { showCancelButton: false, confirmText: "باشه", diff --git a/src/screens/QR/layouts/Scan/index.js b/src/screens/QR/layouts/Scan/index.js index 9e05156..df58aa3 100644 --- a/src/screens/QR/layouts/Scan/index.js +++ b/src/screens/QR/layouts/Scan/index.js @@ -21,7 +21,7 @@ const { width, height } = Dimensions.get("screen"); //assets import laptopImage from "../../assets/laptop.png"; -function Scan({ theme, page }) { +function Scan({ route, theme, page }) { const navigation = useNavigation(); const [hasPermission, setHasPermission] = React.useState(null); const [scanned, setScanned] = React.useState(false); @@ -33,17 +33,24 @@ function Scan({ theme, page }) { })(); }, []); - const handleBarCodeScanned = React.useCallback( - ({ type, data }) => { - setScanned(true); - if (page === "activation") { - navigation.push("Activation", { data }); - } else { - navigation.push("QRContent", { data }); - } - }, - [page, scanned] - ); + const handleBarCodeScanned = ({ type, data }) => { + setScanned(true); + if (page === "activation") { + setTimeout(() => { + setScanned(false); + }, 300); + navigation.replace("Activation", { + data: data.slice(data.lastIndexOf("/") + 1, data.length), + }); + } else { + setTimeout(() => { + setScanned(false); + }, 300); + navigation.replace("QRContent", { + data: data.slice(data.lastIndexOf("/") + 1, data.length), + }); + } + }; return ( - {hasPermission ? ( + {hasPermission && !scanned ? ( ) : null}