This commit is contained in:
parent
528813d4a0
commit
7d21081780
3 changed files with 14 additions and 6 deletions
|
|
@ -18,6 +18,14 @@ function clearStoredApiKey() {
|
|||
localStorage.removeItem(API_KEY_STORAGE_KEY);
|
||||
}
|
||||
|
||||
// Get local date string in YYYY-MM-DD format (not UTC)
|
||||
function toLocalDateString(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
// Authenticated fetch wrapper
|
||||
async function authFetch(url, options = {}) {
|
||||
const apiKey = getStoredApiKey();
|
||||
|
|
@ -364,7 +372,7 @@ function App() {
|
|||
setSelectedDayState(route.day);
|
||||
} else if (recordings.length > 0) {
|
||||
const sorted = [...recordings].sort((a, b) => b.startTime - a.startTime);
|
||||
setSelectedDayState(sorted[0].startTime.toISOString().slice(0, 10));
|
||||
setSelectedDayState(toLocalDateString(sorted[0].startTime));
|
||||
}
|
||||
|
||||
// If URL has a recording ID, fetch it
|
||||
|
|
@ -503,7 +511,7 @@ function App() {
|
|||
}
|
||||
|
||||
// Export utilities for other components
|
||||
Object.assign(window, { authFetch, getStoredApiKey });
|
||||
Object.assign(window, { authFetch, getStoredApiKey, toLocalDateString });
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(<App />);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue