|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import _ from 'lodash'
|
|
|
|
|
import { render } from 'preact'
|
|
|
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
|
|
|
import { differenceInMinutes, startOfDay } from 'date-fns'
|
|
|
|
|
|
|
|
|
|
// import { ToolOverlay } from './components/ToolOverlay.jsx'
|
|
|
|
|
//
|
|
|
|
@ -18,12 +19,7 @@ import { Icon } from './components/Icon.jsx'
|
|
|
|
|
import { Popup } from './components/Popup.jsx'
|
|
|
|
|
import { Toolbar } from './components/Toolbar.jsx'
|
|
|
|
|
import { OptionBar } from './components/OptionBar.jsx'
|
|
|
|
|
import {
|
|
|
|
|
prettyAulaName,
|
|
|
|
|
prettyProfName,
|
|
|
|
|
clearOldPersistentStates,
|
|
|
|
|
usePersistentState,
|
|
|
|
|
} from './utils.jsx'
|
|
|
|
|
import { prettyAulaName, prettyProfName, usePersistentState } from './utils.jsx'
|
|
|
|
|
import { SettingsBar } from './components/SettingsBar.jsx'
|
|
|
|
|
|
|
|
|
|
// Che fanno queste due righe?
|
|
|
|
@ -67,11 +63,14 @@ function specialEventPatches(eventi) {
|
|
|
|
|
|
|
|
|
|
function formatEvents(timetable) {
|
|
|
|
|
return timetable.map(({ nome, dataInizio, dataFine, docenti, aule }) => {
|
|
|
|
|
const start = new Date(dataInizio)
|
|
|
|
|
const end = new Date(dataFine)
|
|
|
|
|
return {
|
|
|
|
|
id: nome,
|
|
|
|
|
name: _.split(nome, '-', 1)[0].trim(),
|
|
|
|
|
start: new Date(dataInizio),
|
|
|
|
|
end: new Date(dataFine),
|
|
|
|
|
day: start.getDay(),
|
|
|
|
|
start: differenceInMinutes(start, startOfDay(start)),
|
|
|
|
|
end: differenceInMinutes(end, startOfDay(start)),
|
|
|
|
|
docenti: docenti.map(({ nome, cognome }) =>
|
|
|
|
|
prettyProfName(nome, cognome)
|
|
|
|
|
),
|
|
|
|
@ -142,19 +141,50 @@ async function loadCalendari(date) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const View = ({ view, selection, setSelection, timetables }) => {
|
|
|
|
|
const View = ({
|
|
|
|
|
view,
|
|
|
|
|
selection,
|
|
|
|
|
setSelection,
|
|
|
|
|
timetables,
|
|
|
|
|
custom,
|
|
|
|
|
setCustom,
|
|
|
|
|
}) => {
|
|
|
|
|
if (view === 'orario') {
|
|
|
|
|
return <Schedule selection={selection} timetables={timetables} />
|
|
|
|
|
return (
|
|
|
|
|
<Schedule
|
|
|
|
|
selection={selection}
|
|
|
|
|
timetables={timetables}
|
|
|
|
|
custom={custom}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
} else if (view === 'lista') {
|
|
|
|
|
return (
|
|
|
|
|
<Courses
|
|
|
|
|
selection={selection}
|
|
|
|
|
setSelection={setSelection}
|
|
|
|
|
source={'tutti'}
|
|
|
|
|
timetables={timetables}
|
|
|
|
|
hideOtherCourses={true}
|
|
|
|
|
custom={custom}
|
|
|
|
|
isRestrictedList={true}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
} else if (view === 'custom') {
|
|
|
|
|
return (
|
|
|
|
|
<div class="custom-events-view">
|
|
|
|
|
<textarea
|
|
|
|
|
value={custom}
|
|
|
|
|
onChange={e => setCustom(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
<p>Esempio di evento personalizzato</p>
|
|
|
|
|
<p>
|
|
|
|
|
Nome evento [label globale]:
|
|
|
|
|
<br />
|
|
|
|
|
- Lun 9-11
|
|
|
|
|
<br />
|
|
|
|
|
- Mar 9:00-11:00
|
|
|
|
|
<br />- Gio 8:00-12:00 [label locale]
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
<Courses
|
|
|
|
@ -162,7 +192,7 @@ const View = ({ view, selection, setSelection, timetables }) => {
|
|
|
|
|
setSelection={setSelection}
|
|
|
|
|
source={view}
|
|
|
|
|
timetables={timetables}
|
|
|
|
|
hideOtherCourses={false}
|
|
|
|
|
isRestrictedList={false}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
@ -184,15 +214,15 @@ const App = ({}) => {
|
|
|
|
|
setTimetables(await loadCalendari(new Date(date)))
|
|
|
|
|
}, [date])
|
|
|
|
|
|
|
|
|
|
// View Modes
|
|
|
|
|
// const [mode, setMode] = usePersistentState('orario.mode', MODE_COURSES)
|
|
|
|
|
|
|
|
|
|
// Selection
|
|
|
|
|
const [selectedCourses, setSelectedCourses] = usePersistentState(
|
|
|
|
|
'selection',
|
|
|
|
|
[]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Custom Events
|
|
|
|
|
const [custom, setCustom] = usePersistentState('custom', [])
|
|
|
|
|
|
|
|
|
|
// Menus
|
|
|
|
|
const [helpVisible, setHelpVisible] = useState(false)
|
|
|
|
|
const [showMobileMenu, setShowMobileMenu] = useState(false)
|
|
|
|
@ -281,6 +311,8 @@ const App = ({}) => {
|
|
|
|
|
setSelection={setSelectedCourses}
|
|
|
|
|
view={view}
|
|
|
|
|
timetables={timetables}
|
|
|
|
|
custom={custom}
|
|
|
|
|
setCustom={setCustom}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|