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} »`}
-
- ))}
+ )}
+
{card.nextCreditAt && (
@@ -93,6 +103,33 @@ export default function ClientCard() {
)}
+ {/* Cadeaux en nature à remettre en caisse */}
+ {card.gifts?.length > 0 && (
+
+ Cadeaux à remettre
+ {card.gifts.map((g) => (
+
+
+ 🎁
+
+
+ {g.label}
+
+ {SOURCE[g.source]} · {new Date(g.createdAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })}
+
+
+ {giving === g.id ? (
+
+ ) : (
+ give(g)}>
+ Remettre
+
+ )}
+
+ ))}
+
+ )}
+
);
}
diff --git a/pro/app/history.tsx b/pro/app/history.tsx
index 6faebbb..03782e6 100644
--- a/pro/app/history.tsx
+++ b/pro/app/history.tsx
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
import { ActivityIndicator, FlatList, Pressable, View } from 'react-native';
import { api, Operation } from '../src/api';
import { useSession, useStore } from '../src/session';
-import { Banner, T, euros, unit } from '../src/ui';
+import { Banner, Card, T, euros, unit } from '../src/ui';
import { font, useColors } from '../src/theme';
type Period = 'today' | 'week';
@@ -51,80 +51,99 @@ export default function History() {
const mode = store.design.pointsMode;
+ // Résumé de la période (opérations chargées).
+ const done = items.filter((o) => o.type !== 'REJECTED');
+ const given = done.filter((o) => o.points > 0).reduce((n, o) => n + o.points, 0);
+ const rewards = done.filter((o) => o.type === 'REDEEM').length;
+ const dayOf = (iso: string) => new Date(iso).toLocaleDateString('fr-FR', { weekday: 'long', day: 'numeric', month: 'long' });
+
return (
-
- {(['today', 'week'] as const).map((p) => (
- setPeriod(p)}
- style={{
- height: 44,
- paddingHorizontal: 18,
- borderRadius: 22,
- justifyContent: 'center',
- backgroundColor: period === p ? c.primary : c.surface,
- borderWidth: 1,
- borderColor: period === p ? c.primary : c.border,
- }}
- >
- {p === 'today' ? "Aujourd'hui" : '7 jours'}
-
- ))}
+
+ {/* Période : contrôle segmenté */}
+
+ {(['today', 'week'] as const).map((p) => (
+ setPeriod(p)}
+ style={{ flex: 1, paddingVertical: 10, borderRadius: 10, alignItems: 'center', backgroundColor: period === p ? c.primary : 'transparent' }}
+ >
+ {p === 'today' ? "Aujourd'hui" : '7 jours'}
+
+ ))}
+
+
+ {[
+ [done.length, 'opérations'],
+ [given, `${unit(mode)} donnés`],
+ [rewards, 'récompenses'],
+ ].map(([n, l]) => (
+
+ {n}
+ {l}
+
+ ))}
+
+ {isManager ? 'Toutes les opérations du magasin' : 'Vos opérations'}
-
- {isManager ? 'Toutes les opérations du magasin' : 'Vos opérations'}
-
{error && {error}}
o.id}
- contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 32 }}
+ contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 32, gap: 8 }}
onEndReached={() => cursor && !loading && load(false)}
onEndReachedThreshold={0.5}
bounces={false}
overScrollMode="never"
- ListEmptyComponent={!loading ? Aucune opération sur la période. : null}
+ ListEmptyComponent={
+ !loading ? (
+
+ 🗒️
+ Aucune opération sur la période.
+
+ ) : null
+ }
ListFooterComponent={loading ? : null}
- ItemSeparatorComponent={() => }
- renderItem={({ item: o }) => {
+ renderItem={({ item: o, index }) => {
const rejected = o.type === 'REJECTED';
- const time = new Date(o.createdAt).toLocaleString('fr-FR', {
- ...(period === 'week' && { weekday: 'short' }),
- hour: '2-digit',
- minute: '2-digit',
- });
- const what =
- o.type === 'REDEEM'
- ? o.reward?.label ?? 'Récompense'
- : rejected
- ? REASON[o.rejectReason ?? ''] ?? 'Refusé'
- : o.amountCents
- ? euros(o.amountCents)
- : 'Passage';
+ const redeem = o.type === 'REDEEM';
+ const time = new Date(o.createdAt).toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
+ // Sur 7 jours : un intertitre à chaque nouveau jour.
+ const newDay = period === 'week' && (index === 0 || dayOf(items[index - 1].createdAt) !== dayOf(o.createdAt));
+ const what = redeem
+ ? o.reward?.label ?? 'Récompense'
+ : rejected
+ ? REASON[o.rejectReason ?? ''] ?? 'Refusé'
+ : o.amountCents
+ ? euros(o.amountCents)
+ : 'Passage';
+ const [iconBg, iconFg, icon] = rejected ? [c.errBg, c.err, '!'] : redeem ? [c.warnBg, c.warn, '★'] : [c.okBg, c.ok, '+'];
return (
-
-
- {time}
-
-
- {o.customerFirstName}
-
- {what}
- {isManager ? ` · ${o.staff.displayName}` : ''}
+
+ {newDay && (
+
+ {dayOf(o.createdAt)}
-
- 0 ? c.ok : c.text,
- }}
- >
- {rejected ? '—' : `${o.points > 0 ? '+' : '−'}${Math.abs(o.points)} ${unit(mode, Math.abs(o.points)).slice(0, 3)}.`}
-
+ )}
+
+
+ {icon}
+
+
+ {o.customerFirstName}
+
+ {time} · {what}
+ {isManager ? ` · ${o.staff.displayName}` : ''}
+
+
+ 0 ? c.okBg : c.warnBg }}>
+ 0 ? c.ok : c.warn }}>
+ {rejected ? '—' : `${o.points > 0 ? '+' : '−'}${Math.abs(o.points)}`}
+
+
+
);
}}