Permet de modifier l'heure de début du chrono en cours

Champ « Début » sur le timer en cours (POST /ui/timer/debut) ; le chrono
continue. Une heure dans le futur est refusée.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Romulus21andClaude Opus 5.5 committed 2026-10-26 15:49:07 +01:00
1 parent 092bc2fb3e
commit 35df6b52e8
4 files changed
+70

No files matched your search

+27
View File
@@ -29,6 +29,7 @@ pub fn router() -> Router<SqlitePool> {
.route("/ui/dernieres-entrees", get(recent_fragment))
.route("/ui/timer/start", post(start_timer))
.route("/ui/timer/stop", post(stop_timer))
.route("/ui/timer/debut", post(set_timer_start))
.route("/ui/clients", post(create_client))
.route("/ui/clients/{id}", post(save_client))
.route("/ui/clients/{id}/archive", post(archive_client))
@@ -315,6 +316,32 @@ async fn stop_timer(State(pool): State<SqlitePool>) -> PageResult {
Ok(with_entries_changed(render(timer_state(&pool).await?)?))
}
#[derive(Deserialize)]
struct TimerStartForm {
started_at: String,
}
/// Moves the start of the running timer (e.g. started a bit late).
async fn set_timer_start(
State(pool): State<SqlitePool>,
Form(f): Form<TimerStartForm>,
) -> PageResult {
let started = parse_datetime(&f.started_at, "début")?;
let running = entries::running(&pool)
.await?
.ok_or_else(|| AppError::Conflict("aucun timer en cours".into()))?;
entries::update(
&pool,
running.id,
&UpdateEntry {
started_at: Some(started.fixed_offset()),
..Default::default()
},
)
.await?;
Ok(with_entries_changed(render(timer_state(&pool).await?)?))
}
// --- Clients & projects -----------------------------------------------------
struct ClientCard {