Compare commits
No commits in common. "53a598080e600cce4c7bad01f7c206cefb14f9b2" and "cc7357b3cf170fb5ead63b4f937920b53c616280" have entirely different histories.
53a598080e
...
cc7357b3cf
8 changed files with 109 additions and 202 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { ActivityIndicator, Alert, Pressable, View } from 'react-native';
|
import { ActivityIndicator, Alert, View } from 'react-native';
|
||||||
import { router } from 'expo-router';
|
import { router } from 'expo-router';
|
||||||
import { useStore } from '../../../src/session';
|
import { useStore } from '../../../src/session';
|
||||||
import { useCard } from '../../../src/useCard';
|
import { useCard } from '../../../src/useCard';
|
||||||
|
|
@ -28,6 +28,7 @@ export default function ClientCard() {
|
||||||
if (!card) return <Screen style={{ justifyContent: 'center' }}><ActivityIndicator /></Screen>;
|
if (!card) return <Screen style={{ justifyContent: 'center' }}><ActivityIndicator /></Screen>;
|
||||||
|
|
||||||
const mode = store.design.pointsMode;
|
const mode = store.design.pointsMode;
|
||||||
|
const cheapest = store.design.rewards[0];
|
||||||
const reachable = store.design.rewards.filter((r) => r.cost <= card.balance).length;
|
const reachable = store.design.rewards.filter((r) => r.cost <= card.balance).length;
|
||||||
const SOURCE = { BIRTHDAY: 'Anniversaire', REFERRAL: 'Parrainage', REFERRAL_FRIEND: 'Bienvenue (parrainage)' } as const;
|
const SOURCE = { BIRTHDAY: 'Anniversaire', REFERRAL: 'Parrainage', REFERRAL_FRIEND: 'Bienvenue (parrainage)' } as const;
|
||||||
|
|
||||||
|
|
@ -49,52 +50,41 @@ 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 (
|
return (
|
||||||
<Screen scroll>
|
<Screen scroll>
|
||||||
{/* En-tête : initiale, prénom, ancienneté */}
|
<View style={{ gap: 4 }}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 14 }}>
|
<T v="h1">{card.firstName}</T>
|
||||||
<View style={{ width: 56, height: 56, borderRadius: 28, backgroundColor: c.primarySoft, alignItems: 'center', justifyContent: 'center' }}>
|
<T v="muted">
|
||||||
<T style={{ fontFamily: font.extrabold, fontSize: 24, color: c.primary }}>{card.firstName.charAt(0).toUpperCase()}</T>
|
{card.lastCreditAt ? `Dernière visite ${ago(card.lastCreditAt)}` : 'Première visite'} · client depuis le{' '}
|
||||||
</View>
|
{new Date(card.memberSince).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' })}
|
||||||
<View style={{ flex: 1, gap: 2 }}>
|
</T>
|
||||||
<T v="h1" numberOfLines={1}>{card.firstName}</T>
|
|
||||||
<T v="muted" style={{ fontSize: 14 }}>
|
|
||||||
{card.lastCreditAt ? `Dernière visite ${ago(card.lastCreditAt)}` : 'Première visite'} · client depuis {memberSince}
|
|
||||||
</T>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Carte aux couleurs du magasin : solde et progression */}
|
<Card style={{ alignItems: 'center', paddingVertical: 28, backgroundColor: store.design.backgroundColor, borderColor: store.design.backgroundColor }}>
|
||||||
<View style={{ backgroundColor: store.design.backgroundColor, borderRadius: 22, padding: 22, gap: 14 }}>
|
<T style={{ color: store.design.foregroundColor, fontFamily: font.semibold, fontSize: 14, letterSpacing: 1 }}>SOLDE</T>
|
||||||
<T style={{ color: fg, opacity: 0.8, fontFamily: font.semibold, fontSize: 13, letterSpacing: 1 }} numberOfLines={1}>
|
<T v="big" style={{ color: store.design.foregroundColor }}>{card.balance}</T>
|
||||||
{store.design.programName.toUpperCase()}
|
<T style={{ color: store.design.foregroundColor, fontSize: 16 }}>{unit(mode, card.balance)}</T>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{reachable > 0 ? (
|
||||||
|
<Banner tone="ok">{reachable === 1 ? '1 récompense disponible' : `${reachable} récompenses disponibles`}</Banner>
|
||||||
|
) : cheapest ? (
|
||||||
|
<T v="muted" style={{ textAlign: 'center' }}>
|
||||||
|
Encore {cheapest.cost - card.balance} {unit(mode, cheapest.cost - card.balance)} avant « {cheapest.label} »
|
||||||
</T>
|
</T>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'flex-end', gap: 8 }}>
|
) : null}
|
||||||
<T v="big" style={{ color: fg }}>{card.balance}</T>
|
|
||||||
<T style={{ color: fg, fontFamily: font.semibold, fontSize: 18, marginBottom: 10 }}>{unit(mode, card.balance)}</T>
|
{card.gifts?.map((g) => (
|
||||||
</View>
|
<Card key={g.id} style={{ padding: 14, gap: 10, borderColor: c.ok }}>
|
||||||
{target && (
|
<View style={{ gap: 2 }}>
|
||||||
<View style={{ gap: 8 }}>
|
<T v="label">🎁 {g.label}</T>
|
||||||
<View style={{ height: 8, borderRadius: 4, backgroundColor: fg.length === 7 ? `${fg}40` : 'rgba(127,127,127,0.3)', overflow: 'hidden' }}>
|
<T v="muted" style={{ fontSize: 13 }}>
|
||||||
<View style={{ width: `${Math.round(progress * 100)}%`, height: 8, borderRadius: 4, backgroundColor: c.accent }} />
|
{SOURCE[g.source]} · {new Date(g.createdAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })}
|
||||||
</View>
|
|
||||||
<T style={{ color: fg, fontSize: 14 }}>
|
|
||||||
{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} »`}
|
|
||||||
</T>
|
</T>
|
||||||
</View>
|
</View>
|
||||||
)}
|
<Button label="Marquer comme remis" variant="secondary" loading={giving === g.id} onPress={() => give(g)} />
|
||||||
</View>
|
</Card>
|
||||||
|
))}
|
||||||
|
|
||||||
{card.nextCreditAt && (
|
{card.nextCreditAt && (
|
||||||
<Banner tone="warn">
|
<Banner tone="warn">
|
||||||
|
|
@ -103,33 +93,6 @@ export default function ClientCard() {
|
||||||
</Banner>
|
</Banner>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Cadeaux en nature à remettre en caisse */}
|
|
||||||
{card.gifts?.length > 0 && (
|
|
||||||
<View style={{ gap: 10 }}>
|
|
||||||
<T v="h2">Cadeaux à remettre</T>
|
|
||||||
{card.gifts.map((g) => (
|
|
||||||
<Card key={g.id} style={{ padding: 14, flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
|
||||||
<View style={{ width: 44, height: 44, borderRadius: 22, backgroundColor: c.warnBg, alignItems: 'center', justifyContent: 'center' }}>
|
|
||||||
<T style={{ fontSize: 22 }}>🎁</T>
|
|
||||||
</View>
|
|
||||||
<View style={{ flex: 1, gap: 2 }}>
|
|
||||||
<T v="label">{g.label}</T>
|
|
||||||
<T v="muted" style={{ fontSize: 13 }}>
|
|
||||||
{SOURCE[g.source]} · {new Date(g.createdAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' })}
|
|
||||||
</T>
|
|
||||||
</View>
|
|
||||||
{giving === g.id ? (
|
|
||||||
<ActivityIndicator />
|
|
||||||
) : (
|
|
||||||
<Pressable accessibilityRole="button" hitSlop={8} onPress={() => give(g)}>
|
|
||||||
<T style={{ color: c.primary, fontFamily: font.bold }}>Remettre</T>
|
|
||||||
</Pressable>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Button
|
<Button
|
||||||
large
|
large
|
||||||
|
|
@ -137,12 +100,12 @@ export default function ClientCard() {
|
||||||
onPress={() => router.push({ pathname: '/client/[serial]/credit', params: { serial } })}
|
onPress={() => router.push({ pathname: '/client/[serial]/credit', params: { serial } })}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
label={reachable > 0 ? 'Utiliser une récompense' : 'Voir les récompenses'}
|
label="Utiliser une récompense"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
disabled={store.design.rewards.length === 0}
|
disabled={store.design.rewards.length === 0}
|
||||||
onPress={() => router.push({ pathname: '/client/[serial]/rewards', params: { serial } })}
|
onPress={() => router.push({ pathname: '/client/[serial]/rewards', params: { serial } })}
|
||||||
/>
|
/>
|
||||||
<T v="muted" style={{ textAlign: 'center', fontSize: 12 }}>Carte {serial}</T>
|
<T v="muted" style={{ textAlign: 'center', color: c.text3, fontSize: 13 }}>Carte {serial}</T>
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { api, Reward } from '../../../src/api';
|
||||||
import { useStore } from '../../../src/session';
|
import { useStore } from '../../../src/session';
|
||||||
import { useCard } from '../../../src/useCard';
|
import { useCard } from '../../../src/useCard';
|
||||||
import { ErrorScreen } from '../../../src/errors';
|
import { ErrorScreen } from '../../../src/errors';
|
||||||
import { Button, Screen, T, unit } from '../../../src/ui';
|
import { Screen, T, unit } from '../../../src/ui';
|
||||||
import { font, useColors } from '../../../src/theme';
|
import { font, useColors } from '../../../src/theme';
|
||||||
|
|
||||||
/** Choix d'une récompense (maquette 6) : les accessibles d'abord, les autres grisées. */
|
/** Choix d'une récompense (maquette 6) : les accessibles d'abord, les autres grisées. */
|
||||||
|
|
@ -88,8 +88,6 @@ export default function Rewards() {
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Button label="Retour" variant="secondary" onPress={() => router.back()} />
|
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,8 @@ export default function Done() {
|
||||||
}, [scale]);
|
}, [scale]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Screen noHeader style={{ alignItems: 'stretch' }}>
|
<Screen style={{ justifyContent: 'center', alignItems: 'stretch' }}>
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<View style={{ alignItems: 'center', gap: 16 }}>
|
<View style={{ alignItems: 'center', gap: 16 }}>
|
||||||
{/* Halo + pastille de validation */}
|
|
||||||
<View style={{ width: 132, height: 132, borderRadius: 66, backgroundColor: c.okBg, 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: 96, height: 96, borderRadius: 48, backgroundColor: c.ok, alignItems: 'center', justifyContent: 'center', transform: [{ scale }] }}
|
||||||
>
|
>
|
||||||
|
|
@ -32,7 +29,6 @@ export default function Done() {
|
||||||
<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>
|
|
||||||
<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)}`}
|
{p.kind === 'redeem' ? `${p.reward} validé` : `+ ${n} ${unit(mode, n)}`}
|
||||||
</T>
|
</T>
|
||||||
|
|
@ -40,7 +36,7 @@ export default function Done() {
|
||||||
{p.kind === 'redeem' ? `− ${n} ${unit(mode, n)} pour ${p.firstName}` : `pour ${p.firstName}`}
|
{p.kind === 'redeem' ? `− ${n} ${unit(mode, n)} pour ${p.firstName}` : `pour ${p.firstName}`}
|
||||||
</T>
|
</T>
|
||||||
</View>
|
</View>
|
||||||
<Card style={{ alignItems: 'center', paddingVertical: 22 }}>
|
<Card style={{ alignItems: 'center' }}>
|
||||||
<T v="muted">Nouveau solde</T>
|
<T v="muted">Nouveau solde</T>
|
||||||
<T style={{ fontFamily: font.extrabold, fontSize: 44, lineHeight: 50 }}>
|
<T style={{ fontFamily: font.extrabold, fontSize: 44, lineHeight: 50 }}>
|
||||||
{p.balance} <T style={{ fontSize: 20 }}>{unit(mode, Number(p.balance))}</T>
|
{p.balance} <T style={{ fontSize: 20 }}>{unit(mode, Number(p.balance))}</T>
|
||||||
|
|
@ -49,8 +45,6 @@ export default function Done() {
|
||||||
</Card>
|
</Card>
|
||||||
<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')} />
|
||||||
{/* Retour à la fiche du client (autre récompense, crédit…) */}
|
|
||||||
{router.canGoBack() && <Button label="Retour à la fiche client" variant="secondary" onPress={() => router.back()} />}
|
|
||||||
<Button label="Accueil" variant="secondary" onPress={() => router.dismissTo('/')} />
|
<Button label="Accueil" variant="secondary" onPress={() => router.dismissTo('/')} />
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
|
||||||
import { ActivityIndicator, FlatList, Pressable, View } from 'react-native';
|
import { ActivityIndicator, FlatList, Pressable, View } from 'react-native';
|
||||||
import { api, Operation } from '../src/api';
|
import { api, Operation } from '../src/api';
|
||||||
import { useSession, useStore } from '../src/session';
|
import { useSession, useStore } from '../src/session';
|
||||||
import { Banner, Card, T, euros, unit } from '../src/ui';
|
import { Banner, T, euros, unit } from '../src/ui';
|
||||||
import { font, useColors } from '../src/theme';
|
import { font, useColors } from '../src/theme';
|
||||||
|
|
||||||
type Period = 'today' | 'week';
|
type Period = 'today' | 'week';
|
||||||
|
|
@ -51,99 +51,80 @@ export default function History() {
|
||||||
|
|
||||||
const mode = store.design.pointsMode;
|
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 (
|
return (
|
||||||
<View style={{ flex: 1, backgroundColor: c.bg }}>
|
<View style={{ flex: 1, backgroundColor: c.bg }}>
|
||||||
<View style={{ padding: 16, paddingBottom: 8, gap: 12 }}>
|
<View style={{ flexDirection: 'row', gap: 8, padding: 16, paddingBottom: 8 }}>
|
||||||
{/* Période : contrôle segmenté */}
|
{(['today', 'week'] as const).map((p) => (
|
||||||
<View accessibilityRole="tablist" style={{ flexDirection: 'row', backgroundColor: c.surface, borderRadius: 14, padding: 4, borderWidth: 1, borderColor: c.border }}>
|
<Pressable
|
||||||
{(['today', 'week'] as const).map((p) => (
|
key={p}
|
||||||
<Pressable
|
accessibilityRole="button"
|
||||||
key={p}
|
accessibilityState={{ selected: period === p }}
|
||||||
accessibilityRole="tab"
|
onPress={() => setPeriod(p)}
|
||||||
accessibilityState={{ selected: period === p }}
|
style={{
|
||||||
onPress={() => setPeriod(p)}
|
height: 44,
|
||||||
style={{ flex: 1, paddingVertical: 10, borderRadius: 10, alignItems: 'center', backgroundColor: period === p ? c.primary : 'transparent' }}
|
paddingHorizontal: 18,
|
||||||
>
|
borderRadius: 22,
|
||||||
<T style={{ fontFamily: font.bold, fontSize: 15, color: period === p ? c.onPrimary : c.text }}>{p === 'today' ? "Aujourd'hui" : '7 jours'}</T>
|
justifyContent: 'center',
|
||||||
</Pressable>
|
backgroundColor: period === p ? c.primary : c.surface,
|
||||||
))}
|
borderWidth: 1,
|
||||||
</View>
|
borderColor: period === p ? c.primary : c.border,
|
||||||
<View style={{ flexDirection: 'row', gap: 10 }}>
|
}}
|
||||||
{[
|
>
|
||||||
[done.length, 'opérations'],
|
<T style={{ fontFamily: font.semibold, color: period === p ? c.onPrimary : c.text }}>{p === 'today' ? "Aujourd'hui" : '7 jours'}</T>
|
||||||
[given, `${unit(mode)} donnés`],
|
</Pressable>
|
||||||
[rewards, 'récompenses'],
|
))}
|
||||||
].map(([n, l]) => (
|
|
||||||
<View key={String(l)} style={{ flex: 1, backgroundColor: c.primarySoft, borderRadius: 14, paddingVertical: 10, paddingHorizontal: 12 }}>
|
|
||||||
<T style={{ fontFamily: font.extrabold, fontSize: 20, color: c.primary }}>{n}</T>
|
|
||||||
<T v="muted" style={{ fontSize: 12 }}>{l}</T>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
<T v="muted" style={{ fontSize: 13 }}>{isManager ? 'Toutes les opérations du magasin' : 'Vos opérations'}</T>
|
|
||||||
</View>
|
</View>
|
||||||
|
<T v="muted" style={{ paddingHorizontal: 16, paddingBottom: 8 }}>
|
||||||
|
{isManager ? 'Toutes les opérations du magasin' : 'Vos opérations'}
|
||||||
|
</T>
|
||||||
{error && <View style={{ paddingHorizontal: 16 }}><Banner tone="error">{error}</Banner></View>}
|
{error && <View style={{ paddingHorizontal: 16 }}><Banner tone="error">{error}</Banner></View>}
|
||||||
<FlatList
|
<FlatList
|
||||||
data={items}
|
data={items}
|
||||||
keyExtractor={(o) => o.id}
|
keyExtractor={(o) => o.id}
|
||||||
contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 32, gap: 8 }}
|
contentContainerStyle={{ paddingHorizontal: 16, paddingBottom: 32 }}
|
||||||
onEndReached={() => cursor && !loading && load(false)}
|
onEndReached={() => cursor && !loading && load(false)}
|
||||||
onEndReachedThreshold={0.5}
|
onEndReachedThreshold={0.5}
|
||||||
bounces={false}
|
bounces={false}
|
||||||
overScrollMode="never"
|
overScrollMode="never"
|
||||||
ListEmptyComponent={
|
ListEmptyComponent={!loading ? <T v="muted" style={{ textAlign: 'center', marginTop: 40 }}>Aucune opération sur la période.</T> : null}
|
||||||
!loading ? (
|
|
||||||
<View style={{ alignItems: 'center', marginTop: 48, gap: 6 }}>
|
|
||||||
<T style={{ fontSize: 36 }}>🗒️</T>
|
|
||||||
<T v="muted" style={{ textAlign: 'center' }}>Aucune opération sur la période.</T>
|
|
||||||
</View>
|
|
||||||
) : null
|
|
||||||
}
|
|
||||||
ListFooterComponent={loading ? <ActivityIndicator style={{ margin: 16 }} /> : null}
|
ListFooterComponent={loading ? <ActivityIndicator style={{ margin: 16 }} /> : null}
|
||||||
renderItem={({ item: o, index }) => {
|
ItemSeparatorComponent={() => <View style={{ height: 1, backgroundColor: c.border }} />}
|
||||||
|
renderItem={({ item: o }) => {
|
||||||
const rejected = o.type === 'REJECTED';
|
const rejected = o.type === 'REJECTED';
|
||||||
const redeem = o.type === 'REDEEM';
|
const time = new Date(o.createdAt).toLocaleString('fr-FR', {
|
||||||
const time = new Date(o.createdAt).toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit' });
|
...(period === 'week' && { weekday: 'short' }),
|
||||||
// Sur 7 jours : un intertitre à chaque nouveau jour.
|
hour: '2-digit',
|
||||||
const newDay = period === 'week' && (index === 0 || dayOf(items[index - 1].createdAt) !== dayOf(o.createdAt));
|
minute: '2-digit',
|
||||||
const what = redeem
|
});
|
||||||
? o.reward?.label ?? 'Récompense'
|
const what =
|
||||||
: rejected
|
o.type === 'REDEEM'
|
||||||
? REASON[o.rejectReason ?? ''] ?? 'Refusé'
|
? o.reward?.label ?? 'Récompense'
|
||||||
: o.amountCents
|
: rejected
|
||||||
? euros(o.amountCents)
|
? REASON[o.rejectReason ?? ''] ?? 'Refusé'
|
||||||
: 'Passage';
|
: o.amountCents
|
||||||
const [iconBg, iconFg, icon] = rejected ? [c.errBg, c.err, '!'] : redeem ? [c.warnBg, c.warn, '★'] : [c.okBg, c.ok, '+'];
|
? euros(o.amountCents)
|
||||||
|
: 'Passage';
|
||||||
return (
|
return (
|
||||||
<View style={{ gap: 8 }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 14 }}>
|
||||||
{newDay && (
|
<View style={{ width: 54 }}>
|
||||||
<T v="label" style={{ marginTop: index === 0 ? 0 : 10, color: c.text3, textTransform: 'capitalize' }}>
|
<T v="muted" style={{ fontSize: 14 }}>{time}</T>
|
||||||
{dayOf(o.createdAt)}
|
</View>
|
||||||
|
<View style={{ flex: 1, gap: 2 }}>
|
||||||
|
<T v="label" numberOfLines={1}>{o.customerFirstName}</T>
|
||||||
|
<T v="muted" numberOfLines={1} style={{ fontSize: 14, color: rejected ? c.err : c.text3 }}>
|
||||||
|
{what}
|
||||||
|
{isManager ? ` · ${o.staff.displayName}` : ''}
|
||||||
</T>
|
</T>
|
||||||
)}
|
</View>
|
||||||
<Card style={{ flexDirection: 'row', alignItems: 'center', gap: 12, padding: 12, opacity: rejected ? 0.85 : 1 }}>
|
<T
|
||||||
<View style={{ width: 40, height: 40, borderRadius: 20, backgroundColor: iconBg, alignItems: 'center', justifyContent: 'center' }}>
|
style={{
|
||||||
<T style={{ fontFamily: font.extrabold, fontSize: 18, color: iconFg }}>{icon}</T>
|
fontFamily: font.bold,
|
||||||
</View>
|
fontSize: 17,
|
||||||
<View style={{ flex: 1, gap: 2 }}>
|
color: rejected ? c.text3 : o.points > 0 ? c.ok : c.text,
|
||||||
<T v="label" numberOfLines={1}>{o.customerFirstName}</T>
|
}}
|
||||||
<T v="muted" numberOfLines={1} style={{ fontSize: 13, color: rejected ? c.err : c.text3 }}>
|
>
|
||||||
{time} · {what}
|
{rejected ? '—' : `${o.points > 0 ? '+' : '−'}${Math.abs(o.points)} ${unit(mode, Math.abs(o.points)).slice(0, 3)}.`}
|
||||||
{isManager ? ` · ${o.staff.displayName}` : ''}
|
</T>
|
||||||
</T>
|
|
||||||
</View>
|
|
||||||
<View style={{ paddingHorizontal: 10, paddingVertical: 4, borderRadius: 999, backgroundColor: rejected ? c.surface2 : o.points > 0 ? c.okBg : c.warnBg }}>
|
|
||||||
<T style={{ fontFamily: font.bold, fontSize: 15, color: rejected ? c.text3 : o.points > 0 ? c.ok : c.warn }}>
|
|
||||||
{rejected ? '—' : `${o.points > 0 ? '+' : '−'}${Math.abs(o.points)}`}
|
|
||||||
</T>
|
|
||||||
</View>
|
|
||||||
</Card>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -87,9 +87,9 @@ function Counter() {
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
|
||||||
<BrandSymbol size={36} />
|
<BrandSymbol size={36} />
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<T v="h2" numberOfLines={1}>{store.name}</T>
|
<T v="label" numberOfLines={1}>{store.name}</T>
|
||||||
<T v="muted" numberOfLines={1}>
|
<T v="muted" numberOfLines={1}>
|
||||||
Bonjour {me?.displayName.split(' ')[0]} · {isManager ? 'Dirigeant' : 'Employé'}
|
{me?.displayName} · {isManager ? 'Dirigeant' : 'Employé'}
|
||||||
</T>
|
</T>
|
||||||
</View>
|
</View>
|
||||||
<Pressable
|
<Pressable
|
||||||
|
|
@ -158,8 +158,8 @@ function Counter() {
|
||||||
[summary?.pointsGiven ?? '—', `${u} donnés`],
|
[summary?.pointsGiven ?? '—', `${u} donnés`],
|
||||||
[summary?.rewards ?? '—', 'récompenses'],
|
[summary?.rewards ?? '—', 'récompenses'],
|
||||||
].map(([n, l]) => (
|
].map(([n, l]) => (
|
||||||
<Card key={String(l)} style={{ flex: 1, padding: 14, gap: 2, backgroundColor: c.primarySoft, borderColor: c.primarySoft }}>
|
<Card key={String(l)} style={{ flex: 1, padding: 14, gap: 2 }}>
|
||||||
<T style={{ fontFamily: font.extrabold, fontSize: 26, color: c.primary }}>{n}</T>
|
<T style={{ fontFamily: font.extrabold, fontSize: 26 }}>{n}</T>
|
||||||
<T v="muted" style={{ fontSize: 13 }}>{l}</T>
|
<T v="muted" style={{ fontSize: 13 }}>{l}</T>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export default function Scan() {
|
||||||
if (!permission) return null;
|
if (!permission) return null;
|
||||||
if (!permission.granted) {
|
if (!permission.granted) {
|
||||||
return (
|
return (
|
||||||
<Screen noHeader style={{ justifyContent: 'center' }}>
|
<Screen style={{ justifyContent: 'center' }}>
|
||||||
<T v="h1">Accès à la caméra</T>
|
<T v="h1">Accès à la caméra</T>
|
||||||
<T v="muted">La caméra sert uniquement à lire le QR code de la carte de fidélité du client.</T>
|
<T v="muted">La caméra sert uniquement à lire le QR code de la carte de fidélité du client.</T>
|
||||||
{permission.canAskAgain ? (
|
{permission.canAskAgain ? (
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,11 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import Svg, { Circle, Path } from 'react-native-svg';
|
import Svg, { Circle, Path } from 'react-native-svg';
|
||||||
import { font, useColors } from './theme';
|
import { font, useColors } from './theme';
|
||||||
|
|
||||||
/**
|
export function Screen({ children, scroll = false, style }: { children: ReactNode; scroll?: boolean; style?: ViewStyle }) {
|
||||||
* Écran standard. `noHeader` : écran sans barre de titre, le contenu reste sous
|
|
||||||
* la Dynamic Island / l'encoche (marge haute de sécurité).
|
|
||||||
*/
|
|
||||||
export function Screen({ children, scroll = false, style, noHeader = false }: { children: ReactNode; scroll?: boolean; style?: ViewStyle; noHeader?: boolean }) {
|
|
||||||
const c = useColors();
|
const c = useColors();
|
||||||
const inner = <View style={[{ padding: 20, gap: 20, flexGrow: 1 }, style]}>{children}</View>;
|
const inner = <View style={[{ padding: 20, gap: 20, flexGrow: 1 }, style]}>{children}</View>;
|
||||||
return (
|
return (
|
||||||
<SafeAreaView style={{ flex: 1, backgroundColor: c.bg }} edges={noHeader ? ['top', 'bottom', 'left', 'right'] : ['bottom', 'left', 'right']}>
|
<SafeAreaView style={{ flex: 1, backgroundColor: c.bg }} edges={['bottom', 'left', 'right']}>
|
||||||
{scroll ? <ScrollView contentContainerStyle={{ flexGrow: 1 }}>{inner}</ScrollView> : inner}
|
{scroll ? <ScrollView contentContainerStyle={{ flexGrow: 1 }}>{inner}</ScrollView> : inner}
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
|
|
@ -83,29 +79,7 @@ export function Button({
|
||||||
|
|
||||||
export function Card({ children, style }: { children: ReactNode; style?: ViewStyle }) {
|
export function Card({ children, style }: { children: ReactNode; style?: ViewStyle }) {
|
||||||
const c = useColors();
|
const c = useColors();
|
||||||
return (
|
return <View style={[{ backgroundColor: c.surface, borderColor: c.border, borderWidth: 1, borderRadius: 16, padding: 18, gap: 8 }, style]}>{children}</View>;
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
{
|
|
||||||
backgroundColor: c.surface,
|
|
||||||
borderColor: c.border,
|
|
||||||
borderWidth: StyleSheet.hairlineWidth,
|
|
||||||
borderRadius: 18,
|
|
||||||
padding: 18,
|
|
||||||
gap: 8,
|
|
||||||
// Ombre légère : les cartes se détachent du fond sans trait épais.
|
|
||||||
shadowColor: '#000',
|
|
||||||
shadowOpacity: 0.05,
|
|
||||||
shadowRadius: 10,
|
|
||||||
shadowOffset: { width: 0, height: 3 },
|
|
||||||
elevation: 1,
|
|
||||||
},
|
|
||||||
style,
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Banner({ tone, children }: { tone: 'error' | 'warn' | 'ok'; children: ReactNode }) {
|
export function Banner({ tone, children }: { tone: 'error' | 'warn' | 'ok'; children: ReactNode }) {
|
||||||
|
|
@ -137,5 +111,5 @@ export function unit(mode: 'AMOUNT' | 'STAMP', n = 2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
btn: { borderRadius: 16, borderWidth: 1, paddingHorizontal: 20, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 10 },
|
btn: { borderRadius: 14, borderWidth: 1, paddingHorizontal: 20, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 10 },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useFocusEffect, useLocalSearchParams } from 'expo-router';
|
import { useLocalSearchParams } from 'expo-router';
|
||||||
import { api, CardInfo } from './api';
|
import { api, CardInfo } from './api';
|
||||||
|
|
||||||
/** Carte scannée (paramètre de route `serial`), rechargeable. */
|
/** Carte scannée (paramètre de route `serial`), rechargeable. */
|
||||||
|
|
@ -17,12 +17,9 @@ export function useCard() {
|
||||||
}
|
}
|
||||||
}, [serial]);
|
}, [serial]);
|
||||||
|
|
||||||
// Rechargée à chaque affichage : solde à jour après un crédit ou une récompense.
|
useEffect(() => {
|
||||||
useFocusEffect(
|
load();
|
||||||
useCallback(() => {
|
}, [load]);
|
||||||
load();
|
|
||||||
}, [load]),
|
|
||||||
);
|
|
||||||
|
|
||||||
return { serial, card, setCard, error, reload: load };
|
return { serial, card, setCard, error, reload: load };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue