|
|
|
@ -9,6 +9,7 @@ import { |
|
|
|
|
SafeAreaView, |
|
|
|
|
StatusBar, |
|
|
|
|
LayoutAnimation, |
|
|
|
|
KeyboardAvoidingView, |
|
|
|
|
Appearance, |
|
|
|
|
} from "react-native"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
@ -128,89 +129,75 @@ function ShoppingCart({ |
|
|
|
|
style={{ |
|
|
|
|
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, |
|
|
|
|
position: "relative", |
|
|
|
|
height: height, |
|
|
|
|
flex: 1, |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<Navbar |
|
|
|
|
setBoxPosition={setBoxPosition} |
|
|
|
|
headerOptions={{ |
|
|
|
|
logo: false, |
|
|
|
|
menu: false, |
|
|
|
|
hamburgerMenu: false, |
|
|
|
|
title: "سبد خرید", |
|
|
|
|
bookmark: false, |
|
|
|
|
qr: false, |
|
|
|
|
back: false, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<Drawer setBoxPosition={setBoxPosition} position={position} /> |
|
|
|
|
{list?.filter((product) => product?.condition < 2)?.length ? ( |
|
|
|
|
<ScrollView |
|
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
|
style={styles.container} |
|
|
|
|
> |
|
|
|
|
{list |
|
|
|
|
?.sort((a, b) => a?.id - b?.id) |
|
|
|
|
?.map((product, index) => |
|
|
|
|
product?.condition < 2 ? ( |
|
|
|
|
<Product key={index} product={product} loading={loading} /> |
|
|
|
|
) : null |
|
|
|
|
)} |
|
|
|
|
<Code /> |
|
|
|
|
<View |
|
|
|
|
style={tw( |
|
|
|
|
`flex w-full border-t py-2 border-gray-300 border-b mt-6 ${ |
|
|
|
|
theme === "light" ? "" : "border-opacity-20" |
|
|
|
|
}` |
|
|
|
|
)} |
|
|
|
|
> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="مبلغ سبد خرید" |
|
|
|
|
value={ |
|
|
|
|
isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice || 0)) |
|
|
|
|
} |
|
|
|
|
type="normal" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="میزان تخفیف" |
|
|
|
|
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)) |
|
|
|
|
} |
|
|
|
|
type="error" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View |
|
|
|
|
style={tw( |
|
|
|
|
"flex flex-row-reverse justify-between items-center w-full py-3" |
|
|
|
|
)} |
|
|
|
|
<KeyboardAvoidingView behavior="padding" style={{ flex: 1 }}> |
|
|
|
|
<Navbar |
|
|
|
|
setBoxPosition={setBoxPosition} |
|
|
|
|
headerOptions={{ |
|
|
|
|
logo: false, |
|
|
|
|
menu: false, |
|
|
|
|
hamburgerMenu: false, |
|
|
|
|
title: "سبد خرید", |
|
|
|
|
bookmark: false, |
|
|
|
|
qr: false, |
|
|
|
|
back: false, |
|
|
|
|
}} |
|
|
|
|
/> |
|
|
|
|
<Drawer setBoxPosition={setBoxPosition} position={position} /> |
|
|
|
|
{list?.filter((product) => product?.condition < 2)?.length ? ( |
|
|
|
|
<ScrollView |
|
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
|
style={styles.container} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.base, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
{list |
|
|
|
|
?.sort((a, b) => a?.id - b?.id) |
|
|
|
|
?.map((product, index) => |
|
|
|
|
product?.condition < 2 ? ( |
|
|
|
|
<Product key={index} product={product} loading={loading} /> |
|
|
|
|
) : null |
|
|
|
|
)} |
|
|
|
|
<Code /> |
|
|
|
|
<View |
|
|
|
|
style={tw( |
|
|
|
|
`flex w-full border-t py-2 border-gray-300 border-b mt-6 ${ |
|
|
|
|
theme === "light" ? "" : "border-opacity-20" |
|
|
|
|
}` |
|
|
|
|
)} |
|
|
|
|
> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="مبلغ سبد خرید" |
|
|
|
|
value={ |
|
|
|
|
isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice || 0)) |
|
|
|
|
} |
|
|
|
|
type="normal" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
<PriceStatus |
|
|
|
|
name="میزان تخفیف" |
|
|
|
|
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)) |
|
|
|
|
} |
|
|
|
|
type="error" |
|
|
|
|
theme={theme} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
<View |
|
|
|
|
style={tw( |
|
|
|
|
"flex flex-row-reverse justify-between items-center w-full py-3" |
|
|
|
|
)} |
|
|
|
|
> |
|
|
|
|
جمع کل سبد خرید |
|
|
|
|
</Text> |
|
|
|
|
<View style={tw("flex flex-row-reverse items-center")}> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
@ -218,95 +205,111 @@ function ShoppingCart({ |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.xl, |
|
|
|
|
fontSize: fontSize.base, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
{isEmpty ? 0 : separate(factorInfo?.payPrice || "")} |
|
|
|
|
</Text> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
marginRight: 4, |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
تومان |
|
|
|
|
جمع کل سبد خرید |
|
|
|
|
</Text> |
|
|
|
|
<View style={tw("flex flex-row-reverse items-center")}> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.xl, |
|
|
|
|
fontFamily: "bold", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
{isEmpty ? 0 : separate(factorInfo?.payPrice || "")} |
|
|
|
|
</Text> |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
marginRight: 4, |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
تومان |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
<View style={tw("w-full")}> |
|
|
|
|
<Pressable |
|
|
|
|
style={[ |
|
|
|
|
tw( |
|
|
|
|
"w-full rounded-md flex flex-row justify-center items-center py-3 px-3 my-5" |
|
|
|
|
), |
|
|
|
|
{ |
|
|
|
|
backgroundColor: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.greenC8 + "1a" |
|
|
|
|
: Colors.theme1.blue90 + "33", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
|
<View style={tw("w-full")}> |
|
|
|
|
<Pressable |
|
|
|
|
style={[ |
|
|
|
|
tw("mr-1"), |
|
|
|
|
tw( |
|
|
|
|
"w-full rounded-md flex flex-row justify-center items-center py-3 px-3 my-5" |
|
|
|
|
), |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
backgroundColor: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
? Colors.theme1.greenC8 + "1a" |
|
|
|
|
: Colors.theme1.blue90 + "33", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
هزینه ارسال کالا پس از تعیین محل آدرس مشخص میشود |
|
|
|
|
</Text> |
|
|
|
|
<Ionicons |
|
|
|
|
name="alert-circle-outline" |
|
|
|
|
size={20} |
|
|
|
|
color={ |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.greenC8 |
|
|
|
|
: Colors.theme1.white |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
tw("mr-1"), |
|
|
|
|
{ |
|
|
|
|
color: |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.green79 |
|
|
|
|
: Colors.theme1.white, |
|
|
|
|
fontSize: fontSize.sm, |
|
|
|
|
fontFamily: "regular", |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
هزینه ارسال کالا پس از تعیین محل آدرس مشخص میشود |
|
|
|
|
</Text> |
|
|
|
|
<Ionicons |
|
|
|
|
name="alert-circle-outline" |
|
|
|
|
size={20} |
|
|
|
|
color={ |
|
|
|
|
theme === "light" |
|
|
|
|
? Colors.theme1.greenC8 |
|
|
|
|
: Colors.theme1.white |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
|
|
<CustomPressable |
|
|
|
|
title={hasPhysical ? "ادامه فرایند خرید" : "پرداخت"} |
|
|
|
|
backgroundColor={Colors.theme1.greenCF} |
|
|
|
|
color={"white"} |
|
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
|
width={"100%"} |
|
|
|
|
onPress={() => |
|
|
|
|
isEmpty |
|
|
|
|
? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", { |
|
|
|
|
showCancelButton: false, |
|
|
|
|
}) |
|
|
|
|
: hasPhysical |
|
|
|
|
? navigation.navigate("DeliveryForm") |
|
|
|
|
: payFactor({ userId }) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
|
|
<CustomPressable |
|
|
|
|
title={hasPhysical ? "ادامه فرایند خرید" : "پرداخت"} |
|
|
|
|
backgroundColor={Colors.theme1.greenCF} |
|
|
|
|
color={"white"} |
|
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
|
width={"100%"} |
|
|
|
|
onPress={() => |
|
|
|
|
isEmpty |
|
|
|
|
? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", { |
|
|
|
|
showCancelButton: false, |
|
|
|
|
}) |
|
|
|
|
: hasPhysical |
|
|
|
|
? navigation.navigate("DeliveryForm") |
|
|
|
|
: payFactor({ userId }) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
</ScrollView> |
|
|
|
|
) : ( |
|
|
|
|
<Empty |
|
|
|
|
text={"سبد خرید شما خالی است"} |
|
|
|
|
buttonText={"فروشگاه"} |
|
|
|
|
buttonAction={() => navigation.navigate("Products")} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
</View> |
|
|
|
|
</ScrollView> |
|
|
|
|
) : ( |
|
|
|
|
<Empty |
|
|
|
|
text={"سبد خرید شما خالی است"} |
|
|
|
|
buttonText={"فروشگاه"} |
|
|
|
|
buttonAction={() => navigation.navigate("Products")} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
</KeyboardAvoidingView> |
|
|
|
|
</SafeAreaView> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|