Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website3.0/components/AuthButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if (session.status === 'unauthenticated' && !isLogin) {
// Function to fetch user data from local storage and server if logged in
async function fetchData1() {
setIsLogin(true);
let session = await JSON.parse(localStorage.getItem('finalUser'));
let session = await (() => { try { return (JSON.parse(localStorage.getItem('finalUser') ?? "null") ?? null) } catch { return null } })();

// Fetch or create account on the server
let response = await fetch("/api/createaccount", {
Expand Down
120 changes: 1 addition & 119 deletions website3.0/components/ParticleBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,122 +12,4 @@ const ParticlesComponent = (props) => {
// Load slim configuration for particles engine
await loadSlim(engine);
}).then(() => {
// Set initialization flag to true once particles engine is initialized
setInit(true);
});
}, []);

// Function to handle when particles are loaded into the container
const particlesLoaded = (container) => {
};

// Memoized options for particles configuration
const options = useMemo(
() => ({
// Limit frames per second for particle rendering
fpsLimit: 120,
fullScreen:{
enable:false,
zindex:0
},
interactivity: {
events: {
onClick: {
enable: true,
// Interaction mode on click
mode: "repulse",
},
onHover: {
enable: true,
// Interaction mode on hover
mode: "repulse",
},
},
modes: {
repulse: {
// Distance of repulsion effect
distance: 200,
// Duration of repulsion effect
duration: 0.4,
},
grab: {
// Distance of grab interaction
distance: 150,
},
},
},
particles: {
number: {
// Number of particles
value: 100,
density: {
enable: true,
// Area within which particles are density distributed
value_area: 800,
},
},
color: {
// Particle color
value: "#FFFFFF",
},
shape: {
// Particle shape type
type: "triangle",
stroke: {
width: 0,
// Stroke color
color: "#000000",
},
polygon: {
// Number of sides for polygon shape
nb_sides: 12,
},
},
links: {
// Color of links between particles
color: "#FFFFFF",
// Distance of links between particles
distance: 180,
// Enable linking between particles
enable: true,
// Opacity of links
opacity: 0.8,
// Width of links
width: 1,
},
move: {
// Movement direction of particles
direction: "none",
// Enable particle movement
enable: true,
outModes: {
// Out mode for particles when they move out of canvas
default: "bounce",
},
// Random movement direction
random: true,
// Speed of particle movement
speed: 5,
// Allow straight particle movement
straight: false,
},
opacity: {
// Opacity value of particles
value: 0.7,
},
size: {
// Size range of particles
value: { min: 1, max: 3 },
},
},
// Detect retina displays
detectRetina: true,
}),
[]
);

// Render Particles component with specified ID, initialization callback, and options
return <Particles id={props.id} init={particlesLoaded} options={options} />;
};

export default ParticlesComponent;
.catch(err => console.error(err))
4 changes: 2 additions & 2 deletions website3.0/components/admin/dashboard/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const Overview = () => {
}, {});

// Convert to arrays for Chart.js
const labels = Object.keys(blogCountsByDate).sort();
const chartData = labels.map(label => blogCountsByDate[label]);
const labels = Object.keys(blogCountsByDate).sort((a, b) => a - b);
const chartData = (labels ?? []).map(label => blogCountsByDate[label]);

setChartData({
labels,
Expand Down
6 changes: 3 additions & 3 deletions website3.0/components/forumpage/ForumPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function ForumPost({ theme, id, finalUser, setMsg, setIsPopup }) {
}

// Create a new issue object with the updated state
const updatedSolutions = issue.solutions.map((solution, i) =>
const updatedSolutions = issue.(solutions ?? []).map((solution, i) =>
i === index ? { ...solution, isAccepted: true } : solution
);

Expand Down Expand Up @@ -301,7 +301,7 @@ function ForumPost({ theme, id, finalUser, setMsg, setIsPopup }) {
setIsComment(false);
let arr = document.getElementsByClassName("ql-editor");
Array.from(arr).map((data) => {
data.innerHTML = "";
data.textContent = "";
});
} catch (error) {
console.error("Error adding comment:", error);
Expand Down Expand Up @@ -1124,7 +1124,7 @@ function ForumPost({ theme, id, finalUser, setMsg, setIsPopup }) {
}
)
}
{/* {replies.map((reply, index) => (
{/* {(replies ?? []).map((reply, index) => (
<div
key={index}
className="relative group mt-8 cursor-pointer"
Expand Down
94 changes: 1 addition & 93 deletions website3.0/components/profile/FollowersTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,96 +42,4 @@ async function handleFollow(userId) {
other_user_id: finalUser.email, // Use `finalUser.email` to identify the current user
}),
}).then(res => res.json());

// Update context and local storage with the new user data
setFinalUser(updatedData.user1);
localStorage.setItem('finalUser', JSON.stringify(updatedData.user1));
} catch (error) {
console.error("Error following user:", error);
}
}

// Handle unfollowing a user
async function handleUnFollow(userId) {
try {
const updatedData = await fetch("/api/unfollow", {
method: "POST",
body: JSON.stringify({
user_id: userId,
other_user_id: finalUser.email, // Use `finalUser.email` to identify the current user
}),
}).then(res => res.json());

// Update context and local storage with the new user data
setFinalUser(updatedData.user1);
localStorage.setItem('finalUser', JSON.stringify(updatedData.user1));
} catch (error) {
console.error("Error unfollowing user:", error);
}
}

// Toggle the visibility of the follow tab
const handleClose = () => {
setFollowTab(!FollowTab);
};
return (
<div className="auth-overlay">
<div className="auth-modal flex justify-center">
<div className={`w-[500px] overflow-hidden max-sm:w-[95vw] z-[1000000] ${theme ? "bg-slate-100 " : "bg-[#121111]"} opacityanimator h-[50vh] fixed m-auto top-[20%] rounded-xl`}>
<div className="flex min-h-[7vh] h-auto w-[100%] justify-center items-center">
<div
onClick={() => setFirstShow(true)}
className={`h-[7vh] w-[50%] relative cursor-pointer flex justify-center border-r-[1px] items-center border-b-2 ${firstShow ? "bg-gray-300 border-gray-400" : "border-gray-400"} ${theme ? "text-black" : "text-white"}`}
>
{firstShow && <span className={`absolute bottom-[-1px] left-0 animate-first h-[2px] bg-black ${theme ? "text-black" : "text-white"}`}></span>}
Followers
</div>
<div
onClick={() => setFirstShow(false)}
className={`w-[50%] relative cursor-pointer flex justify-center h-[7vh] items-center border-b-2 ${!firstShow ? "bg-gray-300 border-gray-500" : "border-gray-500"} ${theme ? "text-black" : "text-white"}`}
>
{!firstShow && <span className="absolute bottom-[-1px] left-0 animate-first h-[2px] bg-black"></span>}
Following
</div>
</div>
<div className="w-[100%] h-[42vh] overflow-hidden overflow-x-hidden">
{firstShow ? (
<div className="overflow-y-scroll h-[42vh] w-[100%]">
{userDetails.followers && Object.entries(userDetails.followers).map(([userId, [userImg, userName]]) => (
userId !== finalUser._id && (
<div key={userId} className="w-[100%] mt-[20px] h-[60px] items-center flex justify-between pl-[10px] pr-[10px] overflow-hidden">
<img height='60px' width='60px' className="rounded-full" src={userImg} alt={userName} />
<h1 className={`text-wrap text-center ${theme ? "text-black" : "text-white"}`}>{userName}</h1>
{(userId in finalUser.following) ? (
<button className="boton-elegante" onClick={() => handleUnFollow(userId)}>UnFollow</button>
) : (
<button className="boton-elegante" onClick={() => handleFollow(userId)}>Follow</button>
)}
</div>
)
))}
</div>
) : (
<div className="overflow-y-scroll h-[42vh] w-[100%]">
{userDetails.following && Object.entries(userDetails.following).map(([userId, [userImg, userName]]) => (
userId !== finalUser._id && (
<div key={userId} className="w-[100%] mt-[20px] h-[60px] items-center flex justify-between pl-[10px] pr-[10px] overflow-hidden">
<img height='60px' width='60px' className="rounded-full" src={userImg} alt={userName} />
<h1 className={`text-wrap text-center ${theme ? "text-black" : "text-white"}`}>{userName}</h1>
{(userId in finalUser.following) ? (
<button className="boton-elegante" onClick={() => handleUnFollow(userId)}>UnFollow</button>
) : (
<button className="boton-elegante" onClick={() => handleFollow(userId)}>Follow</button>
)}
</div>
)
))}
</div>
)}
</div>
</div>
</div>
<div className="fixed top-0 left-0 h-[100vh] w-[100vw] opacity-35 bg-black" onClick={handleClose}></div>
</div>
);
}
.catch(err => console.error(err))
Loading