DebasishDhal99 commited on
Commit
fc5c224
·
1 Parent(s): 825a801

Remove wiki rendering within map marker, refactoring the endpoint selection

Browse files
Files changed (1) hide show
  1. frontend/src/components/Map.js +15 -3
frontend/src/components/Map.js CHANGED
@@ -86,9 +86,19 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
86
 
87
  const fetchWiki = useCallback(async (pageName) => {
88
  try{
89
- const endpoint = contentType === 'summary'
90
- ? `${BACKEND_URL}/wiki/${pageName}`
91
- : `${BACKEND_URL}/wiki/search/${pageName}`;
 
 
 
 
 
 
 
 
 
 
92
 
93
  const res = await fetch(endpoint);
94
  const data = await res.json();
@@ -233,6 +243,7 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
233
  />
234
  <ClickHandler onMapClick={onMapClick}/>
235
  <Marker position={markerPosition}>
 
236
  <Popup minWidth={250}>
237
  {wikiContent ? (
238
  <>
@@ -243,6 +254,7 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
243
  "Search for a location to see information"
244
  )}
245
  </Popup>
 
246
  </Marker>
247
  </MapContainer>
248
  {panelSize === 'closed' && (
 
86
 
87
  const fetchWiki = useCallback(async (pageName) => {
88
  try{
89
+ let endpoint;
90
+ if (contentType === 'summary') {
91
+ endpoint = `${BACKEND_URL}/wiki/${pageName}`;
92
+ }
93
+ else if (contentType === 'full') {
94
+ endpoint = `${BACKEND_URL}/wiki/search/${pageName}`;
95
+ }
96
+
97
+ else {
98
+ console.log("Invalid content type:", contentType);
99
+ setWikiContent(null);
100
+ return;
101
+ }
102
 
103
  const res = await fetch(endpoint);
104
  const data = await res.json();
 
243
  />
244
  <ClickHandler onMapClick={onMapClick}/>
245
  <Marker position={markerPosition}>
246
+ {contentType === 'summary' && (
247
  <Popup minWidth={250}>
248
  {wikiContent ? (
249
  <>
 
254
  "Search for a location to see information"
255
  )}
256
  </Popup>
257
+ )}
258
  </Marker>
259
  </MapContainer>
260
  {panelSize === 'closed' && (