fix: UTC-Bug bei Datum-Defaults - new Date().toISOString() durch lokale Formatierung ersetzt
This commit is contained in:
@@ -45,7 +45,11 @@ function BestellungDetail({ id, toast, onBack }) {
|
|||||||
const [pickerSearch,setPickerSearch]= useState('');
|
const [pickerSearch,setPickerSearch]= useState('');
|
||||||
const [editMode, setEditMode] = useState(false);
|
const [editMode, setEditMode] = useState(false);
|
||||||
const [form, setForm] = useState({ name:'', bemerkung:'', custom_price:'', status:'warteliste' });
|
const [form, setForm] = useState({ name:'', bemerkung:'', custom_price:'', status:'warteliste' });
|
||||||
const today = () => new Date().toISOString().slice(0,10);
|
const today = () => {
|
||||||
|
const d = new Date();
|
||||||
|
const y = d.getFullYear(), m = String(d.getMonth()+1).padStart(2,'0'), day = String(d.getDate()).padStart(2,'0');
|
||||||
|
return `${y}-${m}-${day}`;
|
||||||
|
};
|
||||||
const [bezahltDate, setBezahltDate] = useState(today());
|
const [bezahltDate, setBezahltDate] = useState(today());
|
||||||
const [abgeholtDate, setAbgeholtDate] = useState(today());
|
const [abgeholtDate, setAbgeholtDate] = useState(today());
|
||||||
const [showBezahltPicker, setShowBezahltPicker] = useState(false);
|
const [showBezahltPicker, setShowBezahltPicker] = useState(false);
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ const CATS = ['Filament','Zubehör','Ersatzteile','Werkzeug','Sonstiges'];
|
|||||||
const CAT_COLORS = { Filament:'#4ecdc4', Zubehör:'#ffe66d', Ersatzteile:'#ff6b9d', Werkzeug:'#60a5fa', Sonstiges:'#c084fc' };
|
const CAT_COLORS = { Filament:'#4ecdc4', Zubehör:'#ffe66d', Ersatzteile:'#ff6b9d', Werkzeug:'#60a5fa', Sonstiges:'#c084fc' };
|
||||||
|
|
||||||
const fmt = v => `${(v||0).toFixed(2)} €`;
|
const fmt = v => `${(v||0).toFixed(2)} €`;
|
||||||
|
// Lokales Datum als YYYY-MM-DD (kein UTC-Bug wie bei toISOString)
|
||||||
|
function todayLocal() {
|
||||||
|
const d = new Date();
|
||||||
|
const y = d.getFullYear(), m = String(d.getMonth()+1).padStart(2,'0'), day = String(d.getDate()).padStart(2,'0');
|
||||||
|
return `${y}-${m}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
const fmtMonth = m => {
|
const fmtMonth = m => {
|
||||||
if (!m) return '';
|
if (!m) return '';
|
||||||
if (/^\d{4}-\d{2}$/.test(m)) {
|
if (/^\d{4}-\d{2}$/.test(m)) {
|
||||||
@@ -192,12 +199,12 @@ function OrdersInPeriod({ fromDate, toDate }) {
|
|||||||
|
|
||||||
export default function Statistik({ mobile }) {
|
export default function Statistik({ mobile }) {
|
||||||
const [fromDate, setFromDate] = useState('');
|
const [fromDate, setFromDate] = useState('');
|
||||||
const [toDate, setToDate] = useState(new Date().toISOString().slice(0,10));
|
const [toDate, setToDate] = useState(todayLocal());
|
||||||
const [data, setData] = useState(null);
|
const [data, setData] = useState(null);
|
||||||
const [loading,setLoading] = useState(false);
|
const [loading,setLoading] = useState(false);
|
||||||
const [tab, setTab] = useState('overview');
|
const [tab, setTab] = useState('overview');
|
||||||
|
|
||||||
const [expForm,setExpForm] = useState({ date: new Date().toISOString().slice(0,10), category:'Filament', description:'', amount:'' });
|
const [expForm,setExpForm] = useState({ date: todayLocal(), category:'Filament', description:'', amount:'' });
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
@@ -251,7 +258,7 @@ export default function Statistik({ mobile }) {
|
|||||||
borderRadius:8,padding:'5px 10px',color:'#fff',fontFamily:'monospace',fontSize:11,cursor:'pointer'}}/>
|
borderRadius:8,padding:'5px 10px',color:'#fff',fontFamily:'monospace',fontSize:11,cursor:'pointer'}}/>
|
||||||
</div>
|
</div>
|
||||||
{fromDate && (
|
{fromDate && (
|
||||||
<button onClick={()=>{setFromDate('');setToDate(new Date().toISOString().slice(0,10));}}
|
<button onClick={()=>{setFromDate('');setToDate(todayLocal());}}
|
||||||
style={{background:'rgba(255,255,255,0.04)',border:'1px solid rgba(255,255,255,0.1)',
|
style={{background:'rgba(255,255,255,0.04)',border:'1px solid rgba(255,255,255,0.1)',
|
||||||
borderRadius:8,padding:'5px 10px',color:'rgba(255,255,255,0.4)',fontFamily:'monospace',fontSize:11,cursor:'pointer'}}>
|
borderRadius:8,padding:'5px 10px',color:'rgba(255,255,255,0.4)',fontFamily:'monospace',fontSize:11,cursor:'pointer'}}>
|
||||||
✕ Zurücksetzen
|
✕ Zurücksetzen
|
||||||
|
|||||||
Reference in New Issue
Block a user