Upload folder using huggingface_hub
Browse files
frontend/src/components/EventView.tsx
CHANGED
|
@@ -63,7 +63,7 @@ export default function EventView() {
|
|
| 63 |
const [editBuffer, setEditBuffer] = useState(0);
|
| 64 |
const [editDateFrom, setEditDateFrom] = useState('');
|
| 65 |
const [editDateTo, setEditDateTo] = useState('');
|
| 66 |
-
const [editSelectedDays, setEditSelectedDays] = useState<
|
| 67 |
const [editSaving, setEditSaving] = useState(false);
|
| 68 |
|
| 69 |
const [error, setError] = useState('');
|
|
@@ -78,6 +78,13 @@ export default function EventView() {
|
|
| 78 |
|
| 79 |
useEffect(load, [id]);
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
if (loading) return <p className="text-gray-500">Loading...</p>;
|
| 82 |
if (error) return <p className="text-red-500">Error: {error}</p>;
|
| 83 |
if (!event) return <p className="text-red-500">Event not found.</p>;
|
|
@@ -158,7 +165,7 @@ export default function EventView() {
|
|
| 158 |
// Infer which days are included
|
| 159 |
const days = new Set<number>();
|
| 160 |
event.dates.forEach((d) => days.add(new Date(d + 'T00:00:00').getDay()));
|
| 161 |
-
setEditSelectedDays(days);
|
| 162 |
}
|
| 163 |
setEditing(true);
|
| 164 |
};
|
|
@@ -173,18 +180,10 @@ export default function EventView() {
|
|
| 173 |
}
|
| 174 |
};
|
| 175 |
|
| 176 |
-
const editDates = useMemo(
|
| 177 |
-
() => generateDatesInRange(editDateFrom, editDateTo, editSelectedDays),
|
| 178 |
-
[editDateFrom, editDateTo, editSelectedDays]
|
| 179 |
-
);
|
| 180 |
-
|
| 181 |
const toggleEditDay = (dayIndex: number) => {
|
| 182 |
-
setEditSelectedDays((prev) =>
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
else next.add(dayIndex);
|
| 186 |
-
return next;
|
| 187 |
-
});
|
| 188 |
};
|
| 189 |
|
| 190 |
const handleEditSave = async () => {
|
|
@@ -308,7 +307,7 @@ export default function EventView() {
|
|
| 308 |
<div className="flex gap-2">
|
| 309 |
{DAY_LABELS.map((label, i) => {
|
| 310 |
const dayIndex = DAY_INDICES[i];
|
| 311 |
-
const isActive = editSelectedDays.
|
| 312 |
return (
|
| 313 |
<button key={label} type="button" onClick={() => toggleEditDay(dayIndex)}
|
| 314 |
className={`px-3 py-1.5 rounded text-sm font-medium transition-colors ${isActive ? 'bg-blue-600 text-white' : 'bg-gray-100 text-gray-500 hover:bg-gray-200'}`}>
|
|
|
|
| 63 |
const [editBuffer, setEditBuffer] = useState(0);
|
| 64 |
const [editDateFrom, setEditDateFrom] = useState('');
|
| 65 |
const [editDateTo, setEditDateTo] = useState('');
|
| 66 |
+
const [editSelectedDays, setEditSelectedDays] = useState<number[]>([1, 2, 3, 4, 5]);
|
| 67 |
const [editSaving, setEditSaving] = useState(false);
|
| 68 |
|
| 69 |
const [error, setError] = useState('');
|
|
|
|
| 78 |
|
| 79 |
useEffect(load, [id]);
|
| 80 |
|
| 81 |
+
const editDaysSet = useMemo(() => new Set(editSelectedDays), [editSelectedDays]);
|
| 82 |
+
|
| 83 |
+
const editDates = useMemo(
|
| 84 |
+
() => generateDatesInRange(editDateFrom, editDateTo, editDaysSet),
|
| 85 |
+
[editDateFrom, editDateTo, editSelectedDays]
|
| 86 |
+
);
|
| 87 |
+
|
| 88 |
if (loading) return <p className="text-gray-500">Loading...</p>;
|
| 89 |
if (error) return <p className="text-red-500">Error: {error}</p>;
|
| 90 |
if (!event) return <p className="text-red-500">Event not found.</p>;
|
|
|
|
| 165 |
// Infer which days are included
|
| 166 |
const days = new Set<number>();
|
| 167 |
event.dates.forEach((d) => days.add(new Date(d + 'T00:00:00').getDay()));
|
| 168 |
+
setEditSelectedDays(Array.from(days));
|
| 169 |
}
|
| 170 |
setEditing(true);
|
| 171 |
};
|
|
|
|
| 180 |
}
|
| 181 |
};
|
| 182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
const toggleEditDay = (dayIndex: number) => {
|
| 184 |
+
setEditSelectedDays((prev) =>
|
| 185 |
+
prev.includes(dayIndex) ? prev.filter((d) => d !== dayIndex) : [...prev, dayIndex]
|
| 186 |
+
);
|
|
|
|
|
|
|
|
|
|
| 187 |
};
|
| 188 |
|
| 189 |
const handleEditSave = async () => {
|
|
|
|
| 307 |
<div className="flex gap-2">
|
| 308 |
{DAY_LABELS.map((label, i) => {
|
| 309 |
const dayIndex = DAY_INDICES[i];
|
| 310 |
+
const isActive = editSelectedDays.includes(dayIndex);
|
| 311 |
return (
|
| 312 |
<button key={label} type="button" onClick={() => toggleEditDay(dayIndex)}
|
| 313 |
className={`px-3 py-1.5 rounded text-sm font-medium transition-colors ${isActive ? 'bg-blue-600 text-white' : 'bg-gray-100 text-gray-500 hover:bg-gray-200'}`}>
|