aktueller stand

This commit is contained in:
2026-01-29 21:00:20 +01:00
parent e64edabf85
commit 18891f8525
4 changed files with 1190 additions and 42 deletions

View File

@@ -40,6 +40,7 @@ function App() {
const [focusedStoreId, setFocusedStoreId] = useState(null);
const [nearestStoreLabel, setNearestStoreLabel] = useState(null);
const [regularPickupMap, setRegularPickupMap] = useState({});
const bootstrapOnceRef = useRef(false);
const minSelectableDate = useMemo(() => startOfDay(new Date()), []);
const weekdays = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'];
@@ -232,9 +233,12 @@ function App() {
setStores(Array.isArray(result.stores) ? result.stores : []);
setAdminSettingsSnapshot(result.adminSettings ?? null);
setConfig(Array.isArray(result.config) ? result.config : []);
if (result.regularPickupMap && typeof result.regularPickupMap === 'object') {
setRegularPickupMap(result.regularPickupMap);
}
return result;
},
[setStores, setAdminSettingsSnapshot, setConfig]
[setStores, setAdminSettingsSnapshot, setConfig, setRegularPickupMap]
);
const resetSessionState = useCallback(() => {
@@ -361,6 +365,10 @@ function App() {
let ticker;
let cancelled = false;
(async () => {
if (bootstrapOnceRef.current) {
return;
}
bootstrapOnceRef.current = true;
const storedToken = getStoredToken();
if (!storedToken) {
return;

View File

@@ -91,26 +91,32 @@ const useSessionManager = ({ normalizeConfigEntries, onUnauthorized, setError, s
progress?.update?.('Betriebe werden geprüft...', 45);
const stores = Array.isArray(data.stores) ? data.stores : [];
const adminSettings = data.isAdmin ? normalizeAdminSettings(data.adminSettings) : null;
const configResponse = await fetch('/api/config', {
headers: { Authorization: `Bearer ${token}` }
});
if (configResponse.status === 401) {
handleUnauthorized();
return {};
const configSource = Array.isArray(data.config) ? data.config : data.config || null;
let config = normalizeConfigEntries(Array.isArray(configSource) ? configSource : []);
if (!configSource) {
const configResponse = await fetch('/api/config', {
headers: { Authorization: `Bearer ${token}` }
});
if (configResponse.status === 401) {
handleUnauthorized();
return {};
}
if (!configResponse.ok) {
throw new Error(`HTTP ${configResponse.status}`);
}
const configData = await configResponse.json();
progress?.update?.('Konfiguration wird geladen...', 75);
config = normalizeConfigEntries(Array.isArray(configData) ? configData : []);
} else {
progress?.update?.('Konfiguration wird geladen...', 75);
}
if (!configResponse.ok) {
throw new Error(`HTTP ${configResponse.status}`);
}
const configData = await configResponse.json();
progress?.update?.('Konfiguration wird geladen...', 75);
const config = normalizeConfigEntries(Array.isArray(configData) ? configData : []);
progress?.update?.('Synchronisierung abgeschlossen', 95);
return {
session: sessionData,
stores,
adminSettings,
regularPickupMap: data.regularPickupMap ?? null,
config,
storeRefreshJob: data.storeRefreshJob,
storesFresh: data.storesFresh