Décharge conseillée et progression par série (5d) ; journal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
74bd0851cb
commit
d0aff18d8e
@@ -17,6 +17,8 @@ import { estimatedMinutes } from "../../domain/progression.js";
|
||||
import { hud } from "../game.js";
|
||||
import { toast } from "../feedback.js";
|
||||
import { installOffer, strengthSessions } from "../install.js";
|
||||
import { DELOAD, deloadAdvice, deloadStatus } from "../../domain/deload.js";
|
||||
import { addDays } from "../../domain/dates.js";
|
||||
|
||||
/** @typedef {import("../../domain/state.js").State} State */
|
||||
/** @typedef {import("../../domain/planning.js").Slot} Slot */
|
||||
@@ -164,6 +166,7 @@ function homeContent(store, nav, today, synced) {
|
||||
hud(state, today),
|
||||
h("header", { class: "visually-hidden" }, h("h1", null, program.name)),
|
||||
todayBlock,
|
||||
deloadCard(store, today),
|
||||
installOffer("home", { hasProgram: true, sessions: strengthSessions(state) }),
|
||||
|
||||
oneOffs.length > 0 && [
|
||||
@@ -260,3 +263,51 @@ function otherActivity(store, today) {
|
||||
return h("div", null, toggle, panel);
|
||||
}
|
||||
|
||||
|
||||
/** Préférence de l'appareil : la décharge conseillée, remise à plus tard (jusqu'à cette date). */
|
||||
const DELOAD_LATER = "ia-fit.deload-later";
|
||||
|
||||
/**
|
||||
* La décharge (lot 5d) : conseillée (cycle ou fatigue), en cours, ou terminée.
|
||||
* @param {Store} store
|
||||
* @param {string} today
|
||||
* @returns {HTMLElement|null}
|
||||
*/
|
||||
export function deloadCard(store, today) {
|
||||
const state = store.getState();
|
||||
const status = deloadStatus(state, today);
|
||||
if (status) {
|
||||
const resume = () => {
|
||||
store.dispatch("ModeChanged", { mode: "progression", reason: "Fin de la semaine de décharge." });
|
||||
toast("Progression reprise.");
|
||||
};
|
||||
return h("section", { class: "block deload", "aria-labelledby": "deload-title" },
|
||||
h("p", { class: "kicker" }, status.over ? "Décharge terminée" : `Décharge · jour ${status.day} sur ${DELOAD.days}`),
|
||||
h("h2", { class: "block__title", id: "deload-title" }, status.over ? "On reprend ?" : "Semaine plus légère"),
|
||||
h("p", { class: "muted" }, status.over
|
||||
? "Ta semaine de décharge est faite : les charges reviennent à tes charges de travail."
|
||||
: "Les séances proposent 10 % de charge en moins et une série de moins par exercice."),
|
||||
h("button", { type: "button", class: status.over ? "btn btn--primary btn--block" : "btn btn--ghost btn--block", on: { click: resume } },
|
||||
status.over ? "Reprendre la progression" : "Arrêter la décharge"));
|
||||
}
|
||||
const advice = deloadAdvice(state, today);
|
||||
let later = "";
|
||||
try { later = localStorage.getItem(DELOAD_LATER) ?? ""; } catch { /* stockage indisponible : la carte reste */ }
|
||||
if (!advice || later > today) return null;
|
||||
const start = () => {
|
||||
store.dispatch("ModeChanged", { mode: "recovery", deload: true, reason: `Semaine de décharge : ${advice.text}` });
|
||||
toast("Décharge commencée pour une semaine.");
|
||||
};
|
||||
const card = h("section", { class: "block deload", "aria-labelledby": "deload-title" },
|
||||
h("p", { class: "kicker" }, "Conseil de l'app"),
|
||||
h("h2", { class: "block__title", id: "deload-title" }, "Une semaine de décharge ?"),
|
||||
h("p", null, advice.text),
|
||||
h("p", { class: "muted" }, `Pendant ${DELOAD.days} jours : 10 % de charge en moins, une série de moins par exercice. Tes charges de travail ne changent pas.`),
|
||||
h("div", { class: "btn-stack" },
|
||||
h("button", { type: "button", class: "btn btn--primary btn--block", on: { click: start } }, "Commencer la décharge"),
|
||||
h("button", { type: "button", class: "btn btn--ghost btn--block", on: { click: () => {
|
||||
try { localStorage.setItem(DELOAD_LATER, addDays(today, 7)); } catch { /* rien à garder */ }
|
||||
card.remove();
|
||||
} } }, "Pas cette semaine")));
|
||||
return card;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user