Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed 1:1 Mentorship bug #414

Closed
wants to merge 3 commits into from
Closed
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
81 changes: 30 additions & 51 deletions pages/teamprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,45 @@ import { useEffect } from "react";
const TeamMember = () => {
const router = useRouter();
const { name } = router.query;
const member = memberData.find((m) => m[name]);

const details = member ? member[name] : {};
const githubUsername = details.GitHub
? details.GitHub.split("/").pop()
: "";
const member = name ? memberData.find((m) => m[name]) : null;

useEffect(() => { // to embed topmate widget link
if (details.TopmateService) {
const script = document.createElement("script");
script.src =
"https://topmate-embed.s3.ap-south-1.amazonaws.com/v1/topmate-embed.js";
script.async = true;
script.defer = true;
const details = member ? member[name] : {};
const githubUsername = details.GitHub ? details.GitHub.split("/").pop() : "";

const isMobile = window.innerWidth <= 640; // Mobile screen (640px and below)
const isMedium = window.innerWidth > 640 && window.innerWidth <= 1024; // Medium screen (between 640px and 1024px)
useEffect(() => {
const buttonId = 'topmate-mentorship-button';

let positionRight = "80px";
let positionBottom = "30px";
let fontSize = "16px";
let customWidth = "160px";
if (member && details.TopmateService) {

if (isMobile) {
positionRight = "5px";
positionBottom = "5px";
fontSize = "14px";
customWidth = "140px";
} else if (isMedium) {
positionRight = "60px";
positionBottom = "40px";
fontSize = "15px";
customWidth = "150px";
}
if (!document.getElementById(buttonId)) {

script.setAttribute(
"user-profile",
`${details.TopmateService}?embed=true&theme=F97316`
);
script.setAttribute(
"btn-style",
'{"backgroundColor":"#000","color":"#fff","border":"1px solid #000"}'
);
script.setAttribute("embed-version", "v1");
script.setAttribute("button-text", "1:1 Mentorship");
script.setAttribute("position-right", positionRight);
script.setAttribute("position-bottom", positionBottom);
script.setAttribute("custom-padding", "0px");
script.setAttribute("custom-font-size", fontSize);
script.setAttribute("custom-font-weight", "500");
script.setAttribute("custom-width", customWidth);
const button = document.createElement("a");
button.id = buttonId;
button.href = `${details.TopmateService}`;
button.textContent = "1:1 Mentorship";
button.style.position = "fixed";
button.style.right = "30px";
button.style.bottom = "30px";
button.style.backgroundColor = "#000";
button.style.color = "#fff";
button.style.padding = "10px 20px";
button.style.borderRadius = "5px";
button.style.zIndex = "1000";

document.body.appendChild(script);
return () => {
if(script)
document.body.removeChild(script);
};

document.body.appendChild(button);
}
}
}, [details.TopmateService, router.query]);

return () => {
const existingButton = document.getElementById(buttonId);
if (existingButton) {
document.body.removeChild(existingButton);
}
};
}, [details.TopmateService, member]);

if (!member) {
return (
<div className="flex flex-col items-center justify-center min-h-72 p-4 dark:text-white">
Expand Down
2 changes: 2 additions & 0 deletions public/team_member_data/member_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@
"GitHub": " https://github.com/Meetjain1",
"Twitter": "https://twitter.com/Meetjain_100",
"LinkedIn": "https://linkedin.com/in/meet-jain-413015265/",
"Topmate": "https://topmate.io/meet_jain10",
"TopmateService": "https://topmate.io/meet_jain10/1209100/pay",
"Instagram": "https://www.instagram.com/m.jain_17/",
"Skills": ["Full-stack development", "CyberSecurity", "Blockchain development", "Problem Solving", "DSA"],
"Languages": ["C++", "JavaScript", "Python", "TypeScript", "MERN", "NextJS", "SvelteJS", "NestJS"],
Expand Down
Loading