From 7cdc081227cfc542eea2df6c457a3bf59de3d6f9 Mon Sep 17 00:00:00 2001 From: Victor Bodinaud Date: Thu, 27 Feb 2025 14:52:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20rewards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 66 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/public/index.html b/public/index.html index 2740982..55a384c 100644 --- a/public/index.html +++ b/public/index.html @@ -510,6 +510,12 @@ const sortedRewards = [...data.rewards].sort((a, b) => a.price - b.price); sortedRewards.forEach(reward => { + // Récupérer le titre localisé (français par défaut, sinon anglais, sinon première langue disponible) + let rewardTitle = ''; + if (reward.title) { + rewardTitle = reward.title.fr || reward.title.en || Object.values(reward.title)[0] || ''; + } + // Calculer le pourcentage pour les récompenses limitées let percentTaken = 0; let stockText = ""; @@ -523,19 +529,19 @@ } html += ` -
-
${formatter.format(reward.price)}
-
${reward.title}
-
${reward.description}
-
- ${reward.orders_count} contributeurs - ${stockText} -
- ${reward.stock ? ` -
-
-
` : ''} -
`; +
+
${formatter.format(reward.price)}
+
${rewardTitle}
+
${reward.description}
+
+ ${reward.orders_count} contributeurs + ${stockText} +
+ ${reward.stock ? ` +
+
+
` : ''} +
`; }); html += ''; @@ -564,25 +570,47 @@ dateStr = date.toLocaleDateString('fr-FR', { year: 'numeric', month: 'short', day: 'numeric' }); } - const avatarUrl = contributor.avatar || 'https://s3-eu-west-1.amazonaws.com/com.ulule.assets/site/build/img/avatars/avatar-blue.png'; + const avatarUrl = contributor.avatar ? (contributor.avatar['90'] || '') : 'https://s3-eu-west-1.amazonaws.com/com.ulule.assets/site/build/img/avatars/avatar-blue.png'; + + // Extraire le nom de la récompense avec le format title.fr si disponible + let rewardName = ''; + if (contributor.latest_project_order && + contributor.latest_project_order.items && + contributor.latest_project_order.items.length > 0) { + + const item = contributor.latest_project_order.items[0]; + + if (item.reward && item.reward.parent && item.reward.parent.title) { + rewardName = item.reward.parent.title.fr || + item.reward.parent.title.en || + Object.values(item.reward.parent.title)[0] || ''; + + // Ajouter la variante si elle existe + if (item.reward.description_fr) { + rewardName += ` (${item.reward.description_fr})`; + } + } + } html += `
- ${contributor.name} + ${contributor.name || 'Contributeur'}
-
${contributor.name || 'Contributeur anonyme'}
- ${contributor.reward ? `
${contributor.reward}
` : ''} +
${contributor.name || contributor.screenname || 'Contributeur anonyme'}
+ ${rewardName ? `
${rewardName}
` : ''} ${contributor.location ? `
${contributor.location}
` : ''} ${dateStr ? `
Depuis le ${dateStr}
` : ''}
- ${contributor.amount ? `
${formatter.format(contributor.amount)}
` : ''} + ${contributor.latest_project_order && contributor.latest_project_order.items && contributor.latest_project_order.items[0].line_total ? + `
${formatter.format(contributor.latest_project_order.items[0].line_total)}
` : ''}
- ${contributor.comment ? `
"${contributor.comment}"
` : ''} + ${contributor.latest_project_comment && contributor.latest_project_comment.comment ? + `
"${contributor.latest_project_comment.comment}"
` : ''}
`; });