|
|
|
@ -17,7 +17,6 @@ import { Ionicons } from "@expo/vector-icons"; |
|
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
|
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; |
|
|
|
|
import separate from "../../utils/separate"; |
|
|
|
|
import * as Linking from "expo-linking"; |
|
|
|
|
|
|
|
|
|
//components
|
|
|
|
|
import Product from "./components/Product"; |
|
|
|
@ -32,10 +31,9 @@ import fontSize from "../../constants/fontSize"; |
|
|
|
|
import Colors from "../../constants/Colors"; |
|
|
|
|
import tw from "tailwind-rn"; |
|
|
|
|
|
|
|
|
|
const { width, height } = Dimensions.get("window"); |
|
|
|
|
const { height } = Dimensions.get("window"); |
|
|
|
|
|
|
|
|
|
const PriceStatus = ({ name, value, type }) => { |
|
|
|
|
const colorScheme = Appearance.getColorScheme(); |
|
|
|
|
const PriceStatus = ({ name, value, type, theme }) => { |
|
|
|
|
return ( |
|
|
|
|
<View style={tw("w-full flex flex-row-reverse justify-between py-2")}> |
|
|
|
|
<Text |
|
|
|
@ -43,7 +41,7 @@ const PriceStatus = ({ name, value, type }) => { |
|
|
|
|
tw(""), |
|
|
|
|
{ |
|
|
|
|
fontSize: fontSize.tiny, |
|
|
|
|
color: Colors.theme1[colorScheme].gray20, |
|
|
|
|
color: Colors.theme1[theme].gray20, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
@ -56,8 +54,8 @@ const PriceStatus = ({ name, value, type }) => { |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
type === "error" |
|
|
|
|
? Colors.theme1[colorScheme].redFF1 |
|
|
|
|
: Colors.theme1[colorScheme].green79, |
|
|
|
|
? Colors.theme1[theme].redFF1 |
|
|
|
|
: Colors.theme1[theme].green79, |
|
|
|
|
fontSize: fontSize.xl, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
@ -70,8 +68,8 @@ const PriceStatus = ({ name, value, type }) => { |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
type === "error" |
|
|
|
|
? Colors.theme1[colorScheme].redFF1 |
|
|
|
|
: Colors.theme1[colorScheme].green79, |
|
|
|
|
? Colors.theme1[theme].redFF1 |
|
|
|
|
: Colors.theme1[theme].green79, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
marginRight: 4, |
|
|
|
@ -93,15 +91,22 @@ function ShoppingCart({ |
|
|
|
|
getFactorInfo, |
|
|
|
|
loading, |
|
|
|
|
payFactor, |
|
|
|
|
theme |
|
|
|
|
}) { |
|
|
|
|
const navigation = useNavigation(); |
|
|
|
|
const colorScheme = Appearance.getColorScheme(); |
|
|
|
|
const [position, setPosition] = useState("100%"); |
|
|
|
|
|
|
|
|
|
const isEmpty = list.filter((product) => product.condition < 2).length === 0; |
|
|
|
|
const hasPhysical = |
|
|
|
|
list.filter((product) => product.condition < 2 && product.productType === 2) |
|
|
|
|
.length !== 0; |
|
|
|
|
const isEmpty = React.useMemo(() => { |
|
|
|
|
return list.filter((product) => product.condition < 2).length === 0; |
|
|
|
|
}, [list]); |
|
|
|
|
|
|
|
|
|
const hasPhysical = React.useMemo(() => { |
|
|
|
|
return ( |
|
|
|
|
list.filter( |
|
|
|
|
(product) => product.condition < 2 && product.productType === 2 |
|
|
|
|
).length !== 0 |
|
|
|
|
); |
|
|
|
|
}, [list]); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (list.length === 0) { |
|
|
|
@ -157,20 +162,29 @@ function ShoppingCart({ |
|
|
|
|
> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="مبلغ سبد خرید" |
|
|
|
|
value={isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice || 0))} |
|
|
|
|
value={ |
|
|
|
|
isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice || 0)) |
|
|
|
|
} |
|
|
|
|
type="normal" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="میزان تخفیف" |
|
|
|
|
value={isEmpty ? 0 : separate(Math.round(factorInfo?.offPrice || 0))} |
|
|
|
|
value={ |
|
|
|
|
isEmpty ? 0 : separate(Math.round(factorInfo?.offPrice || 0)) |
|
|
|
|
} |
|
|
|
|
type="error" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="مالیات بر ارزش افزوده" |
|
|
|
|
value={ |
|
|
|
|
isEmpty ? 0 : separate(Math.round((factorInfo?.sumPrice || 0) * 0.009)) |
|
|
|
|
isEmpty |
|
|
|
|
? 0 |
|
|
|
|
: separate(Math.round((factorInfo?.sumPrice || 0) * 0.009)) |
|
|
|
|
} |
|
|
|
|
type="error" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View |
|
|
|
@ -181,7 +195,7 @@ function ShoppingCart({ |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
color: Colors.theme1[theme].green79, |
|
|
|
|
fontSize: fontSize.base, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
@ -193,18 +207,18 @@ function ShoppingCart({ |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
color: Colors.theme1[theme].green79, |
|
|
|
|
fontSize: fontSize.xl, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
{isEmpty ? 0 : separate(factorInfo?.payPrice || '')} |
|
|
|
|
{isEmpty ? 0 : separate(factorInfo?.payPrice || "")} |
|
|
|
|
</Text> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
color: Colors.theme1[theme].green79, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
marginRight: 4, |
|
|
|
@ -221,14 +235,14 @@ function ShoppingCart({ |
|
|
|
|
tw( |
|
|
|
|
"w-full rounded-md flex flex-row justify-center items-center py-3 px-3 my-5" |
|
|
|
|
), |
|
|
|
|
{ backgroundColor: Colors.theme1[colorScheme].greenC8 + "1a" }, |
|
|
|
|
{ backgroundColor: Colors.theme1[theme].greenC8 + "1a" }, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
tw("mr-1"), |
|
|
|
|
{ |
|
|
|
|
color: Colors.theme1[colorScheme].green79, |
|
|
|
|
color: Colors.theme1[theme].green79, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
}, |
|
|
|
@ -239,13 +253,13 @@ function ShoppingCart({ |
|
|
|
|
<Ionicons |
|
|
|
|
name="alert-circle-outline" |
|
|
|
|
size={20} |
|
|
|
|
color={Colors.theme1[colorScheme].greenC8} |
|
|
|
|
color={Colors.theme1[theme].greenC8} |
|
|
|
|
/> |
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
|
|
<CustomPressable |
|
|
|
|
title={hasPhysical ? "ادامه فرایند خرید" : "پرداخت"} |
|
|
|
|
backgroundColor={Colors.theme1[colorScheme].greenCF} |
|
|
|
|
backgroundColor={Colors.theme1[theme].greenCF} |
|
|
|
|
color={"white"} |
|
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
|
width={"100%"} |
|
|
|
@ -279,6 +293,7 @@ const mapStateToProps = (state) => ({ |
|
|
|
|
userId: state.user.status?.id, |
|
|
|
|
hasPhysical: state.userProduct.hasPhysical, |
|
|
|
|
loading: state.userProduct.loading, |
|
|
|
|
theme: state.publicApi.theme |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|