Compare commits
19 Commits
copilot/up
...
ad96d38863
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad96d38863 | ||
|
|
b80c15e186 | ||
|
|
7a04012b60 | ||
|
|
3b49844d0b | ||
|
|
81767e5270 | ||
|
|
675e5f6fe8 | ||
| 2e9e100178 | |||
|
|
1081ea1074 | ||
|
|
761c7f1971 | ||
|
|
0bd5efde2c | ||
|
|
8e9db971d3 | ||
|
|
09872737b7 | ||
|
|
cc3ad148fc | ||
|
|
1eb96877ff | ||
|
|
76dc94dd78 | ||
|
|
c3dd0cfa69 | ||
|
|
40371b43d1 | ||
|
|
19953dff55 | ||
|
|
50d3803610 |
@@ -68,6 +68,7 @@ if (!carCols.includes('sort_order')) {
|
||||
db.exec('ALTER TABLE cars ADD COLUMN sort_order INTEGER DEFAULT 0');
|
||||
db.exec('UPDATE cars SET sort_order = id');
|
||||
}
|
||||
db.prepare("UPDATE cars SET tire_type = 'スタッドレス' WHERE tire_type = 'スタットレス'").run();
|
||||
|
||||
// Migrate: add period fields to reservations if they don't exist yet
|
||||
const resCols = db.prepare("PRAGMA table_info(reservations)").all().map((c) => c.name);
|
||||
@@ -99,13 +100,17 @@ function broadcast(message) {
|
||||
});
|
||||
}
|
||||
|
||||
// for future use
|
||||
function normalizeTireType(value) {
|
||||
return value === 'スタットレス' ? 'スタッドレス' : value;
|
||||
}
|
||||
|
||||
function normalizeCar(car) {
|
||||
if (!car) {
|
||||
return car;
|
||||
}
|
||||
return {
|
||||
...car,
|
||||
tire_type: normalizeTireType(car.tire_type),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { format, addDays, parseISO, differenceInDays } from 'date-fns';
|
||||
import { format, addDays, startOfWeek, parseISO, differenceInDays } from 'date-fns';
|
||||
import { ja } from 'date-fns/locale';
|
||||
import { api } from '../api.js';
|
||||
import { isInspectionExpirySoon, formatDateRange, formatReservationTooltip } from '../utils/carUtils.js';
|
||||
@@ -43,8 +43,10 @@ export default function ScheduleView({ reloadKey = 0 }) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
// The first date shown in the grid (start from today)
|
||||
const [viewStart, setViewStart] = useState(() => new Date());
|
||||
// The first date shown in the grid
|
||||
const [viewStart, setViewStart] = useState(() =>
|
||||
startOfWeek(new Date(), { weekStartsOn: 1 })
|
||||
);
|
||||
|
||||
// Drag-to-create state
|
||||
const [creating, setCreating] = useState(null);
|
||||
@@ -90,7 +92,7 @@ export default function ScheduleView({ reloadKey = 0 }) {
|
||||
// --- Navigation ---
|
||||
const prevWeek = () => setViewStart((d) => addDays(d, -7));
|
||||
const nextWeek = () => setViewStart((d) => addDays(d, 7));
|
||||
const goToday = () => setViewStart(new Date());
|
||||
const goToday = () => setViewStart(startOfWeek(new Date(), { weekStartsOn: 1 }));
|
||||
|
||||
// --- Grid position helpers ---
|
||||
// Given a mouse clientX within the grid scroll area, get the half-day slot index (0-based)
|
||||
|
||||
@@ -136,9 +136,9 @@ export default function TimelineView({ reloadKey = 0 }) {
|
||||
const carColorMap = {};
|
||||
cars.forEach((car, i) => { carColorMap[car.id] = getColor(i); });
|
||||
|
||||
// Sort reservations by start_date descending (newest first) then car
|
||||
// Sort reservations by start_date then car
|
||||
const sortedReservations = [...reservations].sort((a, b) => {
|
||||
if (a.start_date !== b.start_date) return a.start_date > b.start_date ? -1 : 1;
|
||||
if (a.start_date !== b.start_date) return a.start_date < b.start_date ? -1 : 1;
|
||||
return a.car_id - b.car_id;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user