Skip to content

Commit 4c786ef

Browse files
authored
Merge pull request #1280 from Ayushmaanagarwal1211/Bugs
Fixed all bugs in the grow your reach page
2 parents ddfbd07 + 481256b commit 4c786ef

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

website3.0/components/profile/GrowYourReachTab.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ function GrowYourReachTab() {
2424

2525
if (finalUser && finalUser.following) {
2626
const followingIds = Object.keys(finalUser.following);
27-
const nonFollowersList = allUsers.filter(
27+
let nonFollowersList = allUsers.filter(
2828
user => !followingIds.includes(user._id) && user._id !== finalUser._id
2929
);
30-
30+
let arr=[finalUser.name]
31+
nonFollowersList=nonFollowersList.filter((dataa)=>{
32+
if(!arr.includes(dataa.name)){
33+
arr.push(dataa.name)
34+
return dataa
35+
}
36+
})
3137
setNonFollowers(nonFollowersList);
3238
}
3339
} else {
@@ -59,7 +65,7 @@ function GrowYourReachTab() {
5965
{user.name}
6066
</div>
6167
<a
62-
href={`/profile?id=${user._id}`}
68+
href={`/profile?id=${user.username}&&isView=true`}
6369
target="_blank"
6470
rel="noopener noreferrer"
6571
className={`${theme?"bg-[#6089a4]":"bg-[#979797]"} text-lg max-md:text-sm text-white px-4 py-2 rounded-md`}

website3.0/components/profile/ProfilepageDetails.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export default function ProfilepageDetails({ isViewProfile, id }) {
171171
});
172172
data = await data.json();
173173
if (data.success) {
174+
console.log(data.msg,finalUser,'user')
174175
setViewUserDetails(data.msg);
175176
if (isLogin1) {
176177
if (data.msg.followers.hasOwnProperty(finalUser._id)) {
@@ -319,7 +320,7 @@ export default function ProfilepageDetails({ isViewProfile, id }) {
319320

320321
<div className="w-full h-72 overflow-hidden">
321322
<img
322-
src={finalUser.banner}
323+
src={isViewProfile?viewUserDetails.banner:finalUser.banner}
323324
alt="banner"
324325
className="w-full h-full object-cover object-center"
325326
/>
@@ -428,7 +429,7 @@ export default function ProfilepageDetails({ isViewProfile, id }) {
428429
: finalUser.linkedin
429430
}
430431
>
431-
<a href={`${finalUser.linkedin}`}>
432+
<a href={`${isViewProfile?viewUserDetails.linkedin:finalUser.linkedin}`}>
432433
<FontAwesomeIcon icon={faLinkedinIn} color="#0072b1" />
433434
</a>
434435
</div>

website3.0/src/app/api/getuser/route.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export async function POST(req) {
1111
// Connect to MongoDB using Mongoose
1212
await mongoose.connect(MONGO_URI);
1313
try {
14-
let data = await user.findOne({ _id: id });
14+
let data = await user.findOne({ username: username });
15+
1516
// checking if user exist or not
1617
if (data) {
18+
1719
return NextResponse.json({ success: true, msg: data }, { status: "200" });
1820
} else {
19-
let data = await user.findOne({ username: username });
21+
let data = await user.findById( id );
2022
if(!data){
2123

2224
return NextResponse.json({ success: false }, { status: "200" });

website3.0/src/app/profile/page.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ const BlogDetails = () => <div className="min-h-screen mt-10 rounded-xl"><Dashbo
5252
const DeletedBlogs1=()=><div className="min-h-screen mt-10 rounded-xl"><DeletedBlogs/></div>
5353
const UnblockBlogs1=()=><div className="min-h-screen mt-10 rounded-xl"><Unblock/></div>
5454

55-
const Profile = ({ id }) => (
55+
const Profile = ({ id ,isView}) => (
5656
<div className="bg-gray-100 mt-10 rounded-xl">
57-
<ProfilepageDetails isViewProfile={id.length > 0} id={id} />
57+
<ProfilepageDetails isViewProfile={isView} id={id} />
5858
</div>
5959
);
6060

@@ -130,6 +130,7 @@ const ProfilePage = () => {
130130
const [notificationCount, setNotificationCount] = useState(0); // State for unread notifications count
131131
const pathname = usePathname(); // Get current path
132132
const [id, setId] = useState("");
133+
let [isView,setIsView]=useState(false)
133134
const isViewProfile = id.length > 0;
134135
const router = useRouter();
135136

@@ -142,15 +143,18 @@ const ProfilePage = () => {
142143

143144
// Get the 'id' query parameter from the URL
144145
const idFromQuery = getUrlParameter("id");
145-
146+
let isView=getUrlParameter("isView")
147+
if(isView){
148+
setIsView(true)
149+
}
146150
if (idFromQuery) {
147151
const storedUser = localStorage.getItem("finalUser");
148152
const parsedUser = storedUser ? JSON.parse(storedUser) : isViewProfile;
149153
if (parsedUser.username !== idFromQuery) {
150154
setId(idFromQuery);
151155
}
152156
}
153-
setActiveComponent(<Profile id={id} />);
157+
setActiveComponent(<Profile id={id} isView={isView} />);
154158
setActiveMenuItem("Profile");
155159
}, [id, isViewProfile]); // Adjust dependencies if needed
156160

@@ -262,7 +266,7 @@ const ProfilePage = () => {
262266
title="Profile"
263267
icon={faAddressCard}
264268
isCollapsible={true}
265-
onClick={() => handleMenuClick(<Profile id={id} />, "Profile")}
269+
onClick={() => handleMenuClick(<Profile isView={isView} id={id} />, "Profile")}
266270
isActive={activeMenuItem === "Profile"}
267271
theme={theme}
268272
>

0 commit comments

Comments
 (0)