diff --git a/src/redux/actions/userFactor.js b/src/redux/actions/userFactor.js index a46962c..a1064db 100644 --- a/src/redux/actions/userFactor.js +++ b/src/redux/actions/userFactor.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; diff --git a/src/redux/actions/userFavorite.js b/src/redux/actions/userFavorite.js index fb140d1..943628d 100644 --- a/src/redux/actions/userFavorite.js +++ b/src/redux/actions/userFavorite.js @@ -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; \ No newline at end of file +export default userFavorite; diff --git a/src/redux/reducers/userFactor.js b/src/redux/reducers/userFactor.js index 9791495..ddfa548 100644 --- a/src/redux/reducers/userFactor.js +++ b/src/redux/reducers/userFactor.js @@ -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": diff --git a/src/redux/reducers/userFavorite.js b/src/redux/reducers/userFavorite.js index 740d4d3..5f10ccd 100644 --- a/src/redux/reducers/userFavorite.js +++ b/src/redux/reducers/userFavorite.js @@ -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, }); diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index b49aafb..c101479 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -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, }); }, []); diff --git a/src/screens/OrdersFollowUp/index.js b/src/screens/OrdersFollowUp/index.js index 6b40b26..1966e78 100644 --- a/src/screens/OrdersFollowUp/index.js +++ b/src/screens/OrdersFollowUp/index.js @@ -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 ( ({ + +}); + +const mapDispatchToProps = { + getList: userFactor.fullList, +} + +export default connect(mapStateToProps, mapDispatchToProps)(OrdersFollowUp); OrdersFollowUp.defaultProps = { orders: [ diff --git a/src/screens/Profile/components/ProfileBookmark/index.js b/src/screens/Profile/components/ProfileBookmark/index.js index 5ae16a6..187b8de 100644 --- a/src/screens/Profile/components/ProfileBookmark/index.js +++ b/src/screens/Profile/components/ProfileBookmark/index.js @@ -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 && ( + + + + )} + {bookmarkList.length > 0 ? ( { {bookmarkList?.map((bookmark, index) => ( - + ))} @@ -77,13 +99,13 @@ const ProfileBookmark = ({ bookmarkList, getList }) => { ); }; -const Bookmark = ({ bookmark }) => { +const Bookmark = ({ bookmark, deleteItem, mobile }) => { const colorScheme = Appearance.getColorScheme(); return ( { > { color: Colors.theme1[colorScheme].gray20, }} > - {bookmark.grade} + {bookmark?.grade} - - - - + deleteItem({ id: bookmark.id })}> + + + + + ); }; @@ -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); diff --git a/src/screens/ShoppingCart/index.js b/src/screens/ShoppingCart/index.js index 3e15354..258ec9c 100644 --- a/src/screens/ShoppingCart/index.js +++ b/src/screens/ShoppingCart/index.js @@ -199,7 +199,7 @@ function ShoppingCart({ }, ]} > - {isEmpty ? 0 : separate(factorInfo?.payPrice)} + {isEmpty ? 0 : separate(factorInfo?.payPrice || '')}