diff --git a/pro/app/client/[serial]/index.tsx b/pro/app/client/[serial]/index.tsx index 94ddb9a..a429c2a 100644 --- a/pro/app/client/[serial]/index.tsx +++ b/pro/app/client/[serial]/index.tsx @@ -1,5 +1,5 @@ import { useState } from 'react'; -import { ActivityIndicator, Alert, View } from 'react-native'; +import { ActivityIndicator, Alert, Pressable, View } from 'react-native'; import { router } from 'expo-router'; import { useStore } from '../../../src/session'; import { useCard } from '../../../src/useCard'; @@ -28,7 +28,6 @@ export default function ClientCard() { if (!card) return ; const mode = store.design.pointsMode; - const cheapest = store.design.rewards[0]; const reachable = store.design.rewards.filter((r) => r.cost <= card.balance).length; const SOURCE = { BIRTHDAY: 'Anniversaire', REFERRAL: 'Parrainage', REFERRAL_FRIEND: 'Bienvenue (parrainage)' } as const; @@ -50,41 +49,52 @@ export default function ClientCard() { }, ]); + // Prochain palier : la première récompense pas encore atteinte (sinon la plus chère). + const sortedRewards = [...store.design.rewards].sort((a, b) => a.cost - b.cost); + const target = sortedRewards.find((r) => r.cost > card.balance) ?? sortedRewards[sortedRewards.length - 1]; + const progress = target ? Math.min(card.balance / target.cost, 1) : 0; + const fg = store.design.foregroundColor; + const memberSince = new Date(card.memberSince).toLocaleDateString('fr-FR', { month: 'short', year: 'numeric' }); + return ( - - {card.firstName} - - {card.lastCreditAt ? `Dernière visite ${ago(card.lastCreditAt)}` : 'Première visite'} · client depuis le{' '} - {new Date(card.memberSince).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' })} - + {/* En-tête : initiale, prénom, ancienneté */} + + + {card.firstName.charAt(0).toUpperCase()} + + + {card.firstName} + + {card.lastCreditAt ? `Dernière visite ${ago(card.lastCreditAt)}` : 'Première visite'} · client depuis {memberSince} + + - - SOLDE - {card.balance} - {unit(mode, card.balance)} - - - {reachable > 0 ? ( - {reachable === 1 ? '1 récompense disponible' : `${reachable} récompenses disponibles`} - ) : cheapest ? ( - - Encore {cheapest.cost - card.balance} {unit(mode, cheapest.cost - card.balance)} avant « {cheapest.label} » + {/* Carte aux couleurs du magasin : solde et progression */} + + + {store.design.programName.toUpperCase()} - ) : null} - - {card.gifts?.map((g) => ( - - - 🎁 {g.label} - - {SOURCE[g.source]} · {new Date(g.createdAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })} + + {card.balance} + {unit(mode, card.balance)} + + {target && ( + + + + + + {reachable > 0 + ? reachable === 1 + ? '1 récompense disponible' + : `${reachable} récompenses disponibles` + : `Encore ${target.cost - card.balance} ${unit(mode, target.cost - card.balance)} avant « ${target.label} »`} -