time mismatch issue
This commit is contained in:
parent
d6a87928b8
commit
67a9ab2a45
22
src/App.js
22
src/App.js
@ -125,6 +125,8 @@ const apiService = {
|
|||||||
console.error("Server responded with error:", response.status, errorData);
|
console.error("Server responded with error:", response.status, errorData);
|
||||||
console.log("Sending exact payload:", JSON.stringify(resultData));
|
console.log("Sending exact payload:", JSON.stringify(resultData));
|
||||||
throw new Error(`Failed to publish result: ${response.status}`);
|
throw new Error(`Failed to publish result: ${response.status}`);
|
||||||
|
}else{
|
||||||
|
console.log("Response is ok")
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
@ -520,7 +522,7 @@ const ResultCalendar = () => {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Team</th>
|
<th>Team</th>
|
||||||
<th>Result</th>
|
<th>Result</th>
|
||||||
<th>Announcement Time</th>
|
<th>Result Time</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -528,8 +530,8 @@ const ResultCalendar = () => {
|
|||||||
{results.map(result => (
|
{results.map(result => (
|
||||||
<tr key={result.id}>
|
<tr key={result.id}>
|
||||||
<td>{result.team}</td>
|
<td>{result.team}</td>
|
||||||
<td>{result.result}</td>
|
<td>{result.visible_result}</td>
|
||||||
<td>{result.announcement_time}</td>
|
<td>{new Date(result.result_time).toISOString().split('T').join(" ").replace("Z", "").slice(0, -4)}</td>
|
||||||
<td>
|
<td>
|
||||||
<Link to={`/admin/results/edit/${result.id}?date=${date}`} className="btn-secondary">Edit</Link>
|
<Link to={`/admin/results/edit/${result.id}?date=${date}`} className="btn-secondary">Edit</Link>
|
||||||
<button
|
<button
|
||||||
@ -584,9 +586,8 @@ const ResultForm = ({ isEdit = false }) => {
|
|||||||
if (result) {
|
if (result) {
|
||||||
setFormData({
|
setFormData({
|
||||||
team: result.team_id.toString(),
|
team: result.team_id.toString(),
|
||||||
result: result.result,
|
result: result.visible_result,
|
||||||
date: result.result_date,
|
result_time: result.result_time
|
||||||
announcement_time: result.announcement_time
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,9 +611,8 @@ const ResultForm = ({ isEdit = false }) => {
|
|||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
team: formData.team, // This should be the team ID
|
team: formData.team, // This should be the team ID
|
||||||
date: formData.date,
|
|
||||||
result: formData.result,
|
result: formData.result,
|
||||||
announcement_time: formData.announcement_time
|
result_time: formData.date + " " + formData.result_time
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
@ -669,11 +669,11 @@ const ResultForm = ({ isEdit = false }) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Announcement Time</label>
|
<label>Result Time</label>
|
||||||
<input
|
<input
|
||||||
type="time"
|
type="time"
|
||||||
name="announcement_time"
|
name="result_time"
|
||||||
value={formData.announcement_time}
|
value={formData.result_time}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -388,7 +388,7 @@ const ResultCalendar = () => {
|
|||||||
{results.map(result => (
|
{results.map(result => (
|
||||||
<tr key={result.id}>
|
<tr key={result.id}>
|
||||||
<td>{result.team}</td>
|
<td>{result.team}</td>
|
||||||
<td>{result.result}</td>
|
<td>{result.visible_result}</td>
|
||||||
<td>
|
<td>
|
||||||
<Link to={`/results/edit/${result.id}?date=${date}`} className="btn-secondary">Edit</Link>
|
<Link to={`/results/edit/${result.id}?date=${date}`} className="btn-secondary">Edit</Link>
|
||||||
</td>
|
</td>
|
||||||
@ -439,7 +439,7 @@ const ResultForm = ({ isEdit = false }) => {
|
|||||||
console.log(result)
|
console.log(result)
|
||||||
setFormData({
|
setFormData({
|
||||||
team: result.team,
|
team: result.team,
|
||||||
result: result.result,
|
result: result.visible_result,
|
||||||
date: result.date
|
date: result.date
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,18 +59,19 @@ const Home = () => {
|
|||||||
results[yesterdayFormatted] = yesterdayResults[index].result;
|
results[yesterdayFormatted] = yesterdayResults[index].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add today's result if available
|
// Add today's result if available
|
||||||
const todayResult = todayResultsResponse.data.find(r => r.team === team.name);
|
const todayResult = todayResultsResponse.data.find(r => r.team === team.name);
|
||||||
if (todayResult) {
|
if (todayResult) {
|
||||||
results[todayFormatted] = todayResult.result;
|
console.log("test 1: " + todayResult.visible_result);
|
||||||
}
|
results[todayFormatted] = todayResult.visible_result;
|
||||||
|
}
|
||||||
|
|
||||||
// Extract time from team name or use default
|
// Extract time from today's result or use default
|
||||||
let time = "XX:XX";
|
let time = "XX:XX";
|
||||||
const timePart = team.name.match(/\d{2}:\d{2}\s*(?:AM|PM)/i);
|
if (todayResult && todayResult.result_time) {
|
||||||
if (timePart) {
|
const resultTime = new Date(todayResult.result_time);
|
||||||
time = timePart[0];
|
time = resultTime.toLocaleTimeString("en-US", { hour: '2-digit', minute: '2-digit', hour12: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: team.id,
|
id: team.id,
|
||||||
@ -187,7 +188,7 @@ const Home = () => {
|
|||||||
|
|
||||||
if (dayData && dayData.results.length > 0) {
|
if (dayData && dayData.results.length > 0) {
|
||||||
dayData.results.forEach(result => {
|
dayData.results.forEach(result => {
|
||||||
teamResults[result.team] = result.result;
|
teamResults[result.team] = result.visible_result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ const Home2 = () => {
|
|||||||
// Add today's result if available
|
// Add today's result if available
|
||||||
const todayResult = todayResultsResponse.data.find(r => r.team === team.name);
|
const todayResult = todayResultsResponse.data.find(r => r.team === team.name);
|
||||||
if (todayResult) {
|
if (todayResult) {
|
||||||
results[todayFormatted] = todayResult.result;
|
results[todayFormatted] = todayresult.visible_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract time from team name or use default
|
// Extract time from team name or use default
|
||||||
@ -187,7 +187,7 @@ const Home2 = () => {
|
|||||||
|
|
||||||
if (dayData && dayData.results.length > 0) {
|
if (dayData && dayData.results.length > 0) {
|
||||||
dayData.results.forEach(result => {
|
dayData.results.forEach(result => {
|
||||||
teamResults[result.team] = result.result;
|
teamResults[result.team] = result.visible_result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const TeamResults = () => {
|
|||||||
const sanitizedData = data.map((team) => ({
|
const sanitizedData = data.map((team) => ({
|
||||||
...team,
|
...team,
|
||||||
name: sanitizeString(team.name),
|
name: sanitizeString(team.name),
|
||||||
announcement_time: team.announcement_time || "N/A", // Handle missing time
|
result_time: team.result_time || "N/A", // Handle missing time
|
||||||
results: team.results || {} // Ensure results exist
|
results: team.results || {} // Ensure results exist
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ const TeamResults = () => {
|
|||||||
{teams.map((team) => (
|
{teams.map((team) => (
|
||||||
<div key={team.id} className="border p-4 rounded-md shadow-md">
|
<div key={team.id} className="border p-4 rounded-md shadow-md">
|
||||||
<h3 className="text-lg font-semibold">{team.name}</h3>
|
<h3 className="text-lg font-semibold">{team.name}</h3>
|
||||||
<p className="text-sm text-gray-600">Time: {team.announcement_time}</p>
|
<p className="text-sm text-gray-600">Time: {team.result_time}</p>
|
||||||
|
|
||||||
<div className="mt-2">
|
<div className="mt-2">
|
||||||
<h4 className="font-semibold">Results:</h4>
|
<h4 className="font-semibold">Results:</h4>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user