diff --git a/pro/app/client/[serial]/rewards.tsx b/pro/app/client/[serial]/rewards.tsx index fce4c86..21d0dc3 100644 --- a/pro/app/client/[serial]/rewards.tsx +++ b/pro/app/client/[serial]/rewards.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { ActivityIndicator, Alert, Pressable, View } from 'react-native'; +import { ActivityIndicator, Alert, Pressable, StyleSheet, View } from 'react-native'; import { router } from 'expo-router'; import * as Haptics from 'expo-haptics'; import { api, Reward } from '../../../src/api'; @@ -50,44 +50,92 @@ export default function Rewards() { const sorted = [...store.design.rewards].sort((a, b) => Number(b.cost <= card.balance) - Number(a.cost <= card.balance) || a.cost - b.cost); + const available = sorted.filter((r) => r.cost <= card.balance); + const later = sorted.filter((r) => r.cost > card.balance); + + const item = (r: Reward) => { + const ok = r.cost <= card.balance; + const progress = Math.min(card.balance / r.cost, 1); + return ( + confirm(r)} + style={({ pressed }) => ({ + padding: 16, + borderRadius: 18, + borderWidth: ok ? 2 : StyleSheet.hairlineWidth, + borderColor: ok ? c.primary : c.border, + backgroundColor: ok ? (pressed ? c.primarySoft : c.surface) : c.surface, + gap: 10, + opacity: ok ? 1 : 0.75, + })} + > + + + {ok ? '🎁' : '🔒'} + + + {r.label} + + {r.cost} {unit(mode, r.cost)} + {!ok && ` · encore ${r.cost - card.balance}`} + + + {busy === r.id ? ( + + ) : ( + ok && ( + + Utiliser + + ) + )} + + {/* Progression vers une récompense pas encore atteinte */} + {!ok && ( + + + + )} + + ); + }; + return ( - - Solde de {card.firstName} : {card.balance} {unit(mode, card.balance)} - - - {sorted.map((r) => { - const ok = r.cost <= card.balance; - return ( - confirm(r)} - style={({ pressed }) => ({ - minHeight: 72, - padding: 16, - borderRadius: 16, - borderWidth: ok ? 2 : 1, - borderColor: ok ? c.primary : c.border, - backgroundColor: ok ? (pressed ? c.primarySoft : c.surface) : c.surface2, - flexDirection: 'row', - alignItems: 'center', - gap: 12, - })} - > - - {r.label} - - {ok ? `${r.cost} ${unit(mode, r.cost)}` : `Encore ${r.cost - card.balance} ${unit(mode, r.cost - card.balance)}`} - - - {busy === r.id ? : ok && Utiliser} - - ); - })} + {/* Solde du client aux couleurs de la carte */} + + + Solde de {card.firstName} + + {card.balance} {unit(mode, card.balance)} + + + ⭐ + + {available.length > 0 ? ( + + Disponibles + {available.map(item)} + + ) : ( + + ⏳ + Aucune récompense disponible pour l'instant. + + )} + + {later.length > 0 && ( + + Prochainement + {later.map(item)} + + )} +