74 lines
3.5 KiB
JavaScript
74 lines
3.5 KiB
JavaScript
// Premier lancement : pas de programme, pas de proposition en attente.
|
|
// But : un programme dans l'app en moins de deux minutes, construit avec l'IA
|
|
// de l'utilisateur (ADR 0008 ; ADR 0005, point 7 : le circuit par lien).
|
|
|
|
import { h } from "./dom.js";
|
|
import { actionBar } from "./layout.js";
|
|
import { toast } from "./feedback.js";
|
|
import { copyText } from "./files.js";
|
|
import { href } from "./router.js";
|
|
import { buildOnboardingBrief } from "../domain/ai-brief.js";
|
|
import { EXAMPLE_PROGRAM } from "../domain/example-program.js";
|
|
|
|
/** Consigne courte pour une IA qui sait lire une page web. */
|
|
export const AI_GUIDE_URL = "https://ia-fit.sans.pub/ia.md";
|
|
|
|
/**
|
|
* @param {{store: import("./store.js").Store}} o
|
|
*/
|
|
export function onboarding({ store }) {
|
|
const status = h("p", { class: "status status--ok", role: "status", "aria-live": "polite" });
|
|
const manual = h("div", { class: "manual-copy", hidden: true });
|
|
|
|
const copyBrief = async () => {
|
|
const ok = await copyText(buildOnboardingBrief({ baseUrl: location.origin }), manual, "Texte à copier dans ton IA");
|
|
status.textContent = ok ? "Copié. Colle-le dans ton IA." : "";
|
|
if (ok) toast("Texte copié.");
|
|
};
|
|
|
|
const startFromExample = () => {
|
|
store.dispatch("ProgramProposed", {
|
|
program: structuredClone(EXAMPLE_PROGRAM),
|
|
source: "example",
|
|
reason: "Programme d'exemple : trois séances à domicile avec barre, haltères, banc et élastiques. Ton IA pourra l'adapter ensuite.",
|
|
});
|
|
};
|
|
|
|
const copyGuide = async () => {
|
|
try {
|
|
await navigator.clipboard.writeText(`Lis ${AI_GUIDE_URL}`);
|
|
toast("Phrase copiée.");
|
|
} catch {
|
|
toast("Copie impossible : recopie l'adresse à la main.");
|
|
}
|
|
};
|
|
|
|
return h("div", { class: "onboarding" },
|
|
h("header", { class: "screen-head" },
|
|
h("p", { class: "kicker" }, "IA-Fit · sans compte"),
|
|
h("h1", { class: "title title--hero" }, "Ton programme. Ton IA."),
|
|
h("p", { class: "lede" }, "Elle le construit, tu le suis ici, série par série. Tes données restent sur ton appareil.")),
|
|
|
|
h("section", { class: "block", "aria-labelledby": "onb-how" },
|
|
h("h2", { class: "h2", id: "onb-how" }, "Trois gestes"),
|
|
h("ol", { class: "how" },
|
|
h("li", { class: "how__step" }, h("span", null, h("strong", null, "Copie le texte"), " et colle-le dans ton IA : Claude, ChatGPT, Le Chat…")),
|
|
h("li", { class: "how__step" }, h("span", null, h("strong", null, "Réponds à ses questions"), ", ou montre-lui ton programme actuel.")),
|
|
h("li", { class: "how__step" }, h("span", null, h("strong", null, "Touche le lien qu'elle renvoie."), " Ton programme s'affiche ici. Tu valides."))),
|
|
status,
|
|
manual,
|
|
h("p", { class: "muted" }, "Ton IA lit les pages web ? Dis-lui :"),
|
|
h("div", { class: "copy-line" },
|
|
h("code", { class: "copy-line__text" }, `lis ${AI_GUIDE_URL}`),
|
|
h("button", { type: "button", class: "btn btn--sm", on: { click: copyGuide } }, "Copier"))),
|
|
|
|
h("h2", { class: "tape" }, "Ou bien"),
|
|
h("div", { class: "btn-stack" },
|
|
h("button", { type: "button", class: "btn btn--block", on: { click: startFromExample } }, "Programme d'exemple"),
|
|
h("a", { class: "btn btn--block btn--ghost", href: href.data() }, "Restaurer une sauvegarde")),
|
|
|
|
h("p", { class: "foot" }, "Rien ne part sur un serveur. Ce que tu colles dans ton IA, c'est toi qui le choisis."),
|
|
|
|
actionBar(h("button", { type: "button", class: "btn btn--primary btn--block btn--lg", on: { click: copyBrief } }, "Créer mon programme")));
|
|
}
|