diff --git a/public/index.html b/public/index.html index 2740982..628d6ef 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,25 +529,24 @@ } 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 += ''; rewardsContainer.innerHTML = html; } - function updateContributors(data) { if (!data.contributors || data.contributors.length === 0) { contributorsContainer.innerHTML = '

Aucun contributeur trouvé ou impossible de récupérer la liste.

'; @@ -564,9 +569,77 @@ 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 || 'Contributeur'} +
+
${contributor.name || contributor.screenname || 'Contributeur anonyme'}
+ ${rewardName ? `
${rewardName}
` : ''} + ${contributor.location ? `
${contributor.location}
` : ''} + ${dateStr ? `
Depuis le ${dateStr}
` : ''} +
+
+
+ ${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.latest_project_comment && contributor.latest_project_comment.comment ? + `
"${contributor.latest_project_comment.comment}"
` : ''} +
`; + }); + + contributorsContainer.innerHTML = html; + } + + if (!data.contributors || data.contributors.length === 0) { + contributorsContainer.innerHTML = '

Aucun contributeur trouvé ou impossible de récupérer la liste.

'; + return; + } + + const formatter = new Intl.NumberFormat('fr-FR', { + style: 'currency', + currency: 'EUR', + maximumFractionDigits: 0 + }); + + let html = ''; + + data.contributors.forEach(contributor => { + // Formater la date si elle existe + let dateStr = ''; + if (contributor.date_joined) { + const date = new Date(contributor.date_joined); + 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'; + + html += `
@@ -584,9 +657,9 @@
${contributor.comment ? `
"${contributor.comment}"
` : ''}
`; - }); + }); - contributorsContainer.innerHTML = html; + contributorsContainer.innerHTML = html; } // Fonction pour charger toutes les données