Refactor manifest.json paths, enhance teams fetching logic, and improve results display handling
This commit is contained in:
parent
08d1f2cb63
commit
f0f4418cf0
@ -3,17 +3,17 @@
|
|||||||
"name": "Kings Admin Panel",
|
"name": "Kings Admin Panel",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "favicon.ico",
|
"src": "/favicon.ico",
|
||||||
"sizes": "64x64 32x32 24x24 16x16",
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
"type": "image/x-icon"
|
"type": "image/x-icon"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "logo192.png",
|
"src": "/logo192.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "192x192"
|
"sizes": "192x192"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "logo512.png",
|
"src": "/logo512.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "512x512"
|
"sizes": "512x512"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import 'react-toastify/dist/ReactToastify.css';
|
|||||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<BrowserRouter>
|
<BrowserRouter future={{ v7_relativeSplatPath: true }}>
|
||||||
<AuthProvider>
|
<AuthProvider>
|
||||||
<App />
|
<App />
|
||||||
<ToastContainer position="top-right" autoClose={3000} />
|
<ToastContainer position="top-right" autoClose={3000} />
|
||||||
|
|||||||
@ -35,9 +35,10 @@ const Results = () => {
|
|||||||
const fetchTeams = async () => {
|
const fetchTeams = async () => {
|
||||||
try {
|
try {
|
||||||
const data = await teamsService.getAll();
|
const data = await teamsService.getAll();
|
||||||
setTeams(data);
|
setTeams(Array.isArray(data) ? data : []); // Ensure teams is always an array
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching teams:', err);
|
console.error('Error fetching teams:', err);
|
||||||
|
setTeams([]); // Fallback to an empty array on error
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -236,46 +237,52 @@ const Results = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{results.map((result, index) => (
|
{results.length === 0 ? (
|
||||||
<tr key={result.id}>
|
<tr>
|
||||||
<td>{index + 1}</td>
|
<td colSpan="6" className="text-center">No results found with the current filter.</td>
|
||||||
<td>{result.team || result.team_name}</td>
|
|
||||||
<td>
|
|
||||||
{(result.visible_result === '-1' || result.result === '-1') ? (
|
|
||||||
<span className="text-muted">Pending</span>
|
|
||||||
) : (
|
|
||||||
<span className="text-success fw-bold">
|
|
||||||
{result.visible_result || result.result}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td>{formatDateTimeDisplay(result.result_time)}</td>
|
|
||||||
<td>
|
|
||||||
{new Date(result.result_time) > new Date() ? (
|
|
||||||
<span className="badge bg-warning">Scheduled</span>
|
|
||||||
) : (
|
|
||||||
<span className="badge bg-success">Published</span>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<Button
|
|
||||||
variant="outline-primary"
|
|
||||||
size="sm"
|
|
||||||
className="me-2"
|
|
||||||
onClick={() => handleOpenEditModal(result)}
|
|
||||||
>
|
|
||||||
<FiEdit />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="outline-danger"
|
|
||||||
size="sm"
|
|
||||||
onClick={() => handleOpenDeleteModal(result)}
|
|
||||||
>
|
|
||||||
<FiTrash2 />
|
|
||||||
</Button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
) : (
|
||||||
|
results.map((result, index) => (
|
||||||
|
<tr key={result.id}>
|
||||||
|
<td>{index + 1}</td>
|
||||||
|
<td>{result.team || result.team_name}</td>
|
||||||
|
<td>
|
||||||
|
{(result.visible_result === '-1' || result.result === '-1') ? (
|
||||||
|
<span className="text-muted">Pending</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-success fw-bold">
|
||||||
|
{result.visible_result || result.result}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td>{formatDateTimeDisplay(result.result_time)}</td>
|
||||||
|
<td>
|
||||||
|
{new Date(result.result_time) > new Date() ? (
|
||||||
|
<span className="badge bg-warning">Scheduled</span>
|
||||||
|
) : (
|
||||||
|
<span className="badge bg-success">Published</span>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Button
|
||||||
|
variant="outline-primary"
|
||||||
|
size="sm"
|
||||||
|
className="me-2"
|
||||||
|
onClick={() => handleOpenEditModal(result)}
|
||||||
|
>
|
||||||
|
<FiEdit />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outline-danger"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => handleOpenDeleteModal(result)}
|
||||||
|
>
|
||||||
|
<FiTrash2 />
|
||||||
|
</Button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</Table>
|
</Table>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -142,11 +142,11 @@ const Teams = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{teams.map((team, index) => (
|
{Array.isArray(teams) && teams.map((team, index) => (
|
||||||
<tr key={team.id}>
|
<tr key={team.id}>
|
||||||
<td>{index + 1}</td>
|
<td>{index + 1}</td>
|
||||||
<td>{team.name}</td>
|
<td>{team.name}</td>
|
||||||
<td>{new Date(team.created_at).toLocaleString('en-IN', {timeZone: 'Asia/Kolkata'})}</td>
|
<td>{new Date(team.created_at).toLocaleString('en-IN', { timeZone: 'Asia/Kolkata' })}</td>
|
||||||
<td>
|
<td>
|
||||||
<Button
|
<Button
|
||||||
variant="outline-primary"
|
variant="outline-primary"
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const API_URL = process.env.REACT_APP_API_URL;
|
// const API_URL = process.env.REACT_APP_API_URL;
|
||||||
const TOKEN_KEY = process.env.REACT_APP_TOKEN_KEY;
|
const TOKEN_KEY = process.env.REACT_APP_TOKEN_KEY;
|
||||||
|
|
||||||
|
const API_URL = 'https://backend.matkasattadaily.com'
|
||||||
|
|
||||||
const http = axios.create({
|
const http = axios.create({
|
||||||
baseURL: API_URL,
|
baseURL: API_URL,
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user