new features, bookstack
This commit is contained in:
@@ -52,6 +52,7 @@ import {
|
||||
Delete as DeleteIcon,
|
||||
} from '@mui/icons-material';
|
||||
import DashboardLayout from '../components/dashboard/DashboardLayout';
|
||||
import { toGermanDate, toGermanDateTime, fromGermanDate, fromGermanDateTime } from '../utils/dateInput';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { useNotification } from '../contexts/NotificationContext';
|
||||
import { eventsApi } from '../services/events';
|
||||
@@ -121,15 +122,15 @@ function formatDateShort(isoString: string): string {
|
||||
return `${String(d.getDate()).padStart(2, '0')}.${String(d.getMonth() + 1).padStart(2, '0')}.${d.getFullYear()}`;
|
||||
}
|
||||
|
||||
/** Convert a Date to datetime-local input value "YYYY-MM-DDTHH:MM" */
|
||||
function toDatetimeLocal(isoString: string): string {
|
||||
const d = new Date(isoString);
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
/** Convert datetime-local value back to ISO string */
|
||||
function fromDatetimeLocal(value: string): string {
|
||||
if (!value) return new Date().toISOString();
|
||||
// DD.MM.YYYY HH:MM format
|
||||
const dtIso = fromGermanDateTime(value);
|
||||
if (dtIso) return new Date(dtIso).toISOString();
|
||||
// DD.MM.YYYY format (for ganztaegig)
|
||||
const dIso = fromGermanDate(value);
|
||||
if (dIso) return new Date(dIso).toISOString();
|
||||
return new Date(value).toISOString();
|
||||
}
|
||||
|
||||
@@ -720,16 +721,16 @@ function EventFormDialog({
|
||||
{/* Datum von */}
|
||||
<TextField
|
||||
label="Von"
|
||||
type={form.ganztaegig ? 'date' : 'datetime-local'}
|
||||
placeholder={form.ganztaegig ? 'TT.MM.JJJJ' : 'TT.MM.JJJJ HH:MM'}
|
||||
value={
|
||||
form.ganztaegig
|
||||
? toDatetimeLocal(form.datum_von).slice(0, 10)
|
||||
: toDatetimeLocal(form.datum_von)
|
||||
? toGermanDate(form.datum_von)
|
||||
: toGermanDateTime(form.datum_von)
|
||||
}
|
||||
onChange={(e) => {
|
||||
const raw = e.target.value;
|
||||
const iso = form.ganztaegig
|
||||
? fromDatetimeLocal(`${raw}T00:00`)
|
||||
? fromDatetimeLocal(raw ? `${fromGermanDate(raw)}T00:00` : '')
|
||||
: fromDatetimeLocal(raw);
|
||||
handleChange('datum_von', iso);
|
||||
}}
|
||||
@@ -740,16 +741,16 @@ function EventFormDialog({
|
||||
{/* Datum bis */}
|
||||
<TextField
|
||||
label="Bis"
|
||||
type={form.ganztaegig ? 'date' : 'datetime-local'}
|
||||
placeholder={form.ganztaegig ? 'TT.MM.JJJJ' : 'TT.MM.JJJJ HH:MM'}
|
||||
value={
|
||||
form.ganztaegig
|
||||
? toDatetimeLocal(form.datum_bis).slice(0, 10)
|
||||
: toDatetimeLocal(form.datum_bis)
|
||||
? toGermanDate(form.datum_bis)
|
||||
: toGermanDateTime(form.datum_bis)
|
||||
}
|
||||
onChange={(e) => {
|
||||
const raw = e.target.value;
|
||||
const iso = form.ganztaegig
|
||||
? fromDatetimeLocal(`${raw}T23:59`)
|
||||
? fromDatetimeLocal(raw ? `${fromGermanDate(raw)}T23:59` : '')
|
||||
: fromDatetimeLocal(raw);
|
||||
handleChange('datum_bis', iso);
|
||||
}}
|
||||
@@ -827,9 +828,14 @@ function EventFormDialog({
|
||||
{form.anmeldung_erforderlich && (
|
||||
<TextField
|
||||
label="Anmeldeschluss"
|
||||
type="datetime-local"
|
||||
value={form.anmeldung_bis ? toDatetimeLocal(form.anmeldung_bis) : ''}
|
||||
onChange={(e) => handleChange('anmeldung_bis', e.target.value ? fromDatetimeLocal(e.target.value) : null)}
|
||||
placeholder="TT.MM.JJJJ HH:MM"
|
||||
value={form.anmeldung_bis ? toGermanDateTime(form.anmeldung_bis) : ''}
|
||||
onChange={(e) => {
|
||||
const raw = e.target.value;
|
||||
if (!raw) { handleChange('anmeldung_bis', null); return; }
|
||||
const iso = fromGermanDateTime(raw);
|
||||
if (iso) handleChange('anmeldung_bis', new Date(iso).toISOString());
|
||||
}}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user