diff --git a/docusaurus.config.js b/docusaurus.config.js index 5b5fe432e..73c7e54fc 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -229,143 +229,143 @@ module.exports = { items: [ { label: "A2I Bangladesh", - to: "/docs/2024/org?id=A2I%20Bangladesh", + to: "/docs/2024?id=A2I%20Bangladesh", }, { label: "ABDM Enablers", - to: "/docs/2024/org?id=ABDM%20Enablers", + to: "/docs/2024?id=ABDM%20Enablers", }, { label: "Arghyam", - to: "/docs/2024/org?id=Arghyam", + to: "/docs/2024?id=Arghyam", }, { label: "Avanti Fellows", - to: "/docs/2024/org?id=Avanti%20Fellows", + to: "/docs/2024?id=Avanti%20Fellows", }, { label: "Beckn Open Collective", - to: "/docs/2024/org?id=Beckn%20Open%20Collective", + to: "/docs/2024?id=Beckn%20Open%20Collective", }, { label: "Belongg", - to: "/docs/2024/org?id=Belongg", + to: "/docs/2024?id=Belongg", }, { label: "Bhashini", - to: "/docs/2024/org?id=Bhashini", + to: "/docs/2024?id=Bhashini", }, { label: "Blockster Labs/ CREDEBL", - to: "/docs/2024/org?id=Blockster%20Labs/%20CREDEBL", + to: "/docs/2024?id=Blockster%20Labs/%20CREDEBL", }, { label: "ConveGenius AI", - to: "/docs/2024/org?id=ConveGenius%20AI", + to: "/docs/2024?id=ConveGenius%20AI", }, { label: "Dhiway", - to: "/docs/2024/org?id=Dhiway", + to: "/docs/2024?id=Dhiway", }, { label: "eGovernments Foundation", - to: "/docs/2024/org?id=eGovernments%20Foundation", + to: "/docs/2024?id=eGovernments%20Foundation", }, { label: "EkStep Foundation", - to: "/docs/2024/org?id=EkStep%20Foundation", + to: "/docs/2024?id=EkStep%20Foundation", }, { label: "Haqdarshak", - to: "/docs/2024/org?id=Haqdarshak", + to: "/docs/2024?id=Haqdarshak", }, { label: "IDinsight", - to: "/docs/2024/org?id=IDinsight", + to: "/docs/2024?id=IDinsight", }, { label: "MeitY", - to: "/docs/2024/org?id=MeitY", + to: "/docs/2024?id=MeitY", }, { label: "Mojaloop", - to: "/docs/2024/org?id=Mojaloop", + to: "/docs/2024?id=Mojaloop", }, { label: "NSUT in collaboration with C4GT, SEETA, AIC", - to: "/docs/2024/org?id=NSUT%20in%20collaboration%20with%20C4GT,%20SEETA,%20AIC", + to: "/docs/2024?id=NSUT%20in%20collaboration%20with%20C4GT,%20SEETA,%20AIC", }, { label: "Open Function Group", - to: "/docs/2024/org?id=Open%20Function%20Group", + to: "/docs/2024?id=Open%20Function%20Group", }, { label: "Piramal Swasthya Management Research", - to: "/docs/2024/org?id=Piramal%20Swasthya%20Management%20Research", + to: "/docs/2024?id=Piramal%20Swasthya%20Management%20Research", }, { label: "Planet Read", - to: "/docs/2024/org?id=Planet%20Read", + to: "/docs/2024?id=Planet%20Read", }, { label: "PolicyEngine", - to: "/docs/2024/org?id=PolicyEngine", + to: "/docs/2024?id=PolicyEngine", }, { label: "Project Tech4Dev", - to: "/docs/2024/org?id=Project%20Tech4Dev", + to: "/docs/2024?id=Project%20Tech4Dev", }, { label: "Protean", - to: "/docs/2024/org?id=Protean", + to: "/docs/2024?id=Protean", }, { label: "Reap Benefit", - to: "/docs/2024/org?id=Reap%20Benefit", + to: "/docs/2024?id=Reap%20Benefit", }, { label: "SamagraX", - to: "/docs/2024/org?id=SamagraX", + to: "/docs/2024?id=SamagraX", }, { label: "Samanway Foundation", - to: "/docs/2024/org?id=Samanway%20Foundation", + to: "/docs/2024?id=Samanway%20Foundation", }, { label: "Shikshalokam", - to: "/docs/2024/org?id=Shikshalokam", + to: "/docs/2024?id=Shikshalokam", }, { label: "Sugar Labs", - to: "/docs/2024/org?id=Sugar%20Labs", + to: "/docs/2024?id=Sugar%20Labs", }, { label: "Swasth Alliance", - to: "/docs/2024/org?id=Swasth%20Alliance", + to: "/docs/2024?id=Swasth%20Alliance", }, { label: "Tattle", - to: "/docs/2024/org?id=Tattle", + to: "/docs/2024?id=Tattle", }, { label: "Tekdi", - to: "/docs/2024/org?id=Tekdi", + to: "/docs/2024?id=Tekdi", }, { label: "The Mifos Initiative", - to: "/docs/2024/org?id=The%20Mifos%20Initiative", + to: "/docs/2024?id=The%20Mifos%20Initiative", }, { label: "Unicef", - to: "/docs/2024/org?id=Unicef", + to: "/docs/2024?id=Unicef", }, { label: "Zendalona", - to: "/docs/2024/org?id=Zendalona", + to: "/docs/2024?id=Zendalona", }, { label: "Zenysis Technologies", - to: "/docs/2024/org?id=Zenysis%20Technologies", + to: "/docs/2024?id=Zenysis%20Technologies", }, ] } diff --git a/src/components/IssueDescription.js b/src/components/IssueDescription.js index e349d2ec5..e502fbd13 100644 --- a/src/components/IssueDescription.js +++ b/src/components/IssueDescription.js @@ -58,7 +58,7 @@ function IssueDescription({ currentOrg, currentIssue }) {
  • {currentOrg} diff --git a/src/components/OrgDescription.js b/src/components/OrgDescription.js index d13d9aba5..bf2ab485f 100644 --- a/src/components/OrgDescription.js +++ b/src/components/OrgDescription.js @@ -103,7 +103,7 @@ function OrgDescription({ currentOrg, currentOrgData }) { { - const newUrl = `/docs/2024/org?id=${currentOrg}&issue=${d.id}`; + const newUrl = `/docs/2024?id=${currentOrg}&issue=${d.id}`; history.push(newUrl); }} > diff --git a/src/components/Sidebar.js b/src/components/Sidebar.js index 414d0f334..4aef1c984 100644 --- a/src/components/Sidebar.js +++ b/src/components/Sidebar.js @@ -8,6 +8,7 @@ function Sidebar({ setCurrentOrg, currentIssue, setCurrentIssue, + setCurrentTab }) { const history = useHistory(); return ( @@ -18,7 +19,9 @@ function Sidebar({
    { - window.location.href = `/docs/2024/`; + const newUrl = `/docs/2024/`; + history.push(newUrl); + setCurrentTab("c4gt") }} > C4GT'24 @@ -36,7 +39,7 @@ function Sidebar({
    { - const newUrl = `/docs/2024/org?id=${data?.org_name}`; + const newUrl = `/docs/2024?id=${data?.org_name}`; history.push(newUrl); setCurrentOrg(() => data?.org_name); setCurrentIssue(() => null); @@ -74,7 +77,7 @@ function Sidebar({
    { - const newUrl = `/docs/2024/org?id=${currentOrg}&issue=${d.id}`; + const newUrl = `/docs/2024?id=${currentOrg}&issue=${d.id}`; history.push(newUrl); setCurrentIssue(() => d.id); }} diff --git a/src/pages/docs/2024/index.js b/src/pages/docs/2024/index.js index 0d454ee82..73171bbc1 100644 --- a/src/pages/docs/2024/index.js +++ b/src/pages/docs/2024/index.js @@ -1,20 +1,45 @@ import React, { useEffect, useState } from "react"; import Layout from "@theme/Layout"; import "./index.css"; +import { useHistory, useLocation } from "react-router-dom"; import useParseMarkdown from "../../../hooks/useParseMarkdown"; import ErrorComponent from "../../../components/ErrorComponent"; import Sidebar from "../../../components/Sidebar"; import C4GT2024Description from "../../../components/C4gt2024Description"; +import OrgDescription from "../../../components/OrgDescription"; +import IssueDescription from "../../../components/IssueDescription"; function C4GT2024() { + const location = useLocation(); + const history = useHistory(); const { API_AUTH_KEY, API_BASE_URL } = useParseMarkdown(); - const [issueData, setIssueData] = useState(null); - const [error, setError] = useState(null); const [currentOrg, setCurrentOrg] = useState(null); const [currentIssue, setCurrentIssue] = useState(null); + const [issueData, setIssueData] = useState(null); + const [currentOrgData, setCurrentOrgData] = useState(null); + const [currentTab,setCurrentTab] = useState(null) + const [error, setError] = useState(null); useEffect(() => { setError(() => null); + const queryString = location.search; + const urlParams = new URLSearchParams(queryString); + const ifOrg = urlParams.get("id") ? urlParams.get("id") : null; + const ifIssue = urlParams.get("issue") ? urlParams.get("issue") : null; + const newUrl = ifIssue + ? `/docs/2024?id=${ifOrg}&issue=${ifIssue}` + : ifOrg + ? `/docs/2024?id=${ifOrg}` + : "/docs/2024/"; + history.push(newUrl); + if (ifIssue) setCurrentIssue(() => ifIssue); + else setCurrentIssue(null); + if (ifOrg) {setCurrentOrg(() => ifOrg); + setCurrentTab("org") + } + else {setCurrentOrg(null); + setCurrentTab("c4gt") + } fetch(`${API_BASE_URL}/issues`, { method: "GET", headers: { @@ -29,13 +54,49 @@ function C4GT2024() { throw new Error(`${data?.message}`); } else if (data?.error) { throw new Error(`${data?.error}`); - } else setIssueData(() => data?.issues); + } else { + let issues = data?.issues; + setIssueData(() => issues); + if (ifOrg) { + setCurrentOrgData(() => { + let issue_data = issues?.filter((d, i) => { + if (d.org_name == ifOrg) return d.issues; + else return; + }); + return issue_data; + }); + } else setCurrentOrgData(null); + } }) .catch((error) => { setError(() => error); }); }, []); + useEffect(() => { + const queryString = location.search; + const urlParams = new URLSearchParams(queryString); + const ifOrg = urlParams.get("id") ? urlParams.get("id") : null; + const ifIssue = urlParams.get("issue") ? urlParams.get("issue") : null; + if (ifIssue) setCurrentIssue(() => ifIssue); + else setCurrentIssue(null); + if (ifOrg) { + setCurrentOrg(() => ifOrg); + setCurrentOrgData(() => { + let data = issueData?.filter((d, i) => { + if (d.org_name == ifOrg) return d.issues; + else return; + }); + return data; + }); + setCurrentTab("org") + } else { + setCurrentOrg(null); + setCurrentOrgData(null); + setCurrentTab("c4gt") + } + }, [location]); + return ( <> {error ? ( @@ -47,15 +108,34 @@ function C4GT2024() {
    + {currentTab==="c4gt" ? ( + ) : currentIssue != null ? ( + + ) : currentOrg != null ? ( + + ) : ( + <> + )} +
    diff --git a/src/pages/docs/2024/org/index.js b/src/pages/docs/2024/org/index.js deleted file mode 100644 index afa156388..000000000 --- a/src/pages/docs/2024/org/index.js +++ /dev/null @@ -1,135 +0,0 @@ -import React, { useEffect, useState } from "react"; -import Layout from "@theme/Layout"; -import "../index.css"; -import { useHistory, useLocation } from "react-router-dom"; -import useParseMarkdown from "../../../../hooks/useParseMarkdown"; -import ErrorComponent from "../../../../components/ErrorComponent"; -import Sidebar from "../../../../components/Sidebar"; -import OrgDescription from "../../../../components/OrgDescription"; -import IssueDescription from "../../../../components/IssueDescription"; - -function C4GT2024() { - const location = useLocation(); - const history = useHistory(); - const { API_AUTH_KEY, API_BASE_URL } = useParseMarkdown(); - const [currentOrg, setCurrentOrg] = useState(null); - const [currentIssue, setCurrentIssue] = useState(null); - const [issueData, setIssueData] = useState(null); - const [currentOrgData, setCurrentOrgData] = useState(null); - const [error, setError] = useState(null); - - useEffect(() => { - setError(() => null); - const queryString = location.search; - const urlParams = new URLSearchParams(queryString); - const ifOrg = urlParams.get("id") ? urlParams.get("id") : null; - const ifIssue = urlParams.get("issue") ? urlParams.get("issue") : null; - const newUrl = ifIssue - ? `/docs/2024/org?id=${ifOrg}&issue=${ifIssue}` - : ifOrg - ? `/docs/2024/org?id=${ifOrg}` - : "/docs/2024/"; - history.push(newUrl); - if (ifIssue) setCurrentIssue(() => ifIssue); - else setCurrentIssue(null); - if (ifOrg) setCurrentOrg(() => ifOrg); - else setCurrentOrg(null); - fetch(`${API_BASE_URL}/issues`, { - method: "GET", - headers: { - "X-Secret-Key": API_AUTH_KEY, - }, - }) - .then((response) => { - return response.json(); - }) - .then((data) => { - if (data?.message) { - throw new Error(`${data?.message}`); - } else if (data?.error) { - throw new Error(`${data?.error}`); - } else { - let issues = data?.issues; - setIssueData(() => issues); - if (ifOrg) { - setCurrentOrgData(() => { - let issue_data = issues?.filter((d, i) => { - if (d.org_name == ifOrg) return d.issues; - else return; - }); - return issue_data; - }); - } else setCurrentOrgData(null); - } - }) - .catch((error) => { - setError(() => error); - }); - }, []); - - useEffect(() => { - const queryString = location.search; - const urlParams = new URLSearchParams(queryString); - const ifOrg = urlParams.get("id") ? urlParams.get("id") : null; - const ifIssue = urlParams.get("issue") ? urlParams.get("issue") : null; - if (ifIssue) setCurrentIssue(() => ifIssue); - else setCurrentIssue(null); - if (ifOrg) { - setCurrentOrg(() => ifOrg); - setCurrentOrgData(() => { - let data = issueData?.filter((d, i) => { - if (d.org_name == ifOrg) return d.issues; - else return; - }); - return data; - }); - } else { - setCurrentOrg(null); - setCurrentOrgData(null); - } - }, [location]); - - return ( - <> - {error ? ( - - ) : ( - -
    -
    - -
    - {currentIssue != null ? ( - - ) : currentOrg != null ? ( - - ) : ( - <> - )} -
    -
    -
    -
    - )} - - ); -} -export default C4GT2024;