chore: build
This commit is contained in:
@@ -117,11 +117,15 @@ func GetAdminStats(c *gin.Context) {
|
||||
ci.produit AS name,
|
||||
SUM(ci.quantite) AS total_quantity,
|
||||
COUNT(DISTINCT ci.command_id) AS order_count,
|
||||
SUM(ci.prix * ci.quantite) AS revenue
|
||||
SUM(ci.prix * ci.quantite) AS revenue,
|
||||
COALESCE(p.category, '') AS category,
|
||||
COALESCE(cat.color, '#7c3aed') AS category_color
|
||||
FROM command_items ci
|
||||
JOIN commandes c ON c.id = ci.command_id
|
||||
LEFT JOIN products p ON p.id = ci.product_id
|
||||
LEFT JOIN categories cat ON cat.name = p.category
|
||||
WHERE c.status != 'cancelled'
|
||||
GROUP BY ci.product_id, ci.produit
|
||||
GROUP BY ci.product_id, ci.produit, p.category, cat.color
|
||||
ORDER BY total_quantity DESC
|
||||
LIMIT 15
|
||||
`).Scan(&prodRows)
|
||||
@@ -135,6 +139,8 @@ func GetAdminStats(c *gin.Context) {
|
||||
"quantity": r.Quantity,
|
||||
"order_count": r.OrderCount,
|
||||
"revenue": r.Revenue,
|
||||
"category": r.Category,
|
||||
"category_color": r.CategoryColor,
|
||||
}
|
||||
if i == 0 {
|
||||
topProductName = r.Name
|
||||
|
||||
@@ -18,6 +18,8 @@ type ProductRow struct {
|
||||
Quantity float64 `gorm:"column:total_quantity"`
|
||||
OrderCount int `gorm:"column:order_count"`
|
||||
Revenue float64 `gorm:"column:revenue"`
|
||||
Category string `gorm:"column:category"`
|
||||
CategoryColor string `gorm:"column:category_color"`
|
||||
}
|
||||
|
||||
type HourRow struct {
|
||||
|
||||
@@ -86,6 +86,8 @@ export interface ProductStat {
|
||||
quantity: number;
|
||||
order_count: number;
|
||||
revenue: number;
|
||||
category: string;
|
||||
category_color: string;
|
||||
}
|
||||
|
||||
export interface AdminStats {
|
||||
|
||||
@@ -402,7 +402,7 @@ export default function StatsScreen() {
|
||||
{sortedProducts.length === 0 ? (
|
||||
<Text style={styles.emptyText}>Aucune donnée produit</Text>
|
||||
) : (
|
||||
sortedProducts.map((p, i) => {
|
||||
sortedProducts.map((p) => {
|
||||
const val =
|
||||
prodSort === "orders" ? p.order_count
|
||||
: prodSort === "revenue" ? p.revenue
|
||||
@@ -411,18 +411,13 @@ export default function StatsScreen() {
|
||||
prodSort === "revenue" ? fmtEuro(p.revenue)
|
||||
: prodSort === "orders" ? `${p.order_count} cmd`
|
||||
: `×${fmtNum(p.quantity)}`;
|
||||
const color =
|
||||
i === 0 ? CHART_AMBER
|
||||
: i === 1 ? "#94a3b8"
|
||||
: i === 2 ? "#b45309"
|
||||
: CHART_ACCENT;
|
||||
return (
|
||||
<HBar
|
||||
key={p.product_id}
|
||||
label={p.name}
|
||||
value={val}
|
||||
max={prodMax}
|
||||
color={color}
|
||||
color={p.category_color || CHART_ACCENT}
|
||||
right={rightLabel}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user