App : page de confirmation retravaillée
Pastille verte (crédit) ou dorée (récompense), texte qui apparaît en fondu, nouveau solde aux couleurs de la carte avec progression vers la prochaine récompense, boutons Fiche client / Accueil côte à côte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e7e00b9a6f
commit
0ac5dad9b2
1 changed files with 72 additions and 26 deletions
|
|
@ -3,7 +3,7 @@ import { Animated, View } from 'react-native';
|
||||||
import { router, useLocalSearchParams } from 'expo-router';
|
import { router, useLocalSearchParams } from 'expo-router';
|
||||||
import Svg, { Path } from 'react-native-svg';
|
import Svg, { Path } from 'react-native-svg';
|
||||||
import { useStore } from '../src/session';
|
import { useStore } from '../src/session';
|
||||||
import { Button, Card, Screen, T, unit } from '../src/ui';
|
import { Button, Screen, T, unit } from '../src/ui';
|
||||||
import { font, useColors } from '../src/theme';
|
import { font, useColors } from '../src/theme';
|
||||||
|
|
||||||
/** Confirmation (maquette 7) : nouveau solde, Wallet mis à jour. */
|
/** Confirmation (maquette 7) : nouveau solde, Wallet mis à jour. */
|
||||||
|
|
@ -19,39 +19,85 @@ export default function Done() {
|
||||||
Animated.spring(scale, { toValue: 1, friction: 5, useNativeDriver: true }).start();
|
Animated.spring(scale, { toValue: 1, friction: 5, useNativeDriver: true }).start();
|
||||||
}, [scale]);
|
}, [scale]);
|
||||||
|
|
||||||
|
const redeem = p.kind === 'redeem';
|
||||||
|
const balance = Number(p.balance);
|
||||||
|
// Crédit en vert, récompense en doré.
|
||||||
|
const [tint, tintBg] = redeem ? [c.warn, c.warnBg] : [c.ok, c.okBg];
|
||||||
|
const rewards = [...store.design.rewards].sort((a, b) => a.cost - b.cost);
|
||||||
|
const next = rewards.find((r) => r.cost > balance);
|
||||||
|
const ready = rewards.filter((r) => r.cost <= balance).length;
|
||||||
|
const fg = store.design.foregroundColor;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Screen noHeader style={{ alignItems: 'stretch' }}>
|
<Screen noHeader style={{ alignItems: 'stretch' }}>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<View style={{ alignItems: 'center', gap: 16 }}>
|
<View style={{ alignItems: 'center', gap: 14 }}>
|
||||||
{/* Halo + pastille de validation */}
|
{/* Halo + pastille de validation */}
|
||||||
<View style={{ width: 132, height: 132, borderRadius: 66, backgroundColor: c.okBg, alignItems: 'center', justifyContent: 'center' }}>
|
<View style={{ width: 140, height: 140, borderRadius: 70, backgroundColor: tintBg, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<Animated.View
|
<Animated.View
|
||||||
style={{ width: 96, height: 96, borderRadius: 48, backgroundColor: c.ok, alignItems: 'center', justifyContent: 'center', transform: [{ scale }] }}
|
style={{ width: 100, height: 100, borderRadius: 50, backgroundColor: tint, alignItems: 'center', justifyContent: 'center', transform: [{ scale }] }}
|
||||||
>
|
>
|
||||||
<Svg width={48} height={48} viewBox="0 0 24 24" fill="none" stroke="#fff" strokeWidth={2.6} strokeLinecap="round" strokeLinejoin="round">
|
{redeem ? (
|
||||||
|
<T style={{ fontSize: 46 }}>🎁</T>
|
||||||
|
) : (
|
||||||
|
<Svg width={50} height={50} viewBox="0 0 24 24" fill="none" stroke="#fff" strokeWidth={2.6} strokeLinecap="round" strokeLinejoin="round">
|
||||||
<Path d="M5 12.5l4.5 4.5L19 7.5" />
|
<Path d="M5 12.5l4.5 4.5L19 7.5" />
|
||||||
</Svg>
|
</Svg>
|
||||||
|
)}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</View>
|
</View>
|
||||||
|
<Animated.View style={{ alignItems: 'center', gap: 6, opacity: scale.interpolate({ inputRange: [0.4, 1], outputRange: [0, 1] }) }}>
|
||||||
<T v="h1" accessibilityRole="alert" style={{ textAlign: 'center' }}>
|
<T v="h1" accessibilityRole="alert" style={{ textAlign: 'center' }}>
|
||||||
{p.kind === 'redeem' ? `${p.reward} validé` : `+ ${n} ${unit(mode, n)}`}
|
{redeem ? `${p.reward}` : `+ ${n} ${unit(mode, n)}`}
|
||||||
</T>
|
</T>
|
||||||
<T v="muted" style={{ textAlign: 'center' }}>
|
<View style={{ paddingHorizontal: 12, paddingVertical: 4, borderRadius: 999, backgroundColor: tintBg }}>
|
||||||
{p.kind === 'redeem' ? `− ${n} ${unit(mode, n)} pour ${p.firstName}` : `pour ${p.firstName}`}
|
<T style={{ color: tint, fontFamily: font.semibold, fontSize: 14 }}>
|
||||||
|
{redeem ? `Récompense remise · − ${n} ${unit(mode, n)}` : `Crédité pour ${p.firstName}`}
|
||||||
</T>
|
</T>
|
||||||
</View>
|
</View>
|
||||||
<Card style={{ alignItems: 'center', paddingVertical: 22 }}>
|
</Animated.View>
|
||||||
<T v="muted">Nouveau solde</T>
|
</View>
|
||||||
<T style={{ fontFamily: font.extrabold, fontSize: 44, lineHeight: 50 }}>
|
|
||||||
{p.balance} <T style={{ fontSize: 20 }}>{unit(mode, Number(p.balance))}</T>
|
{/* Nouveau solde aux couleurs de la carte */}
|
||||||
|
<View style={{ backgroundColor: store.design.backgroundColor, borderRadius: 22, padding: 20, gap: 12 }}>
|
||||||
|
<View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-end' }}>
|
||||||
|
<View>
|
||||||
|
<T style={{ color: fg, opacity: 0.8, fontSize: 14 }}>Nouveau solde de {p.firstName}</T>
|
||||||
|
<T style={{ color: fg, fontFamily: font.extrabold, fontSize: 40, lineHeight: 46 }}>
|
||||||
|
{p.balance} <T style={{ color: fg, fontSize: 18 }}>{unit(mode, balance)}</T>
|
||||||
</T>
|
</T>
|
||||||
<T v="muted" style={{ fontSize: 14, textAlign: 'center' }}>Le Wallet du client est mis à jour.</T>
|
</View>
|
||||||
</Card>
|
<T style={{ color: fg, opacity: 0.8, fontSize: 12, marginBottom: 6 }}>Wallet mis à jour ✓</T>
|
||||||
|
</View>
|
||||||
|
{(next || ready > 0) && (
|
||||||
|
<View style={{ gap: 6 }}>
|
||||||
|
{next && (
|
||||||
|
<View style={{ height: 6, borderRadius: 3, backgroundColor: fg.length === 7 ? `${fg}40` : 'rgba(127,127,127,0.3)', overflow: 'hidden' }}>
|
||||||
|
<View style={{ width: `${Math.round(Math.min(balance / next.cost, 1) * 100)}%`, height: 6, borderRadius: 3, backgroundColor: c.accent }} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
<T style={{ color: fg, fontSize: 14 }}>
|
||||||
|
{ready > 0
|
||||||
|
? `${ready} récompense${ready > 1 ? 's' : ''} disponible${ready > 1 ? 's' : ''}`
|
||||||
|
: `Encore ${next!.cost - balance} ${unit(mode, next!.cost - balance)} avant « ${next!.label} »`}
|
||||||
|
</T>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Button large label="Scanner une autre carte" onPress={() => router.replace('/scan')} />
|
<Button large label="Scanner une autre carte" onPress={() => router.replace('/scan')} />
|
||||||
|
<View style={{ flexDirection: 'row', gap: 10 }}>
|
||||||
{/* Retour à la fiche du client (autre récompense, crédit…) */}
|
{/* Retour à la fiche du client (autre récompense, crédit…) */}
|
||||||
{router.canGoBack() && <Button label="Retour à la fiche client" variant="secondary" onPress={() => router.back()} />}
|
{router.canGoBack() && (
|
||||||
|
<View style={{ flex: 1 }}>
|
||||||
|
<Button label="Fiche client" variant="secondary" onPress={() => router.back()} />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
<View style={{ flex: 1 }}>
|
||||||
<Button label="Accueil" variant="secondary" onPress={() => router.dismissTo('/')} />
|
<Button label="Accueil" variant="secondary" onPress={() => router.dismissTo('/')} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue