This commit is contained in:
2026-05-15 22:56:48 +02:00
parent 0350074242
commit f00b3a981d
@@ -269,14 +269,28 @@ export default function StatsScreen() {
</Section> </Section>
{/* ── Revenus par jour (30 jours) ── */} {/* ── Revenus par jour (30 jours) ── */}
<Section title="Revenus par jour (30j)" icon="trending-up-outline">
{stats?.by_day_revenue?.length ? (
<>
<SparkLineRevenue data={stats.by_day_revenue} color={CHART_GREEN} />
{(() => { {(() => {
const best = [...(stats.by_day_revenue ?? [])].sort((a, b) => b.revenue - a.revenue)[0]; const revData = stats?.by_day_revenue ?? [];
if (!best) return null; const revMax = Math.max(...revData.map((d) => d.revenue), 1);
const best = [...revData].sort((a, b) => b.revenue - a.revenue)[0];
return ( return (
<Section title="Revenus par jour (30j)" icon="trending-up-outline">
{revData.length ? (
<>
<SparkLineRevenue data={revData} color={CHART_GREEN} />
<View style={{ marginTop: spacing.m }}>
{[...revData].reverse().map((d) => (
<HBar
key={d.day}
label={d.label}
value={d.revenue}
max={revMax}
color={best && d.day === best.day ? CHART_GREEN : CHART_ACCENT + "bb"}
right={fmtEuro(d.revenue)}
/>
))}
</View>
{best && (
<View style={{ flexDirection: "row", alignItems: "center", gap: spacing.xs, marginTop: spacing.s }}> <View style={{ flexDirection: "row", alignItems: "center", gap: spacing.xs, marginTop: spacing.s }}>
<Ionicons name="star-outline" size={13} color={CHART_GREEN} /> <Ionicons name="star-outline" size={13} color={CHART_GREEN} />
<Text style={{ color: colors.textMuted, fontSize: fontSize.xs }}> <Text style={{ color: colors.textMuted, fontSize: fontSize.xs }}>
@@ -286,13 +300,14 @@ export default function StatsScreen() {
</Text> </Text>
</Text> </Text>
</View> </View>
); )}
})()}
</> </>
) : ( ) : (
<Text style={styles.emptyText}>Aucune donnée de revenu</Text> <Text style={styles.emptyText}>Aucune donnée de revenu</Text>
)} )}
</Section> </Section>
);
})()}
{/* ── Heures d'affluence ── */} {/* ── Heures d'affluence ── */}
{(() => { {(() => {