Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -91,6 +91,22 @@ const TutorialTasks: React.FC = () => {
|
|
| 91 |
el.style.minHeight = '';
|
| 92 |
};
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
// Initialize scroll preservation helper once
|
| 95 |
useEffect(() => {
|
| 96 |
withPreservedScroll.current = (fn: () => void) => {
|
|
@@ -735,6 +751,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 735 |
|
| 736 |
try {
|
| 737 |
lockListHeight();
|
|
|
|
| 738 |
withPreservedScroll.current?.(() => {
|
| 739 |
setSubmitting({ ...submitting, [taskId]: true });
|
| 740 |
});
|
|
@@ -770,7 +787,10 @@ const TutorialTasks: React.FC = () => {
|
|
| 770 |
setSubmitting({ ...submitting, [taskId]: false });
|
| 771 |
});
|
| 772 |
// release after a couple frames to let DOM settle
|
| 773 |
-
requestAnimationFrame(() => requestAnimationFrame(
|
|
|
|
|
|
|
|
|
|
| 774 |
}
|
| 775 |
};
|
| 776 |
|
|
@@ -812,7 +832,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 812 |
setEditSubmissionText('');
|
| 813 |
};
|
| 814 |
|
| 815 |
-
const handleDeleteSubmission = async (submissionId: string) => {
|
| 816 |
|
| 817 |
|
| 818 |
try {
|
|
@@ -834,8 +854,11 @@ const TutorialTasks: React.FC = () => {
|
|
| 834 |
console.error('Error deleting submission:', error);
|
| 835 |
|
| 836 |
}
|
| 837 |
-
// let DOM settle then unlock
|
| 838 |
-
requestAnimationFrame(() => requestAnimationFrame(
|
|
|
|
|
|
|
|
|
|
| 839 |
};
|
| 840 |
|
| 841 |
const getStatusIcon = (status: string) => {
|
|
@@ -2165,7 +2188,7 @@ const TutorialTasks: React.FC = () => {
|
|
| 2165 |
)}
|
| 2166 |
{JSON.parse(localStorage.getItem('user') || '{}').role === 'admin' && (
|
| 2167 |
<button
|
| 2168 |
-
onClick={() => handleDeleteSubmission(submission._id)}
|
| 2169 |
className="text-red-600 hover:text-red-800 text-sm font-medium"
|
| 2170 |
>
|
| 2171 |
Delete
|
|
|
|
| 91 |
el.style.minHeight = '';
|
| 92 |
};
|
| 93 |
|
| 94 |
+
const lockCardHeightById = (id: string) => {
|
| 95 |
+
const el = cardRefs.current[id];
|
| 96 |
+
if (!el) return;
|
| 97 |
+
const h = el.getBoundingClientRect().height;
|
| 98 |
+
el.style.minHeight = `${h}px`;
|
| 99 |
+
el.style.height = `${h}px`;
|
| 100 |
+
el.style.overflow = 'hidden';
|
| 101 |
+
};
|
| 102 |
+
const unlockCardHeightById = (id: string) => {
|
| 103 |
+
const el = cardRefs.current[id];
|
| 104 |
+
if (!el) return;
|
| 105 |
+
el.style.overflow = '';
|
| 106 |
+
el.style.height = '';
|
| 107 |
+
el.style.minHeight = '';
|
| 108 |
+
};
|
| 109 |
+
|
| 110 |
// Initialize scroll preservation helper once
|
| 111 |
useEffect(() => {
|
| 112 |
withPreservedScroll.current = (fn: () => void) => {
|
|
|
|
| 751 |
|
| 752 |
try {
|
| 753 |
lockListHeight();
|
| 754 |
+
lockCardHeightById(taskId);
|
| 755 |
withPreservedScroll.current?.(() => {
|
| 756 |
setSubmitting({ ...submitting, [taskId]: true });
|
| 757 |
});
|
|
|
|
| 787 |
setSubmitting({ ...submitting, [taskId]: false });
|
| 788 |
});
|
| 789 |
// release after a couple frames to let DOM settle
|
| 790 |
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
| 791 |
+
unlockListHeight();
|
| 792 |
+
unlockCardHeightById(taskId);
|
| 793 |
+
}));
|
| 794 |
}
|
| 795 |
};
|
| 796 |
|
|
|
|
| 832 |
setEditSubmissionText('');
|
| 833 |
};
|
| 834 |
|
| 835 |
+
const handleDeleteSubmission = async (submissionId: string, taskId?: string) => {
|
| 836 |
|
| 837 |
|
| 838 |
try {
|
|
|
|
| 854 |
console.error('Error deleting submission:', error);
|
| 855 |
|
| 856 |
}
|
| 857 |
+
// let DOM settle then unlock (both list and card if id known)
|
| 858 |
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
| 859 |
+
unlockListHeight();
|
| 860 |
+
if (taskId) unlockCardHeightById(taskId);
|
| 861 |
+
}));
|
| 862 |
};
|
| 863 |
|
| 864 |
const getStatusIcon = (status: string) => {
|
|
|
|
| 2188 |
)}
|
| 2189 |
{JSON.parse(localStorage.getItem('user') || '{}').role === 'admin' && (
|
| 2190 |
<button
|
| 2191 |
+
onClick={() => handleDeleteSubmission(submission._id, task._id)}
|
| 2192 |
className="text-red-600 hover:text-red-800 text-sm font-medium"
|
| 2193 |
>
|
| 2194 |
Delete
|