MCPcopy Create free account
hub / github.com/Bitbox-Connect/Bitbox / MyProfile

Function MyProfile

client/src/component/MyProject.jsx:26–585  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

24
25
26const MyProfile = (props) => {
27 const { mode } = props;
28 const [showVideo, setShowVideo] = useState(false);
29
30 const handleVideoClose = () => {
31 setShowVideo(false);
32 };
33
34 // Context for Projects
35 const userProjectContext = useContext(projectContext)
36 const { userProjects, getUserProjects, editProject } = userProjectContext;
37
38 let navigate = useNavigate();
39 useEffect(() => {
40 // Check if user is authenticated, if not, navigate to login page
41 if (localStorage.getItem('token')) {
42 getUserProjects();
43 }
44 else {
45 navigate('/login')
46 }
47 // eslint-disable-next-line
48 }, [])
49
50 const refEdit = useRef(null)
51 const refClose = useRef(null)
52
53 const [project, setproject] = useState({ id: "", etitle: "", edescription: "", egitHubLink: "", eyouTubeLink: "" });
54 const updateProject = (currentProject) => {
55 refEdit.current.click();
56 // Set the title, description and link to edit modal
57 setproject({ id: currentProject._id, etitle: currentProject.title, edescription: currentProject.description, egitHubLink: currentProject.gitHubLink, eyouTubeLink: currentProject.youTubeLink })
58 }
59
60 const handleClick = () => {
61 // Modify YouTube link
62 const modifiedYouTubeLink = modifyYouTubeLink(project.eyouTubeLink);
63 // Update project using API call
64 editProject(project.id, project.etitle, project.edescription, project.egitHubLink, modifiedYouTubeLink) // Pass modifiedYouTubeLink instead of project.youTubeLink
65 refClose.current.click();
66 props.showAlert("Project Updated Successfully", "success")
67 }
68
69 const refDetails = useRef(null)
70
71 const showDetailProject = (currentProject) => {
72 refDetails.current.click();
73 // Set the title, description and link to edit modal
74 setproject({ id: currentProject._id, etitle: currentProject.title, edescription: currentProject.description, egitHubLink: currentProject.gitHubLink, eyouTubeLink: currentProject.youTubeLink })
75 }
76
77 const onChange = (e) => {
78 // Update project state when input value changes
79 setproject({ ...project, [e.target.name]: e.target.value });
80 }
81
82 // Profile Context
83 const userProfileContext = useContext(profileContext);

Callers

nothing calls this directly

Calls 3

getUserProjectsFunction · 0.85
getUserProfileFunction · 0.85
formatDateFunction · 0.70

Tested by

no test coverage detected