feat: add reset buttons for heures/jours/doses stats, fix home button color
- StatsScreen: SectionResetBtn for heures d'affluence, jours d'affluence, doses populaires - api_admin.ts: extend StatSection and AdminStats with heures/jours/doses fields - HomeScreen (mobile client): use colors.accent for Se connecter button Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -104,7 +104,7 @@ export interface ProductQuantityBreakdown {
|
|||||||
quantities: QuantityStat[];
|
quantities: QuantityStat[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StatSection = "commandes" | "revenus" | "produits";
|
export type StatSection = "commandes" | "revenus" | "produits" | "heures" | "jours" | "doses";
|
||||||
|
|
||||||
export interface AdminStats {
|
export interface AdminStats {
|
||||||
summary: StatsSummary;
|
summary: StatsSummary;
|
||||||
@@ -117,6 +117,9 @@ export interface AdminStats {
|
|||||||
reset_at_commandes?: string;
|
reset_at_commandes?: string;
|
||||||
reset_at_revenus?: string;
|
reset_at_revenus?: string;
|
||||||
reset_at_produits?: string;
|
reset_at_produits?: string;
|
||||||
|
reset_at_heures?: string;
|
||||||
|
reset_at_jours?: string;
|
||||||
|
reset_at_doses?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getAdminStats = async (): Promise<AdminStats> => {
|
export const getAdminStats = async (): Promise<AdminStats> => {
|
||||||
|
|||||||
@@ -395,6 +395,11 @@ export default function StatsScreen() {
|
|||||||
const hourMax = maxOf(hourData.map((h) => h.count));
|
const hourMax = maxOf(hourData.map((h) => h.count));
|
||||||
return (
|
return (
|
||||||
<Section title="Heures d'affluence" icon="time-outline">
|
<Section title="Heures d'affluence" icon="time-outline">
|
||||||
|
<SectionResetBtn
|
||||||
|
onPress={() => handleReset("heures", "Heures d'affluence")}
|
||||||
|
loading={resetting === "heures"}
|
||||||
|
resetAt={stats?.reset_at_heures}
|
||||||
|
/>
|
||||||
{hourData.some((h) => h.count > 0) ? (
|
{hourData.some((h) => h.count > 0) ? (
|
||||||
<>
|
<>
|
||||||
{hourData.map((h) => (
|
{hourData.map((h) => (
|
||||||
@@ -428,6 +433,11 @@ export default function StatsScreen() {
|
|||||||
|
|
||||||
{/* ── Commandes par jour de la semaine ── */}
|
{/* ── Commandes par jour de la semaine ── */}
|
||||||
<Section title="Jours d'affluence" icon="calendar-outline">
|
<Section title="Jours d'affluence" icon="calendar-outline">
|
||||||
|
<SectionResetBtn
|
||||||
|
onPress={() => handleReset("jours", "Jours d'affluence")}
|
||||||
|
loading={resetting === "jours"}
|
||||||
|
resetAt={stats?.reset_at_jours}
|
||||||
|
/>
|
||||||
{(stats?.by_weekday ?? []).map((w: WeekdayStat) => (
|
{(stats?.by_weekday ?? []).map((w: WeekdayStat) => (
|
||||||
<HBar
|
<HBar
|
||||||
key={w.weekday}
|
key={w.weekday}
|
||||||
@@ -456,6 +466,11 @@ export default function StatsScreen() {
|
|||||||
if (!qtyData.length) return null;
|
if (!qtyData.length) return null;
|
||||||
return (
|
return (
|
||||||
<Section title="Doses populaires par produit" icon="flask-outline">
|
<Section title="Doses populaires par produit" icon="flask-outline">
|
||||||
|
<SectionResetBtn
|
||||||
|
onPress={() => handleReset("doses", "Doses populaires")}
|
||||||
|
loading={resetting === "doses"}
|
||||||
|
resetAt={stats?.reset_at_doses}
|
||||||
|
/>
|
||||||
{qtyData.map((product) => {
|
{qtyData.map((product) => {
|
||||||
const peakCount = product.quantities[0]?.order_count ?? 1;
|
const peakCount = product.quantities[0]?.order_count ?? 1;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default function HomeScreen({ navigation }: Props) {
|
|||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.button}
|
style={[styles.button, { backgroundColor: colors.accent }]}
|
||||||
onPress={() => navigation.navigate("login")}
|
onPress={() => navigation.navigate("login")}
|
||||||
>
|
>
|
||||||
<Text style={styles.buttonText}>Se connecter</Text>
|
<Text style={styles.buttonText}>Se connecter</Text>
|
||||||
@@ -58,7 +58,6 @@ const styles = StyleSheet.create({
|
|||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
backgroundColor: "#7c3aed",
|
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
paddingVertical: 12,
|
paddingVertical: 12,
|
||||||
paddingHorizontal: 24,
|
paddingHorizontal: 24,
|
||||||
|
|||||||
Reference in New Issue
Block a user