some change

master
Reza_ashrafi 3 years ago
parent 9400f85860
commit ed0b11f49b
  1. 4
      src/redux/actions/userFactor.js
  2. 4
      src/redux/actions/userFavorite.js
  3. 11
      src/redux/reducers/userFactor.js
  4. 20
      src/redux/reducers/userFavorite.js
  5. 44
      src/screens/Address/index.js
  6. 26
      src/screens/OrdersFollowUp/index.js
  7. 84
      src/screens/Profile/components/ProfileBookmark/index.js
  8. 2
      src/screens/ShoppingCart/index.js

@ -50,6 +50,10 @@ const userFactor = {
await proxy.delete("userFactor/deleteUserOffCode", data, { dispatch });
await proxy.get("userFactor/info", data2, { dispatch });
},
fullList:
(data = {}) =>
async (dispatch) =>
await proxy.get("userFactor/fullList", data, { dispatch }),
};
export default userFactor;

@ -21,9 +21,9 @@ const userFavorite = {
del:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.delete("userFavorite/delete", data);
await proxy.delete("userFavorite/delete", data, { dispatch });
await proxy.get("userFavorite/list", data2, { dispatch });
},
};
export default userFavorite;
export default userFavorite;

@ -1,4 +1,4 @@
import {asyncAwesomeAlert} from '../../utils/AsyncWrappers';
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
const initialState = {
loading: false,
@ -8,6 +8,7 @@ const initialState = {
sum: null,
checkEmpty: false,
isVerified: null,
fullList: [],
};
export default function userFactor(state = initialState, action) {
// const navigation = useNavigation();
@ -26,6 +27,14 @@ export default function userFactor(state = initialState, action) {
checkEmpty: checkEmpty.length > 0 ? false : true,
error: null,
};
case "userFactor/fullList":
console.log(data);
return {
...state,
loading: false,
fullList: data,
error: null,
};
case "userFactor/info":
return { ...state, loading: false, info: data, error: null };
case "userFactor/add":

@ -1,31 +1,31 @@
import { toastMessage} from '../../utils/message';
import { asyncAwesomeAlert } from '../../utils/AsyncWrappers';
import { toastMessage } from "../../utils/message";
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
const initialState = {
loading: false,
error: null,
list: [],
};
export default function userAddress(state = initialState, action) {
export default function userFavorite(state = initialState, action) {
let { type, data } = action;
switch (type) {
case "userAddress/list":
case "userFavorite/list":
return {
...state,
loading: false,
list: data,
error: null,
};
case "userAddress/update":
case "userFavorite/update":
return { ...state, loading: false, error: null };
case "userAddress/add":
toastMessage('به لیست علاقهمندیها اضافه شد.');
case "userFavorite/add":
toastMessage("به لیست علاقهمندیها اضافه شد.");
return { ...state, loading: false, error: null };
case "userAddress/delete":
case "userFavorite/delete":
return { ...state, loading: false, error: null };
case "userAddress/loading":
case "userFavorite/loading":
return { ...state, loading: true };
case "userAddress/error":
case "userFavorite/error":
asyncAwesomeAlert("خطا", data.message, {
showCancelButton: false,
});

@ -57,28 +57,28 @@ const Address = ({
useEffect(() => {
getProvince();
setProfileFields({
file: user.picFileId,
picFileId: user.picFileId,
docFileIds: user.docFileIds,
cellphone: user.cellphone,
firstName: user.firstName,
lastName: user.lastName,
password: user.password,
username: user.username,
address: user.address,
email: user.email,
birthDate: user.birthDate,
gender: user.gender,
status: user.status,
nationalId: user.nationalId,
phone: user.phone,
schools: user.schools,
zoneId: user.zoneId,
schoolId: user.schoolId,
postalCode: user.postalCode,
gradeIds: user.gradeIds,
provinceId: user.provinceId,
cityId: user.cityId,
file: user?.picFileId,
picFileId: user?.picFileId,
docFileIds: user?.docFileIds,
cellphone: user?.cellphone,
firstName: user?.firstName,
lastName: user?.lastName,
password: user?.password,
username: user?.username,
address: user?.address,
email: user?.email,
birthDate: user?.birthDate,
gender: user?.gender,
status: user?.status,
nationalId: user?.nationalId,
phone: user?.phone,
schools: user?.schools,
zoneId: user?.zoneId,
schoolId: user?.schoolId,
postalCode: user?.postalCode,
gradeIds: user?.gradeIds,
provinceId: user?.provinceId,
cityId: user?.cityId,
});
}, []);

@ -1,4 +1,7 @@
import React, { useState } from "react";
import { connect } from "react-redux";
import { userFactor } from "../../redux/actions";
import {
Dimensions,
StyleSheet,
@ -8,20 +11,29 @@ import {
Platform,
LayoutAnimation,
} from "react-native";
//components
import Order from "./components/Order";
import Navbar from "../../components/Navbar";
import Drawer from "../../components/Drawer";
//assets
import b1Image from "./assets/b1.png";
const width = Dimensions.get("window").width;
function OrdersFollowUp({ orders }) {
function OrdersFollowUp({ orders, getList }) {
const [position, setPosition] = useState("100%");
const setBoxPosition = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setPosition(position === "100%" ? "0%" : "100%");
};
React.useEffect(() => {
getList();
},[]);
return (
<SafeAreaView
style={{
@ -35,7 +47,7 @@ function OrdersFollowUp({ orders }) {
logo: false,
menu: false,
hamburgerMenu: false,
title: "سفارشات",
title: "سفارشات",
bookmark: false,
qr: false,
back: true,
@ -67,7 +79,15 @@ const styles = StyleSheet.create({
},
});
export default OrdersFollowUp;
const mapStateToProps = (state) => ({
});
const mapDispatchToProps = {
getList: userFactor.fullList,
}
export default connect(mapStateToProps, mapDispatchToProps)(OrdersFollowUp);
OrdersFollowUp.defaultProps = {
orders: [

@ -2,7 +2,6 @@ import {
View,
Text,
Pressable,
Appearance,
SafeAreaView,
ScrollView,
StyleSheet,
@ -10,7 +9,7 @@ import {
Dimensions,
StatusBar,
Image,
mobile,
Appearance
} from "react-native";
import React from "react";
import { connect } from "react-redux";
@ -21,6 +20,7 @@ import { userFavorite } from "../../../../redux/actions";
//components
import Navbar from "../../../../components/Navbar";
import Empty from "../../../../components/Empty";
import Blur from "../../../../components/Blur";
//style
import tw from "tailwind-rn";
@ -33,7 +33,9 @@ import bookImage from "../../..//OrdersFollowUp/assets/b1.png";
const { height, width } = Dimensions.get("window");
const ios = Platform.OS === "ios";
const ProfileBookmark = ({ bookmarkList, getList }) => {
const ProfileBookmark = ({ bookmarkList, getList, deleteItem, loading, mobile }) => {
const colorScheme = Appearance.getColorScheme();
React.useEffect(() => {
getList();
}, []);
@ -57,7 +59,22 @@ const ProfileBookmark = ({ bookmarkList, getList }) => {
back: true,
}}
/>
{bookmarkList?.length > 0 ? (
{loading && (
<View
style={[
tw("absolute left-0 top-0 rounded-md overflow-hidden"),
{
width: Dimensions.get("window").width,
height: height,
zIndex: 1,
backgroundColor: Colors.theme1[colorScheme].white + "60",
},
]}
>
<Blur />
</View>
)}
{bookmarkList.length > 0 ? (
<ScrollView
contentContainerStyle={styles.contentContainerStyle}
style={styles.container}
@ -65,7 +82,12 @@ const ProfileBookmark = ({ bookmarkList, getList }) => {
<View style={tw("w-full mt-2 px-4")}>
<View style={tw("p-0 m-0 flex")}>
{bookmarkList?.map((bookmark, index) => (
<Bookmark key={index} bookmark={bookmark} />
<Bookmark
key={index}
bookmark={bookmark}
deleteItem={deleteItem}
mobile={mobile}
/>
))}
</View>
</View>
@ -77,13 +99,13 @@ const ProfileBookmark = ({ bookmarkList, getList }) => {
);
};
const Bookmark = ({ bookmark }) => {
const Bookmark = ({ bookmark, deleteItem, mobile }) => {
const colorScheme = Appearance.getColorScheme();
return (
<Pressable
style={[
tw("flex flex-row-reverse rounded-md justify-between px-3.5 py-2 bg-red-100"),
tw("flex flex-row-reverse rounded-md justify-between px-3.5 py-2 mb-4"),
{
borderWidth: 1.5,
borderColor: Colors.theme1[colorScheme].greenCF,
@ -92,7 +114,7 @@ const Bookmark = ({ bookmark }) => {
>
<View style={tw("flex flex-row-reverse items-end")}>
<Image
source={bookmark.image}
source={bookmark?.image}
style={{
width: mobile ? width / 5 : width / 7,
minWidth: 80,
@ -118,30 +140,32 @@ const Bookmark = ({ bookmark }) => {
color: Colors.theme1[colorScheme].gray20,
}}
>
{bookmark.grade}
{bookmark?.grade}
</Text>
</View>
</View>
<Svg
data-name="vuesax/linear/archive-add"
xmlns="http://www.w3.org/2000/svg"
width={29.778}
height={29.778}
>
<Path
d="M20.869 2.482H8.908a4.8 4.8 0 0 0-4.789 4.789v17.483c0 2.233 1.6 3.176 3.561 2.1l6.055-3.362a2.628 2.628 0 0 1 2.32 0l6.055 3.362c1.96 1.092 3.561.149 3.561-2.1V7.271a4.819 4.819 0 0 0-4.802-4.789Z"
fill="#37a865"
/>
<Path
data-name="Vector"
d="M17.987 13.214h-6.2"
fill="none"
stroke="#fff"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
/>
</Svg>
<Pressable onPress={() => deleteItem({ id: bookmark.id })}>
<Svg
data-name="vuesax/linear/archive-add"
xmlns="http://www.w3.org/2000/svg"
width={29.778}
height={29.778}
>
<Path
d="M20.869 2.482H8.908a4.8 4.8 0 0 0-4.789 4.789v17.483c0 2.233 1.6 3.176 3.561 2.1l6.055-3.362a2.628 2.628 0 0 1 2.32 0l6.055 3.362c1.96 1.092 3.561.149 3.561-2.1V7.271a4.819 4.819 0 0 0-4.802-4.789Z"
fill="#37a865"
/>
<Path
data-name="Vector"
d="M17.987 13.214h-6.2"
fill="none"
stroke="#fff"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
/>
</Svg>
</Pressable>
</Pressable>
);
};
@ -150,10 +174,12 @@ const mapStateToProps = (state) => ({
loading: state.userFactor.loading,
mobile: state.publicApi.mobile,
bookmarkList: state.userFavorite.list,
loading: state.userFavorite.loading,
});
const mapDispatchToProps = {
getList: userFavorite.list,
deleteItem: userFavorite.del,
};
export default connect(mapStateToProps, mapDispatchToProps)(ProfileBookmark);

@ -199,7 +199,7 @@ function ShoppingCart({
},
]}
>
{isEmpty ? 0 : separate(factorInfo?.payPrice)}
{isEmpty ? 0 : separate(factorInfo?.payPrice || '')}
</Text>
<Text
style={[

Loading…
Cancel
Save