add more stats to mobile profile

This commit is contained in:
larssand
2026-09-04 16:17:45 +02:00
parent 142c45be04
commit 4068cc7c19
13 changed files with 267 additions and 22 deletions

View File

@@ -449,6 +449,15 @@ export function renderTrainingView(deps) {
</div>
<div class="training-share-compact">
<p>${escapeHtml(t("training.public_profile_help"))}</p>
${profileShare ? `
<fieldset class="training-share-sections">
<legend>${escapeHtml(t("training.public_sections"))}</legend>
<p class="hint">${escapeHtml(t("training.public_sections_hint"))}</p>
${["progress", "achievements", "performance", "goals", "history"].map((section) => `
<label><input type="checkbox" data-public-training-section="${section}" ${profileShare.visibility?.[section] !== false ? "checked" : ""} /> ${escapeHtml(t(`training.public_section_${section}`))}</label>
`).join("")}
</fieldset>
` : ""}
<label class="training-share-url">
<span>${escapeHtml(t("training.public_base_url"))}</span>
<input id="trainingPublicBaseUrl" type="url" value="${escapeHtml(publicBaseUrl)}" placeholder="https://training.example.se" />
@@ -754,6 +763,17 @@ export function renderTrainingView(deps) {
await syncStateToBackend();
renderView();
});
document.querySelectorAll("[data-public-training-section]").forEach((input) => {
input.addEventListener("change", async () => {
const section = String(input.dataset.publicTrainingSection || "");
state.training.shares = state.training.shares.map((share) => {
if (!profileReferences.has(String(share.driverId || ""))) return share;
return { ...share, visibility: { ...(share.visibility || {}), [section]: input.checked } };
});
saveState();
await syncStateToBackend();
});
});
document.querySelectorAll(".training-club-driver").forEach((button) => {
button.addEventListener("click", () => {
setSelectedDriverId(button.dataset.driverId || "");
@@ -1022,11 +1042,13 @@ function generateShareToken() {
}
function replacePublicProfileShare(state, driverId, profileReferences = new Set([driverId])) {
const previous = state.training.shares.find((share) => profileReferences.has(String(share.driverId || "")));
const nextShare = {
driverId,
token: generateShareToken(),
enabled: true,
createdAt: new Date().toISOString(),
visibility: previous?.visibility || { progress: true, achievements: true, performance: true, goals: true, history: true },
};
state.training.shares = [...state.training.shares.filter((share) => !profileReferences.has(String(share.driverId || ""))), nextShare];
}