update 8 files

master
Reza_ashrafi 3 years ago
parent c10d14f827
commit b96f686440
  1. 1
      src/redux/actions/userProduct.js
  2. 1
      src/redux/reducers/config.js
  3. 22
      src/screens/Address/index.js
  4. 51
      src/screens/DeliveryForm/Address/index.js
  5. 4
      src/screens/DeliveryForm/TransportMethod/index.js
  6. 136
      src/screens/DeliveryForm/index.js
  7. 18
      src/screens/ShoppingCart/index.js

@ -24,7 +24,6 @@ const userProduct = {
(data = {}, data2 = {}, data3 = {}) => (data = {}, data2 = {}, data3 = {}) =>
async (dispatch) => { async (dispatch) => {
await proxy.post("userProduct/add", data, { dispatch }); await proxy.post("userProduct/add", data, { dispatch });
await proxy.get("userFactor/info", data3, { dispatch });
}, },
del: del:
(data = {}, data2 = {}) => (data = {}, data2 = {}) =>

@ -16,7 +16,6 @@ export default function config(state = initialState, action) {
error: null, error: null,
}; };
case "config/availableForSell": case "config/availableForSell":
console.log(data);
return { return {
...state, ...state,
loading: false, loading: false,

@ -553,17 +553,30 @@ const Address = ({
</View> </View>
{!profilePage ? ( {!profilePage ? (
<> <>
<View style={{ width: "100%", height: 250, marginTop: 20}}> <View
style={{
width: "100%",
height: height / 4,
marginTop: 20,
borderWidth: 1,
borderRadius: 2,
overflow: "hidden",
borderColor:
theme === "light"
? Colors.theme1.gray2077 + "66"
: Colors.theme1.grayE3,
}}
>
<MapSelector <MapSelector
setAddress={(address) => setMapAddress(address)} setAddress={(address) => setMapAddress(address)}
/> />
</View> </View>
<TextInput <TextInput
style={[ style={[
tw("w-full mt-4 py-4 px-2 rounded-md h-40"), tw("w-full mt-4 py-4 px-2 rounded-sm h-40"),
{ {
backgroundColor: backgroundColor:
theme === "light" ? Colors.theme1.grayF9 : null, theme === "light" ? Colors.theme1.white : null,
color: color:
theme === "light" theme === "light"
? Colors.theme1.gray20 ? Colors.theme1.gray20
@ -572,10 +585,9 @@ const Address = ({
textAlign: "right", textAlign: "right",
fontFamily: "light", fontFamily: "light",
borderWidth: 1, borderWidth: 1,
borderColor: borderColor:
theme === "light" theme === "light"
? Colors.theme1.grayE3 ? Colors.theme1.gray2077 + "66"
: Colors.theme1.white + "55", : Colors.theme1.white + "55",
}, },
]} ]}

@ -8,7 +8,7 @@ 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 { 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, userAddress } from "../../../redux/actions"; import { userFactor, userAddress } from "../../../redux/actions";
@ -59,7 +59,7 @@ const Address = ({
borderColor: active ? Colors.theme1.greenCF : Colors.theme1.grayE3, borderColor: active ? Colors.theme1.greenCF : Colors.theme1.grayE3,
}, },
tw( tw(
`flex flex-row-reverse items-center w-full px-3 rounded-sm mt-2 ${ `flex flex-row-reverse items-center w-full px-3 rounded-sm mt-2 mb-4 ${
mobile ? "py-3.5" : "py-4" mobile ? "py-3.5" : "py-4"
}` }`
), ),
@ -134,7 +134,7 @@ const Address = ({
onConfirm: () => deleteItem({ id: address?.id }), onConfirm: () => deleteItem({ id: address?.id }),
}) })
} }
style={tw('h-full')} style={tw("h-full")}
> >
<Ionicons <Ionicons
name="trash-bin" name="trash-bin"
@ -156,26 +156,29 @@ const Address = ({
return ( return (
<View style={tw("w-full mt-2")}> <View style={tw("w-full mt-2")}>
{addresses?.length ? ( {addresses?.length ? (
<Text <React.Fragment>
style={{ <Text
fontSize: mobile ? fontSize.base : fontSize.base, style={{
fontFamily: "bold", fontSize: mobile ? fontSize.base : fontSize.base,
color: light ? Colors.theme1.green79 : Colors.theme1.white, fontFamily: "bold",
textAlign: ios ? "right" : "auto", color: light ? Colors.theme1.green79 : Colors.theme1.white,
}} textAlign: ios ? "right" : "auto",
> }}
لطفا آدرس مورد نظر را انتخاب کنید. >
</Text> لطفا آدرس مورد نظر را انتخاب کنید.
</Text>
<View style={tw("p-0 mt-2 flex")}>
{addresses?.map((address, index) => (
<Location
address={address}
key={index}
active={userAddressId === address?.id}
/>
))}
</View>
</React.Fragment>
) : null} ) : null}
<View style={tw("p-0 mt-2 flex")}>
{addresses?.map((address, index) => (
<Location
address={address}
key={index}
active={userAddressId === address?.id}
/>
))}
</View>
<TouchableOpacity <TouchableOpacity
style={[ style={[
{ {
@ -186,7 +189,7 @@ const Address = ({
borderWidth: 1.5, borderWidth: 1.5,
}, },
tw( tw(
`flex flex-row-reverse justify-center py-3 rounded-sm items-center w-full mt-4` `flex flex-row-reverse justify-center py-3 rounded-sm items-center w-full`
), ),
]} ]}
onPress={() => navigation.push("CreateAddress")} onPress={() => navigation.push("CreateAddress")}
@ -224,7 +227,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
update: userFactor.update, update: userFactor.update,
deleteItem: userAddress.update deleteItem: userAddress.update,
}; };
export default connect(mapStateToProps, mapDispatchToProps)(Address); export default connect(mapStateToProps, mapDispatchToProps)(Address);

@ -139,7 +139,7 @@ const TransportMethod = ({
[factorInfo, loading] [factorInfo, loading]
); );
return ( return factorInfo?.transports?.length ? (
<View style={tw(`w-full ${mobile ? "mt-4" : "mt-4"}`)}> <View style={tw(`w-full ${mobile ? "mt-4" : "mt-4"}`)}>
<Text <Text
style={{ style={{
@ -161,7 +161,7 @@ const TransportMethod = ({
))} ))}
</View> </View>
</View> </View>
); ) : null;
}; };
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({

@ -6,11 +6,13 @@ import {
StatusBar, StatusBar,
Platform, Platform,
Dimensions, Dimensions,
Text
} from "react-native"; } from "react-native";
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { userFactor, userAddress } from "../../redux/actions"; import { userFactor, userAddress } from "../../redux/actions";
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
import separate from "../../utils/separate";
//components //components
import Navbar from "../../components/Navbar"; import Navbar from "../../components/Navbar";
@ -23,9 +25,65 @@ import CustomPressable from "../../components/Pressable";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
import Colors from "../../constants/Colors"; import Colors from "../../constants/Colors";
import fontSize from "../../constants/fontSize";
const { height } = Dimensions.get("window"); const { height } = Dimensions.get("window");
const PriceStatus = ({ name, value, type, theme }) => {
return (
<View style={tw("w-full flex flex-row-reverse justify-between py-2")}>
<Text
style={[
tw(""),
{
fontSize: fontSize.tiny,
color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontFamily: "bold",
},
]}
>
{name}
</Text>
<View style={tw("flex flex-row-reverse items-center")}>
<Text
style={[
{
color:
type === "error"
? Colors.theme1.redFF1
: theme === "light"
? Colors.theme1.green79
: Colors.theme1.white,
fontSize: fontSize.xl,
fontFamily: "bold",
},
]}
>
{value}
</Text>
<Text
style={[
{
color:
type === "error"
? Colors.theme1.redFF1
: theme === "light"
? Colors.theme1.green79
: Colors.theme1.white,
fontSize: fontSize.sm,
fontFamily: "regular",
marginRight: 4,
},
]}
>
تومان
</Text>
</View>
</View>
);
};
const DeliveryForm = ({ const DeliveryForm = ({
list, list,
form, form,
@ -85,6 +143,83 @@ const DeliveryForm = ({
<TransportDate transportDate={form?.transportDate} /> <TransportDate transportDate={form?.transportDate} />
</View> </View>
) : null} ) : null}
<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={separate(Math.round(factorInfo?.sumPrice || 0))}
type="normal"
theme={theme}
/>
<PriceStatus
name="هزینه ارسال"
value={separate(Math.round(list?.length ? factorInfo?.transportPrice : 0))}
type="error"
theme={theme}
/>
<PriceStatus
name="میزان تخفیف"
value={separate(Math.round(factorInfo?.offPrice || 0))}
type="error"
theme={theme}
/>
</View>
<View
style={tw(
"flex flex-row-reverse justify-between items-center w-full py-3"
)}
>
<Text
style={[
{
color:
theme === "light"
? Colors.theme1.green79
: Colors.theme1.white,
fontSize: fontSize.base,
fontFamily: "bold",
},
]}
>
جمع کل سبد خرید
</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",
},
]}
>
{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>
</ScrollView> </ScrollView>
<View style={tw("w-full pt-4")}> <View style={tw("w-full pt-4")}>
@ -114,7 +249,6 @@ const styles = StyleSheet.create({
}, },
container: { container: {
paddingVertical: 5, paddingVertical: 5,
}, },
}); });

@ -114,6 +114,10 @@ function ShoppingCart({
); );
}, [list]); }, [list]);
useEffect(() => {
getFactorInfo({ userId });
}, [list]);
useEffect(() => { useEffect(() => {
getList(); getList();
getFactorInfo({ userId }); getFactorInfo({ userId });
@ -174,6 +178,7 @@ function ShoppingCart({
type="normal" type="normal"
theme={theme} theme={theme}
/> />
<PriceStatus <PriceStatus
name="میزان تخفیف" name="میزان تخفیف"
value={ value={
@ -182,16 +187,7 @@ function ShoppingCart({
type="error" type="error"
theme={theme} theme={theme}
/> />
<PriceStatus
name="مالیات بر ارزش افزوده"
value={
isEmpty
? 0
: separate(Math.round((factorInfo?.sumPrice || 0) * 0.009))
}
type="error"
theme={theme}
/>
</View> </View>
<View <View
style={tw( style={tw(
@ -225,7 +221,7 @@ function ShoppingCart({
}, },
]} ]}
> >
{isEmpty ? 0 : separate(factorInfo?.payPrice || "")} {isEmpty ? 0 : separate(factorInfo?.payPrice - factorInfo?.transportPrice)}
</Text> </Text>
<Text <Text
style={[ style={[

Loading…
Cancel
Save