Skip to content

Commit 28b12ba

Browse files
authored
Merge pull request #965 from Code4GovTech/dev
API call Fixes
2 parents 8329528 + ad1c63c commit 28b12ba

File tree

6 files changed

+127
-179
lines changed

6 files changed

+127
-179
lines changed

docusaurus.config.js

+35-35
Original file line numberDiff line numberDiff line change
@@ -229,143 +229,143 @@ module.exports = {
229229
items: [
230230
{
231231
label: "A2I Bangladesh",
232-
to: "/docs/2024/org?id=A2I%20Bangladesh",
232+
to: "/docs/2024?id=A2I%20Bangladesh",
233233
},
234234
{
235235
label: "ABDM Enablers",
236-
to: "/docs/2024/org?id=ABDM%20Enablers",
236+
to: "/docs/2024?id=ABDM%20Enablers",
237237
},
238238
{
239239
label: "Arghyam",
240-
to: "/docs/2024/org?id=Arghyam",
240+
to: "/docs/2024?id=Arghyam",
241241
},
242242
{
243243
label: "Avanti Fellows",
244-
to: "/docs/2024/org?id=Avanti%20Fellows",
244+
to: "/docs/2024?id=Avanti%20Fellows",
245245
},
246246
{
247247
label: "Beckn Open Collective",
248-
to: "/docs/2024/org?id=Beckn%20Open%20Collective",
248+
to: "/docs/2024?id=Beckn%20Open%20Collective",
249249
},
250250
{
251251
label: "Belongg",
252-
to: "/docs/2024/org?id=Belongg",
252+
to: "/docs/2024?id=Belongg",
253253
},
254254
{
255255
label: "Bhashini",
256-
to: "/docs/2024/org?id=Bhashini",
256+
to: "/docs/2024?id=Bhashini",
257257
},
258258
{
259259
label: "Blockster Labs/ CREDEBL",
260-
to: "/docs/2024/org?id=Blockster%20Labs/%20CREDEBL",
260+
to: "/docs/2024?id=Blockster%20Labs/%20CREDEBL",
261261
},
262262
{
263263
label: "ConveGenius AI",
264-
to: "/docs/2024/org?id=ConveGenius%20AI",
264+
to: "/docs/2024?id=ConveGenius%20AI",
265265
},
266266
{
267267
label: "Dhiway",
268-
to: "/docs/2024/org?id=Dhiway",
268+
to: "/docs/2024?id=Dhiway",
269269
},
270270
{
271271
label: "eGovernments Foundation",
272-
to: "/docs/2024/org?id=eGovernments%20Foundation",
272+
to: "/docs/2024?id=eGovernments%20Foundation",
273273
},
274274
{
275275
label: "EkStep Foundation",
276-
to: "/docs/2024/org?id=EkStep%20Foundation",
276+
to: "/docs/2024?id=EkStep%20Foundation",
277277
},
278278
{
279279
label: "Haqdarshak",
280-
to: "/docs/2024/org?id=Haqdarshak",
280+
to: "/docs/2024?id=Haqdarshak",
281281
},
282282
{
283283
label: "IDinsight",
284-
to: "/docs/2024/org?id=IDinsight",
284+
to: "/docs/2024?id=IDinsight",
285285
},
286286
{
287287
label: "MeitY",
288-
to: "/docs/2024/org?id=MeitY",
288+
to: "/docs/2024?id=MeitY",
289289
},
290290
{
291291
label: "Mojaloop",
292-
to: "/docs/2024/org?id=Mojaloop",
292+
to: "/docs/2024?id=Mojaloop",
293293
},
294294
{
295295
label: "NSUT in collaboration with C4GT, SEETA, AIC",
296-
to: "/docs/2024/org?id=NSUT%20in%20collaboration%20with%20C4GT,%20SEETA,%20AIC",
296+
to: "/docs/2024?id=NSUT%20in%20collaboration%20with%20C4GT,%20SEETA,%20AIC",
297297
},
298298
{
299299
label: "Open Function Group",
300-
to: "/docs/2024/org?id=Open%20Function%20Group",
300+
to: "/docs/2024?id=Open%20Function%20Group",
301301
},
302302
{
303303
label: "Piramal Swasthya Management Research",
304-
to: "/docs/2024/org?id=Piramal%20Swasthya%20Management%20Research",
304+
to: "/docs/2024?id=Piramal%20Swasthya%20Management%20Research",
305305
},
306306
{
307307
label: "Planet Read",
308-
to: "/docs/2024/org?id=Planet%20Read",
308+
to: "/docs/2024?id=Planet%20Read",
309309
},
310310
{
311311
label: "PolicyEngine",
312-
to: "/docs/2024/org?id=PolicyEngine",
312+
to: "/docs/2024?id=PolicyEngine",
313313
},
314314
{
315315
label: "Project Tech4Dev",
316-
to: "/docs/2024/org?id=Project%20Tech4Dev",
316+
to: "/docs/2024?id=Project%20Tech4Dev",
317317
},
318318
{
319319
label: "Protean",
320-
to: "/docs/2024/org?id=Protean",
320+
to: "/docs/2024?id=Protean",
321321
},
322322
{
323323
label: "Reap Benefit",
324-
to: "/docs/2024/org?id=Reap%20Benefit",
324+
to: "/docs/2024?id=Reap%20Benefit",
325325
},
326326
{
327327
label: "SamagraX",
328-
to: "/docs/2024/org?id=SamagraX",
328+
to: "/docs/2024?id=SamagraX",
329329
},
330330
{
331331
label: "Samanway Foundation",
332-
to: "/docs/2024/org?id=Samanway%20Foundation",
332+
to: "/docs/2024?id=Samanway%20Foundation",
333333
},
334334
{
335335
label: "Shikshalokam",
336-
to: "/docs/2024/org?id=Shikshalokam",
336+
to: "/docs/2024?id=Shikshalokam",
337337
},
338338
{
339339
label: "Sugar Labs",
340-
to: "/docs/2024/org?id=Sugar%20Labs",
340+
to: "/docs/2024?id=Sugar%20Labs",
341341
},
342342
{
343343
label: "Swasth Alliance",
344-
to: "/docs/2024/org?id=Swasth%20Alliance",
344+
to: "/docs/2024?id=Swasth%20Alliance",
345345
},
346346
{
347347
label: "Tattle",
348-
to: "/docs/2024/org?id=Tattle",
348+
to: "/docs/2024?id=Tattle",
349349
},
350350
{
351351
label: "Tekdi",
352-
to: "/docs/2024/org?id=Tekdi",
352+
to: "/docs/2024?id=Tekdi",
353353
},
354354
{
355355
label: "The Mifos Initiative",
356-
to: "/docs/2024/org?id=The%20Mifos%20Initiative",
356+
to: "/docs/2024?id=The%20Mifos%20Initiative",
357357
},
358358
{
359359
label: "Unicef",
360-
to: "/docs/2024/org?id=Unicef",
360+
to: "/docs/2024?id=Unicef",
361361
},
362362
{
363363
label: "Zendalona",
364-
to: "/docs/2024/org?id=Zendalona",
364+
to: "/docs/2024?id=Zendalona",
365365
},
366366
{
367367
label: "Zenysis Technologies",
368-
to: "/docs/2024/org?id=Zenysis%20Technologies",
368+
to: "/docs/2024?id=Zenysis%20Technologies",
369369
},
370370
]
371371
}

src/components/IssueDescription.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function IssueDescription({ currentOrg, currentIssue }) {
5858
<li className="breadcrumbs__item">
5959
<a
6060
className="breadcrumbs__link breadcrumbs-items"
61-
href={`/docs/2024/org?id=${currentOrg}`}
61+
href={`/docs/2024?id=${currentOrg}`}
6262
>
6363
{currentOrg}
6464
</a>

src/components/OrgDescription.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function OrgDescription({ currentOrg, currentOrgData }) {
103103
<a
104104
className="cursor-pointer"
105105
onClick={() => {
106-
const newUrl = `/docs/2024/org?id=${currentOrg}&issue=${d.id}`;
106+
const newUrl = `/docs/2024?id=${currentOrg}&issue=${d.id}`;
107107
history.push(newUrl);
108108
}}
109109
>

src/components/Sidebar.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function Sidebar({
88
setCurrentOrg,
99
currentIssue,
1010
setCurrentIssue,
11+
setCurrentTab
1112
}) {
1213
const history = useHistory();
1314
return (
@@ -18,7 +19,9 @@ function Sidebar({
1819
<div
1920
className={`menu__link cursor-pointer ${currentTab == "c4gt" ? "menu__link--active" : ""}`}
2021
onClick={() => {
21-
window.location.href = `/docs/2024/`;
22+
const newUrl = `/docs/2024/`;
23+
history.push(newUrl);
24+
setCurrentTab("c4gt")
2225
}}
2326
>
2427
C4GT'24
@@ -36,7 +39,7 @@ function Sidebar({
3639
<div
3740
className={`menu__list-item-collapsible cursor-pointer ${currentOrg == data?.org_name && currentIssue == null ? "menu__list-item-collapsible--active" : ""}`}
3841
onClick={() => {
39-
const newUrl = `/docs/2024/org?id=${data?.org_name}`;
42+
const newUrl = `/docs/2024?id=${data?.org_name}`;
4043
history.push(newUrl);
4144
setCurrentOrg(() => data?.org_name);
4245
setCurrentIssue(() => null);
@@ -74,7 +77,7 @@ function Sidebar({
7477
<div
7578
className={`menu__link cursor-pointer ${currentIssue == d.id ? "menu__link--active" : ""}`}
7679
onClick={() => {
77-
const newUrl = `/docs/2024/org?id=${currentOrg}&issue=${d.id}`;
80+
const newUrl = `/docs/2024?id=${currentOrg}&issue=${d.id}`;
7881
history.push(newUrl);
7982
setCurrentIssue(() => d.id);
8083
}}

src/pages/docs/2024/index.js

+84-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
import React, { useEffect, useState } from "react";
22
import Layout from "@theme/Layout";
33
import "./index.css";
4+
import { useHistory, useLocation } from "react-router-dom";
45
import useParseMarkdown from "../../../hooks/useParseMarkdown";
56
import ErrorComponent from "../../../components/ErrorComponent";
67
import Sidebar from "../../../components/Sidebar";
78
import C4GT2024Description from "../../../components/C4gt2024Description";
9+
import OrgDescription from "../../../components/OrgDescription";
10+
import IssueDescription from "../../../components/IssueDescription";
811

912
function C4GT2024() {
13+
const location = useLocation();
14+
const history = useHistory();
1015
const { API_AUTH_KEY, API_BASE_URL } = useParseMarkdown();
11-
const [issueData, setIssueData] = useState(null);
12-
const [error, setError] = useState(null);
1316
const [currentOrg, setCurrentOrg] = useState(null);
1417
const [currentIssue, setCurrentIssue] = useState(null);
18+
const [issueData, setIssueData] = useState(null);
19+
const [currentOrgData, setCurrentOrgData] = useState(null);
20+
const [currentTab,setCurrentTab] = useState(null)
21+
const [error, setError] = useState(null);
1522

1623
useEffect(() => {
1724
setError(() => null);
25+
const queryString = location.search;
26+
const urlParams = new URLSearchParams(queryString);
27+
const ifOrg = urlParams.get("id") ? urlParams.get("id") : null;
28+
const ifIssue = urlParams.get("issue") ? urlParams.get("issue") : null;
29+
const newUrl = ifIssue
30+
? `/docs/2024?id=${ifOrg}&issue=${ifIssue}`
31+
: ifOrg
32+
? `/docs/2024?id=${ifOrg}`
33+
: "/docs/2024/";
34+
history.push(newUrl);
35+
if (ifIssue) setCurrentIssue(() => ifIssue);
36+
else setCurrentIssue(null);
37+
if (ifOrg) {setCurrentOrg(() => ifOrg);
38+
setCurrentTab("org")
39+
}
40+
else {setCurrentOrg(null);
41+
setCurrentTab("c4gt")
42+
}
1843
fetch(`${API_BASE_URL}/issues`, {
1944
method: "GET",
2045
headers: {
@@ -29,13 +54,49 @@ function C4GT2024() {
2954
throw new Error(`${data?.message}`);
3055
} else if (data?.error) {
3156
throw new Error(`${data?.error}`);
32-
} else setIssueData(() => data?.issues);
57+
} else {
58+
let issues = data?.issues;
59+
setIssueData(() => issues);
60+
if (ifOrg) {
61+
setCurrentOrgData(() => {
62+
let issue_data = issues?.filter((d, i) => {
63+
if (d.org_name == ifOrg) return d.issues;
64+
else return;
65+
});
66+
return issue_data;
67+
});
68+
} else setCurrentOrgData(null);
69+
}
3370
})
3471
.catch((error) => {
3572
setError(() => error);
3673
});
3774
}, []);
3875

76+
useEffect(() => {
77+
const queryString = location.search;
78+
const urlParams = new URLSearchParams(queryString);
79+
const ifOrg = urlParams.get("id") ? urlParams.get("id") : null;
80+
const ifIssue = urlParams.get("issue") ? urlParams.get("issue") : null;
81+
if (ifIssue) setCurrentIssue(() => ifIssue);
82+
else setCurrentIssue(null);
83+
if (ifOrg) {
84+
setCurrentOrg(() => ifOrg);
85+
setCurrentOrgData(() => {
86+
let data = issueData?.filter((d, i) => {
87+
if (d.org_name == ifOrg) return d.issues;
88+
else return;
89+
});
90+
return data;
91+
});
92+
setCurrentTab("org")
93+
} else {
94+
setCurrentOrg(null);
95+
setCurrentOrgData(null);
96+
setCurrentTab("c4gt")
97+
}
98+
}, [location]);
99+
39100
return (
40101
<>
41102
{error ? (
@@ -47,15 +108,34 @@ function C4GT2024() {
47108
<aside className="theme-doc-sidebar-container sidebar-container-2024">
48109
<Sidebar
49110
issueData={issueData}
50-
currentTab={"c4gt"}
111+
currentTab={currentTab}
51112
currentOrg={currentOrg}
52113
currentIssue={currentIssue}
53114
setCurrentIssue={setCurrentIssue}
54115
setCurrentOrg={setCurrentOrg}
116+
setCurrentTab={setCurrentTab}
55117
/>
56118
</aside>
57119
<main className="main-container">
120+
{currentTab==="c4gt" ? (
58121
<C4GT2024Description />
122+
) : currentIssue != null ? (
123+
<IssueDescription
124+
currentOrg={currentOrg}
125+
currentIssue={currentIssue}
126+
/>
127+
) : currentOrg != null ? (
128+
<OrgDescription
129+
currentIssue={currentIssue}
130+
setCurrentIssue={setCurrentIssue}
131+
currentOrg={currentOrg}
132+
issueData={issueData}
133+
currentOrgData={currentOrgData}
134+
/>
135+
) : (
136+
<></>
137+
)}
138+
59139
</main>
60140
</div>
61141
</div>

0 commit comments

Comments
 (0)