|
|
@ -84,6 +84,7 @@ const App = ({}) => {
|
|
|
|
const [showMobileMenu, setShowMobileMenu] = useState(false)
|
|
|
|
const [showMobileMenu, setShowMobileMenu] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(async () => {
|
|
|
|
useEffect(async () => {
|
|
|
|
|
|
|
|
console.log('source changed')
|
|
|
|
const eventi = await loadEventi(CALENDAR_IDS[source])
|
|
|
|
const eventi = await loadEventi(CALENDAR_IDS[source])
|
|
|
|
|
|
|
|
|
|
|
|
window.dataBuffer[source] = eventi
|
|
|
|
window.dataBuffer[source] = eventi
|
|
|
@ -91,23 +92,21 @@ const App = ({}) => {
|
|
|
|
setEventi(eventi)
|
|
|
|
setEventi(eventi)
|
|
|
|
}, [source])
|
|
|
|
}, [source])
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const groupIds = new Set(eventi.map(e => e.nome))
|
|
|
|
setSelectedCourses(selectedCourses => {
|
|
|
|
const toolOverlayVisible =
|
|
|
|
const nextCoursesGroup = new Set(eventi.map(e => e.nome))
|
|
|
|
selectedCourses.length > 0 && selectedCourses.filter(id => groupIds.has(id)).length > 0
|
|
|
|
|
|
|
|
|
|
|
|
// Here the filter is on "selection" because most of the times |selection| <= |nextCoursesGroup|
|
|
|
|
|
|
|
|
const intersectionSize = selectedCourses.filter(nome =>
|
|
|
|
|
|
|
|
nextCoursesGroup.has(nome)
|
|
|
|
|
|
|
|
).length
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return intersectionSize === 0 ? [] : selectedCourses
|
|
|
|
useEffect(() => {
|
|
|
|
})
|
|
|
|
console.log('course length changed')
|
|
|
|
}, [eventi, selectedCourses])
|
|
|
|
const groupIds = new Set(eventi.map(e => e.nome))
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Should wrap in "useEffect"?
|
|
|
|
if (
|
|
|
|
if (selectedCourses.length === 0) {
|
|
|
|
selectedCourses.length === 0 ||
|
|
|
|
setHideOtherCourses(false)
|
|
|
|
selectedCourses.filter(id => groupIds.has(id)).length === 0
|
|
|
|
}
|
|
|
|
) {
|
|
|
|
|
|
|
|
setHideOtherCourses(false)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [eventi, selectedCourses.length])
|
|
|
|
|
|
|
|
|
|
|
|
const [theme, setTheme] = useState(
|
|
|
|
const [theme, setTheme] = useState(
|
|
|
|
localStorage.getItem('theme') ??
|
|
|
|
localStorage.getItem('theme') ??
|
|
|
@ -138,6 +137,7 @@ const App = ({}) => {
|
|
|
|
hideOtherCourses={hideOtherCourses}
|
|
|
|
hideOtherCourses={hideOtherCourses}
|
|
|
|
start={new Date(2022, 10, 3)}
|
|
|
|
start={new Date(2022, 10, 3)}
|
|
|
|
events={eventi.map(({ nome, dataInizio, dataFine, docenti, aule }) => ({
|
|
|
|
events={eventi.map(({ nome, dataInizio, dataFine, docenti, aule }) => ({
|
|
|
|
|
|
|
|
id: nome,
|
|
|
|
name: _.split(nome, '-', 1)[0].trim(),
|
|
|
|
name: _.split(nome, '-', 1)[0].trim(),
|
|
|
|
start: new Date(dataInizio),
|
|
|
|
start: new Date(dataInizio),
|
|
|
|
end: new Date(dataFine),
|
|
|
|
end: new Date(dataFine),
|
|
|
@ -150,7 +150,7 @@ const App = ({}) => {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
}))}
|
|
|
|
}))}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
{selectedCourses.length > 0 && (
|
|
|
|
{toolOverlayVisible && (
|
|
|
|
<ToolOverlay
|
|
|
|
<ToolOverlay
|
|
|
|
visibility={hideOtherCourses}
|
|
|
|
visibility={hideOtherCourses}
|
|
|
|
toggleVisibility={() => setHideOtherCourses(s => !s)}
|
|
|
|
toggleVisibility={() => setHideOtherCourses(s => !s)}
|
|
|
|