3 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
208dddeeb3 Fix schedule start date and timeline sort order
Agent-Logs-Url: https://github.com/h/CarReservation/sessions/47d2417d-06f8-4edb-95cc-c0d838df7be0

Co-authored-by: h <57948770+h@users.noreply.github.com>
2026-04-15 05:21:07 +00:00
h
b597453fac Commit 2026-04-15 13:57:56 +09:00
h
696e1b9c9f Merge pull request #8 from h/copilot/update-schedule-display-to-am-pm
スケジュール画面の横軸を午前・午後の2スロットに分割
2026-04-06 17:20:49 +09:00
3 changed files with 7 additions and 14 deletions

View File

@@ -68,7 +68,6 @@ 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);
@@ -100,17 +99,13 @@ function broadcast(message) {
});
}
function normalizeTireType(value) {
return value === 'スタットレス' ? 'スタッドレス' : value;
}
// for future use
function normalizeCar(car) {
if (!car) {
return car;
}
return {
...car,
tire_type: normalizeTireType(car.tire_type),
};
}

View File

@@ -1,5 +1,5 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import { format, addDays, startOfWeek, parseISO, differenceInDays } from 'date-fns';
import { format, addDays, 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,10 +43,8 @@ export default function ScheduleView({ reloadKey = 0 }) {
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
// The first date shown in the grid
const [viewStart, setViewStart] = useState(() =>
startOfWeek(new Date(), { weekStartsOn: 1 })
);
// The first date shown in the grid (start from today)
const [viewStart, setViewStart] = useState(() => new Date());
// Drag-to-create state
const [creating, setCreating] = useState(null);
@@ -92,7 +90,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(startOfWeek(new Date(), { weekStartsOn: 1 }));
const goToday = () => setViewStart(new Date());
// --- Grid position helpers ---
// Given a mouse clientX within the grid scroll area, get the half-day slot index (0-based)

View File

@@ -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 then car
// Sort reservations by start_date descending (newest first) 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;
});