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

Function Community

client/src/component/Community.jsx:20–954  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

18import "../css/Community.css";
19
20const Community = (props) => {
21 const [loading, setLoading] = useState(true); // State to track loading
22 const [project, setProject] = useState({
23 id: "",
24 etitle: "",
25 edescription: "",
26 egitHubLink: "",
27 eyouTubeLink: "",
28 });
29 const [showVideo, setShowVideo] = useState(false);
30 const refDetails = useRef(null);
31 const ref = useRef(null);
32 const context = useContext(projectContext);
33 const { globalProjects, getGlobalProjects } = context;
34 const userProfileContext = useContext(profileContext);
35 // eslint-disable-next-line
36 const { userProfile, getUserProfile } = userProfileContext;
37 // eslint-disable-next-line
38 const [image, setImage] = useState();
39
40 // Fetch projects on component mount
41 useEffect(() => {
42 const fetchData = async () => {
43 setLoading(true); // Set loading to true before fetching
44 await getGlobalProjects();
45 setLoading(false); // Set loading to false after data is fetched
46 };
47 fetchData();
48 // eslint-disable-next-line
49 }, []);
50
51 useEffect(() => {
52 if (localStorage.getItem("token")) {
53 getUserProfile();
54 }
55 // eslint-disable-next-line
56 }, []);
57
58 const showDetailProject = (currentProject) => {
59 refDetails.current.click();
60 setProject({
61 id: currentProject._id,
62 etitle: currentProject.title,
63 edescription: currentProject.description,
64 egitHubLink: currentProject.gitHubLink,
65 eyouTubeLink: currentProject.youTubeLink,
66 });
67 };
68
69 const handleVideoClose = () => {
70 setShowVideo(false);
71 };
72
73 // Function to format date
74 const formatDate = (dateString) => {
75 const date = new Date(dateString);
76 const year = date.getFullYear().toString().slice(-2);
77 const month = ("0" + (date.getMonth() + 1)).slice(-2);

Callers

nothing calls this directly

Calls 3

getUserProfileFunction · 0.85
fetchDataFunction · 0.70
formatDateFunction · 0.70

Tested by

no test coverage detected