Skip to content

Commit

Permalink
Revert "Merge pull request #152 from Katyusha-Group/Fix/Timeline-Prof…
Browse files Browse the repository at this point in the history
…ile-Data"

This reverts commit ce83520, reversing
changes made to 6b91328.
  • Loading branch information
ymasteryfarahani committed Jan 28, 2024
1 parent dba8c35 commit 5f967ef
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 158 deletions.
5 changes: 1 addition & 4 deletions src/assets/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export const apis = {

tweets: {
tweets: `${domain}/twittes/`,
twittedBy: `${domain}/twittes/?twitted_by=`,
likedBy: `${domain}/twittes/?liked_by=`,
repliedBy: `${domain}/twittes/?replied_by=`,
},
reports: {
tweets: `${domain}/report-twitte/`,
Expand All @@ -87,7 +84,7 @@ export const apis = {
forYouTwittes: {
forYouTwittes: `${domain}/for-you-twittes/`,
},
chat: {
chat:{
chat: `${chatDomain}/ws/chat/`,
chatWith: `${domain}/chat/chat-with/`,
}
Expand Down
4 changes: 0 additions & 4 deletions src/assets/css/Profile.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@
border-bottom: 2px solid var(--purple);
}

.chatIcon {
padding-left: 7px;
font-size: large;
}

@media only screen and (max-width: 1064px) {
.leftpart {
Expand Down
21 changes: 0 additions & 21 deletions src/hooks/useLikedBy.jsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/hooks/useRepliedBy.jsx

This file was deleted.

21 changes: 0 additions & 21 deletions src/hooks/useTweetBy.jsx

This file was deleted.

21 changes: 8 additions & 13 deletions src/views/TimeLine/Timeline_Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import TeacherTimeline from "../../components/TeacherTimeline/TeacherTimeline";
import StudentTimeline from "./StudentTimeline.jsx";
import { useTweets } from "../../hooks/Twitter/useTweets";
import { useGetChartData } from "../../hooks/GetChartData.jsx";
import { useTweetBy } from "../../hooks/useTweetBy.jsx";
import { useLikedBy } from "../../hooks/useLikedBy.jsx";
import { useRepliedBy } from "../../hooks/useRepliedBy.jsx";


function Timeline({ tabsList, profileData, profileData_loading, setProfileData, username, IsThisMe }) {
if (profileData_loading) {
return <></>
Expand All @@ -37,9 +36,6 @@ function Timeline({ tabsList, profileData, profileData_loading, setProfileData,
];
}
const { data: tweets, setData: setTweets, loading } = useTweets("get", true);
const { filteredTweets, tweetLoading } = useTweetBy(profileData.username);
const { likedTweets, likedLoading } = useLikedBy(profileData.username);
const { repliedTweets, repliedLoading } = useRepliedBy(profileData.username);
const [open, setOpen] = useState(false);
return (
<>
Expand All @@ -65,7 +61,7 @@ function Timeline({ tabsList, profileData, profileData_loading, setProfileData,
<div className={styles.content}>
{activeTab === "Tweets" && (
<div className={styles.tweetsContainer}>
{filteredTweets.results.map((tweet) => (
{tweets.results.map((tweet) => (
<Tweet key={tweet.id}
tweet={tweet}
setOpenComment={setOpen}
Expand Down Expand Up @@ -106,10 +102,9 @@ function Timeline({ tabsList, profileData, profileData_loading, setProfileData,
</div>)}
</div>
)}
{/* {console.log(tweets)} */}
{activeTab === "Likes" && (
<div className={styles.tweetsContainer}>
{likedTweets.results.map((tweet) => (
{tweets.results.filter(item => item.liked_by_me).map((tweet) => (
<Tweet
key={tweet.id}
tweet={tweet}
Expand All @@ -121,14 +116,14 @@ function Timeline({ tabsList, profileData, profileData_loading, setProfileData,
)}
{activeTab === "Comments" && (
<div className={styles.tweetsContainer}>
{repliedTweets.results.map((tweet) => {
return <Tweet
{tweets.results.map((tweet) => (
<Tweet
key={tweet.id}
tweet={tweet.parent_info}
tweet={tweet}
setOpenComment={setOpen}
setTweets={setTweets}
/>
})}
))}
</div>
)}
<ModalProfileHeader
Expand Down
142 changes: 70 additions & 72 deletions src/views/UserPorfile/ProfileHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ import { POSTFollow } from '../../hooks/POSTFollow';
import { useNavigate } from 'react-router-dom';
import { apis } from '../../assets/apis';
import Spinner from "react-bootstrap/Spinner";
export default function ProfileHeader({ profile, setProfileData, username, IsThisMe, profileData_loading }) {
export default function ProfileHeader({profile, setProfileData, username, IsThisMe, profileData_loading}) {
// console.log("Profile in profile header: ", profile);
const [showModal, setShowModal] = React.useState(false);
const [IsFollowing, setIsFollowing] = React.useState(false); // Which Modal
// const [profileData_Here, setProfileData_Here] = React.useState(profile);
const [IsFollowed, setIsFollowed] = React.useState(profile.is_followed);

if (profileData_loading) {
if (profileData_loading)
{
return (
<div>
<Spinner animation="border" variant="primary" />
</div>
);
}

const handleOpenModal_Following = () => {
setIsFollowing(true);
setShowModal(true);
Expand Down Expand Up @@ -57,21 +58,21 @@ export default function ProfileHeader({ profile, setProfileData, username, IsThi
fetch((apis["profiles"]["view_profile"] + `${username}`), {
headers: { Authorization: `Bearer ${token}` },
})
.then(response => {
return response.json().then((data) => {
setProfileData(data);
});
})
.catch((error) => {
console.error(error);
.then(response => {
return response.json().then((data) => {
setProfileData(data);
});
})
.catch((error) => {
console.error(error);
});
}, []);



const dateObj = new Date(profile.created_at);
const formattedDate = dateObj.toISOString().split('T')[0].replace(/-/g, '/');
const date = moment(formattedDate, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD');
const date =moment(formattedDate, 'YYYY/MM/DD').locale('fa').format('YYYY/MM/DD');

// let Button_Data = IsThisMe ?
// "ویرایش پروفایل" :
Expand All @@ -80,77 +81,74 @@ export default function ProfileHeader({ profile, setProfileData, username, IsThi
// "دنبال کردن";

const navigate = useNavigate();
function Profile_Button() {
if (IsThisMe) {
function Profile_Button () {
if (IsThisMe)
{
navigate('/user');
}
else if (IsFollowed) {
else if (IsFollowed)
{
setIsFollowed(prev => !prev);
POSTFollow(username, !IsFollowed); // unfollow
}
else {
else
{
setIsFollowed(prev => !prev);
POSTFollow(username, !IsFollowed); // follow
}
}
return (
<div className={styles.rightUpper}>
<div className={styles.ProfileHeader_Content}>
<img className={styles.ProfileImage}
src={profile.image}
// src="https://www.katyushaiust.ir/media/images/profile_pics/male_default.png"
alt="" />
<p className={styles.myusername}>
@{profile.username}
<a href={"/chat/" + username} className={styles.chatIcon}>
<i className='tim-icons icon-chat-33'></i>
</a>
</p>

<div className={styles.Followes}>
<div onClick={handleOpenModal_Following} className={styles.Following_Follower}>
<i className='tim-icons icon-single-02'></i>
<span className={styles.Followes_Count}>{profile.following_count}</span>
<p>دنبال میشود</p>
<div className={styles.rightUpper}>
<div className={styles.ProfileHeader_Content}>
<img className={styles.ProfileImage}
src={profile.image}
// src="https://www.katyushaiust.ir/media/images/profile_pics/male_default.png"
alt="" />
<p className={styles.myusername}> @{profile.username} </p>
<div className={styles.Followes}>
<div onClick={handleOpenModal_Following} className={styles.Following_Follower}>
<i className='tim-icons icon-single-02'></i>
<span className={styles.Followes_Count}>{profile.following_count}</span>
<p>دنبال میشود</p>
</div>
<div onClick={handleOpenModal_Followers} className={styles.Following_Follower}>
<i className='tim-icons icon-single-02'></i>
<span className={styles.Followes_Count}>{profile.followers_count}</span>
<p>دنبال کننده</p>
</div>
<UsersListModal
showModal={showModal}
handleClose={handleCloseModal}
IsFollowing={IsFollowing} // Is it Following or Follower Modal
// Followings={Followings}
// Followers={Followers}
username={username}
IsThisMe = {IsThisMe}
/>
</div>
<button className={styles.followbutton} onClick={Profile_Button}>
{IsThisMe ?
"ویرایش پروفایل" :
profile.is_followed ?
"حذف" :
"دنبال کردن"}
</button>
</div>
<div onClick={handleOpenModal_Followers} className={styles.Following_Follower}>
<i className='tim-icons icon-single-02'></i>
<span className={styles.Followes_Count}>{profile.followers_count}</span>
<p>دنبال کننده</p>

<div className={styles.ProfileHeader_Other}>
<div className={styles.ProfileHeader_Other_Item}>
<p>نام</p>
<p>{profile.name}</p>
</div>
<div className={styles.ProfileHeader_Other_Item}>
<p>نام کاربری</p>
<p>{profile.username}@</p>
</div>
<div className={styles.ProfileHeader_Other_Item}>
<p>تاریخ شروع فعالیت</p>
<p>{date}</p>
</div>
</div>
<UsersListModal
showModal={showModal}
handleClose={handleCloseModal}
IsFollowing={IsFollowing} // Is it Following or Follower Modal
// Followings={Followings}
// Followers={Followers}
username={username}
IsThisMe={IsThisMe}
/>
</div>
<button className={styles.followbutton} onClick={Profile_Button}>
{IsThisMe ?
"ویرایش پروفایل" :
profile.is_followed ?
"حذف" :
"دنبال کردن"}
</button>
</div>

<div className={styles.ProfileHeader_Other}>
<div className={styles.ProfileHeader_Other_Item}>
<p>نام</p>
<p>{profile.name}</p>
</div>
<div className={styles.ProfileHeader_Other_Item}>
<p>نام کاربری</p>
<p>{profile.username}@</p>
</div>
<div className={styles.ProfileHeader_Other_Item}>
<p>تاریخ شروع فعالیت</p>
<p>{date}</p>
</div>
</div>
</div>
)
)
}
2 changes: 1 addition & 1 deletion src/views/UserSearchResponce.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const UserSearchResponce = (res) => {
<div className={styles.main2}>
<img className={styles.img} src={res.res.image} />
<p className={styles.text}>
{res.res.name}
{res.res.name }
</p>
</div>
</Link>
Expand Down

0 comments on commit 5f967ef

Please sign in to comment.