import { View, Text, Pressable, SafeAreaView, ScrollView, StyleSheet, Platform, Dimensions, StatusBar, Image, ActivityIndicator, } from "react-native"; import React from "react"; import { connect } from "react-redux"; import Svg, { Path } from "react-native-svg"; import { userFavorite } from "../../../../redux/actions"; import { useNavigation } from "@react-navigation/native"; //components import Navbar from "../../../../components/Navbar"; import Empty from "../../../../components/Empty"; //style import tw from "tailwind-rn"; import Colors from "../../../../constants/Colors"; import fontSize from "../../../../constants/fontSize"; const { height, width } = Dimensions.get("window"); const ios = Platform.OS === "ios"; const ProfileBookmark = ({ bookmarkList, deleteItem, loading, mobile, grades, theme, }) => { return ( {bookmarkList?.length ? ( {bookmarkList?.map((bookmark, index) => ( ))} ) : ( )} ); }; const Bookmark = ({ bookmark, deleteItem, mobile, grades, theme, loading }) => { const navigation = useNavigation(); const [selectedBookmark, setSelectedBookmark] = React.useState(null); const isContent = React.useMemo(() => { return bookmark?.contentId; }, [bookmark]); const deleteAction = async (action) => { setSelectedBookmark(bookmark); await action(); }; React.useEffect(() => { if (!loading) { setSelectedBookmark(null); } }, [loading]); return ( navigation.push(isContent ? "Blog" : "Product", { id: isContent ? bookmark?.contentId : bookmark?.product?.bookId, }) } > {isContent ? bookmark?.content?.name : bookmark?.product?.book?.name} {!isContent ? ( {"پایه" + " " + grades[bookmark?.product?.book?.gradeId]} ) : null} {selectedBookmark === bookmark ? ( ) : ( deleteAction(deleteItem({ id: bookmark?.id }))} > )} ); }; const mapStateToProps = (state) => ({ loading: state.userFactor.loading, mobile: state.publicApi.mobile, bookmarkList: state.userFavorite.list, loading: state.userFavorite.loading, grades: state.publicApi.grades, theme: state.publicApi.theme, }); const mapDispatchToProps = { deleteItem: userFavorite.del, }; export default connect(mapStateToProps, mapDispatchToProps)(ProfileBookmark); const styles = StyleSheet.create({ contentContainerStyle: { paddingBottom: 100, position: "relative", }, container: { flexDirection: "column", paddingVertical: 0, paddingHorizontal: 0, }, });