Spaces:
Sleeping
Sleeping
Tristan Yu commited on
Commit ·
2ab9afd
1
Parent(s): 0759bb6
Add debugging for translation brief and image display issues
Browse files- src/pages/TutorialTasks.tsx +29 -5
src/pages/TutorialTasks.tsx
CHANGED
|
@@ -171,19 +171,37 @@ const TutorialTasks: React.FC = () => {
|
|
| 171 |
|
| 172 |
if (response.data) {
|
| 173 |
const tasks = response.data;
|
|
|
|
| 174 |
setTutorialTasks(tasks);
|
| 175 |
|
| 176 |
-
//
|
| 177 |
-
|
| 178 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
const tutorialWeekData: TutorialWeek = {
|
| 180 |
weekNumber: selectedWeek,
|
| 181 |
translationBrief: translationBrief,
|
| 182 |
tasks: tasks
|
| 183 |
};
|
| 184 |
setTutorialWeek(tutorialWeekData);
|
| 185 |
-
}
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
}
|
| 188 |
|
| 189 |
await fetchUserSubmissions(tasks);
|
|
@@ -447,6 +465,8 @@ const TutorialTasks: React.FC = () => {
|
|
| 447 |
weekNumber: selectedWeek
|
| 448 |
});
|
| 449 |
|
|
|
|
|
|
|
| 450 |
if (response.status >= 200 && response.status < 300) {
|
| 451 |
console.log('Brief saved successfully');
|
| 452 |
await fetchTutorialTasks();
|
|
@@ -1025,8 +1045,12 @@ const TutorialTasks: React.FC = () => {
|
|
| 1025 |
alt={task.imageAlt || 'Task image'}
|
| 1026 |
className="w-full max-w-md mx-auto rounded-lg shadow-md"
|
| 1027 |
onError={(e) => {
|
|
|
|
| 1028 |
e.currentTarget.style.display = 'none';
|
| 1029 |
}}
|
|
|
|
|
|
|
|
|
|
| 1030 |
/>
|
| 1031 |
{task.imageAlt && (
|
| 1032 |
<p className="text-sm text-gray-600 text-center mt-2 italic">{task.imageAlt}</p>
|
|
|
|
| 171 |
|
| 172 |
if (response.data) {
|
| 173 |
const tasks = response.data;
|
| 174 |
+
console.log('Fetched tasks:', tasks);
|
| 175 |
setTutorialTasks(tasks);
|
| 176 |
|
| 177 |
+
// Try to fetch translation brief separately
|
| 178 |
+
try {
|
| 179 |
+
const briefResponse = await api.get(`/search/tutorial-brief/${selectedWeek}`);
|
| 180 |
+
console.log('Brief response:', briefResponse.data);
|
| 181 |
+
const translationBrief = briefResponse.data?.translationBrief || tasks[0]?.translationBrief;
|
| 182 |
+
console.log('Translation brief:', translationBrief);
|
| 183 |
+
|
| 184 |
const tutorialWeekData: TutorialWeek = {
|
| 185 |
weekNumber: selectedWeek,
|
| 186 |
translationBrief: translationBrief,
|
| 187 |
tasks: tasks
|
| 188 |
};
|
| 189 |
setTutorialWeek(tutorialWeekData);
|
| 190 |
+
} catch (briefError) {
|
| 191 |
+
console.log('No separate brief endpoint, using task brief');
|
| 192 |
+
// Fallback to task brief
|
| 193 |
+
if (tasks.length > 0) {
|
| 194 |
+
const translationBrief = tasks[0].translationBrief;
|
| 195 |
+
console.log('Translation brief from task:', translationBrief);
|
| 196 |
+
const tutorialWeekData: TutorialWeek = {
|
| 197 |
+
weekNumber: selectedWeek,
|
| 198 |
+
translationBrief: translationBrief,
|
| 199 |
+
tasks: tasks
|
| 200 |
+
};
|
| 201 |
+
setTutorialWeek(tutorialWeekData);
|
| 202 |
+
} else {
|
| 203 |
+
setTutorialWeek(null);
|
| 204 |
+
}
|
| 205 |
}
|
| 206 |
|
| 207 |
await fetchUserSubmissions(tasks);
|
|
|
|
| 465 |
weekNumber: selectedWeek
|
| 466 |
});
|
| 467 |
|
| 468 |
+
console.log('Brief save response:', response);
|
| 469 |
+
|
| 470 |
if (response.status >= 200 && response.status < 300) {
|
| 471 |
console.log('Brief saved successfully');
|
| 472 |
await fetchTutorialTasks();
|
|
|
|
| 1045 |
alt={task.imageAlt || 'Task image'}
|
| 1046 |
className="w-full max-w-md mx-auto rounded-lg shadow-md"
|
| 1047 |
onError={(e) => {
|
| 1048 |
+
console.error('Image failed to load:', task.imageUrl);
|
| 1049 |
e.currentTarget.style.display = 'none';
|
| 1050 |
}}
|
| 1051 |
+
onLoad={() => {
|
| 1052 |
+
console.log('Image loaded successfully:', task.imageUrl);
|
| 1053 |
+
}}
|
| 1054 |
/>
|
| 1055 |
{task.imageAlt && (
|
| 1056 |
<p className="text-sm text-gray-600 text-center mt-2 italic">{task.imageAlt}</p>
|