MonEspacePro/pro/app/done.tsx
Tony AVERTY 6725358a7c App Pro (Expo) et API du comptoir avec anti-triche
- API /staff : profil, scan d'une carte, crédit (montant ou tampon),
  récompenses, historique (gérant : tout le magasin, employé : le sien),
  résumé du jour
- Anti-triche côté serveur : carte du bon magasin, plafond de montant,
  délai minimum entre deux crédits (atomique, scans simultanés compris),
  tentatives refusées journalisées avec l'employé
- App Expo SDK 54 / Expo Router : connexion, accueil, scanner QR avec
  lampe, fiche client, pavé numérique, récompenses, confirmation, erreurs,
  historique ; icônes générées depuis le logo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 12:50:59 +02:00

51 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useEffect, useRef } from 'react';
import { Animated, View } from 'react-native';
import { router, useLocalSearchParams } from 'expo-router';
import Svg, { Path } from 'react-native-svg';
import { useStore } from '../src/session';
import { Button, Card, Screen, T, unit } from '../src/ui';
import { font, useColors } from '../src/theme';
/** Confirmation (maquette 7) : nouveau solde, Wallet mis à jour. */
export default function Done() {
const c = useColors();
const store = useStore();
const p = useLocalSearchParams<{ kind: 'credit' | 'redeem'; firstName: string; points: string; balance: string; reward?: string }>();
const scale = useRef(new Animated.Value(0.4)).current;
const mode = store.design.pointsMode;
const n = Number(p.points);
useEffect(() => {
Animated.spring(scale, { toValue: 1, friction: 5, useNativeDriver: true }).start();
}, [scale]);
return (
<Screen style={{ justifyContent: 'center', alignItems: 'stretch' }}>
<View style={{ alignItems: 'center', gap: 16 }}>
<Animated.View
style={{ width: 96, height: 96, borderRadius: 48, backgroundColor: c.ok, 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">
<Path d="M5 12.5l4.5 4.5L19 7.5" />
</Svg>
</Animated.View>
<T v="h1" accessibilityRole="alert" style={{ textAlign: 'center' }}>
{p.kind === 'redeem' ? `${p.reward} validé` : `+ ${n} ${unit(mode, n)}`}
</T>
<T v="muted" style={{ textAlign: 'center' }}>
{p.kind === 'redeem' ? `− ${n} ${unit(mode, n)} pour ${p.firstName}` : `pour ${p.firstName}`}
</T>
</View>
<Card style={{ alignItems: 'center' }}>
<T v="muted">Nouveau solde</T>
<T style={{ fontFamily: font.extrabold, fontSize: 44, lineHeight: 50 }}>
{p.balance} <T style={{ fontSize: 20 }}>{unit(mode, Number(p.balance))}</T>
</T>
<T v="muted" style={{ fontSize: 14, textAlign: 'center' }}>Le Wallet du client est mis à jour.</T>
</Card>
<View style={{ flex: 1 }} />
<Button large label="Scanner une autre carte" onPress={() => router.replace('/scan')} />
<Button label="Accueil" variant="secondary" onPress={() => router.dismissTo('/')} />
</Screen>
);
}