Skip to content

Commit

Permalink
Merge pull request #965 from Code4GovTech/dev
Browse files Browse the repository at this point in the history
API call Fixes
  • Loading branch information
karntrehan authored Jul 2, 2024
2 parents 8329528 + ad1c63c commit 28b12ba
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 179 deletions.
70 changes: 35 additions & 35 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/IssueDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function IssueDescription({ currentOrg, currentIssue }) {
<li className="breadcrumbs__item">
<a
className="breadcrumbs__link breadcrumbs-items"
href={`/docs/2024/org?id=${currentOrg}`}
href={`/docs/2024?id=${currentOrg}`}
>
{currentOrg}
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/components/OrgDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function OrgDescription({ currentOrg, currentOrgData }) {
<a
className="cursor-pointer"
onClick={() => {
const newUrl = `/docs/2024/org?id=${currentOrg}&issue=${d.id}`;
const newUrl = `/docs/2024?id=${currentOrg}&issue=${d.id}`;
history.push(newUrl);
}}
>
Expand Down
9 changes: 6 additions & 3 deletions src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function Sidebar({
setCurrentOrg,
currentIssue,
setCurrentIssue,
setCurrentTab
}) {
const history = useHistory();
return (
Expand All @@ -18,7 +19,9 @@ function Sidebar({
<div
className={`menu__link cursor-pointer ${currentTab == "c4gt" ? "menu__link--active" : ""}`}
onClick={() => {
window.location.href = `/docs/2024/`;
const newUrl = `/docs/2024/`;
history.push(newUrl);
setCurrentTab("c4gt")
}}
>
C4GT'24
Expand All @@ -36,7 +39,7 @@ function Sidebar({
<div
className={`menu__list-item-collapsible cursor-pointer ${currentOrg == data?.org_name && currentIssue == null ? "menu__list-item-collapsible--active" : ""}`}
onClick={() => {
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);
Expand Down Expand Up @@ -74,7 +77,7 @@ function Sidebar({
<div
className={`menu__link cursor-pointer ${currentIssue == d.id ? "menu__link--active" : ""}`}
onClick={() => {
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);
}}
Expand Down
88 changes: 84 additions & 4 deletions src/pages/docs/2024/index.js
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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 ? (
Expand All @@ -47,15 +108,34 @@ function C4GT2024() {
<aside className="theme-doc-sidebar-container sidebar-container-2024">
<Sidebar
issueData={issueData}
currentTab={"c4gt"}
currentTab={currentTab}
currentOrg={currentOrg}
currentIssue={currentIssue}
setCurrentIssue={setCurrentIssue}
setCurrentOrg={setCurrentOrg}
setCurrentTab={setCurrentTab}
/>
</aside>
<main className="main-container">
{currentTab==="c4gt" ? (
<C4GT2024Description />
) : currentIssue != null ? (
<IssueDescription
currentOrg={currentOrg}
currentIssue={currentIssue}
/>
) : currentOrg != null ? (
<OrgDescription
currentIssue={currentIssue}
setCurrentIssue={setCurrentIssue}
currentOrg={currentOrg}
issueData={issueData}
currentOrgData={currentOrgData}
/>
) : (
<></>
)}

</main>
</div>
</div>
Expand Down
Loading

0 comments on commit 28b12ba

Please sign in to comment.