From f0f4418cf0d931d788d12cd280cc16c99f16fee0 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Date: Tue, 22 Apr 2025 12:30:15 +0530 Subject: [PATCH] Refactor manifest.json paths, enhance teams fetching logic, and improve results display handling --- public/manifest.json | 6 +-- src/index.js | 2 +- src/pages/Results.js | 87 ++++++++++++++++++++++++-------------------- src/pages/Teams.js | 4 +- src/utils/http.js | 4 +- 5 files changed, 56 insertions(+), 47 deletions(-) diff --git a/public/manifest.json b/public/manifest.json index c5fc123..aaf50b1 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -3,17 +3,17 @@ "name": "Kings Admin Panel", "icons": [ { - "src": "favicon.ico", + "src": "/favicon.ico", "sizes": "64x64 32x32 24x24 16x16", "type": "image/x-icon" }, { - "src": "logo192.png", + "src": "/logo192.png", "type": "image/png", "sizes": "192x192" }, { - "src": "logo512.png", + "src": "/logo512.png", "type": "image/png", "sizes": "512x512" } diff --git a/src/index.js b/src/index.js index 9429752..ef56ab4 100644 --- a/src/index.js +++ b/src/index.js @@ -11,7 +11,7 @@ import 'react-toastify/dist/ReactToastify.css'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - + diff --git a/src/pages/Results.js b/src/pages/Results.js index 4f1c492..ef52ba3 100644 --- a/src/pages/Results.js +++ b/src/pages/Results.js @@ -35,9 +35,10 @@ const Results = () => { const fetchTeams = async () => { try { const data = await teamsService.getAll(); - setTeams(data); + setTeams(Array.isArray(data) ? data : []); // Ensure teams is always an array } catch (err) { console.error('Error fetching teams:', err); + setTeams([]); // Fallback to an empty array on error } }; @@ -236,46 +237,52 @@ const Results = () => { - {results.map((result, index) => ( - - {index + 1} - {result.team || result.team_name} - - {(result.visible_result === '-1' || result.result === '-1') ? ( - Pending - ) : ( - - {result.visible_result || result.result} - - )} - - {formatDateTimeDisplay(result.result_time)} - - {new Date(result.result_time) > new Date() ? ( - Scheduled - ) : ( - Published - )} - - - - - + {results.length === 0 ? ( + + No results found with the current filter. - ))} + ) : ( + results.map((result, index) => ( + + {index + 1} + {result.team || result.team_name} + + {(result.visible_result === '-1' || result.result === '-1') ? ( + Pending + ) : ( + + {result.visible_result || result.result} + + )} + + {formatDateTimeDisplay(result.result_time)} + + {new Date(result.result_time) > new Date() ? ( + Scheduled + ) : ( + Published + )} + + + + + + + )) + )} )} diff --git a/src/pages/Teams.js b/src/pages/Teams.js index 8ec1087..08db554 100644 --- a/src/pages/Teams.js +++ b/src/pages/Teams.js @@ -142,11 +142,11 @@ const Teams = () => { - {teams.map((team, index) => ( + {Array.isArray(teams) && teams.map((team, index) => ( {index + 1} {team.name} - {new Date(team.created_at).toLocaleString('en-IN', {timeZone: 'Asia/Kolkata'})} + {new Date(team.created_at).toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' })}