add chicken counting, mortality api for daily data sync. Also adjust karung sync to sync every 30 sec after publish cutoff time to update real data without clicking sync button manually

This commit is contained in:
Alberto-Audrix committed 2026-09-04 15:32:18 +07:00
1 parent 5ae477a99d
commit 6c21af745d
17 files changed
+791 -119

No files matched your search

+11 -3
View File
@@ -1,17 +1,23 @@
import React, { useMemo } from 'react';
import { Line, LineChart, ResponsiveContainer, Tooltip } from 'recharts';
import { Line, LineChart, ResponsiveContainer, Tooltip, XAxis } from 'recharts';
import { formatNumber, formatRatio } from '../utils/format.ts';
import type { View } from '../types/common.ts';
export type KpiStatus = 'ok' | 'warning' | 'critical' | 'na';
export type KpiTrendPoint = {
value: number;
/** Tooltip label, e.g. ``Hari 0 · 2 Sep 2026``. */
label: string;
};
export type KpiCardModel = {
key: string;
title: string;
value: number | null;
unit: string;
icon: string;
trend?: number[];
trend?: KpiTrendPoint[];
status: KpiStatus;
targetView?: View;
};
@@ -46,7 +52,7 @@ const KpiCard: React.FC<Props> = ({
const isNA = value === null;
const styles = isNA ? statusStyles.na : statusStyles[status];
const trendData = useMemo(
() => (trend ?? []).map((point, index) => ({ name: index, value: point })),
() => (trend ?? []).map((point) => ({ name: point.label, value: point.value })),
[trend]
);
@@ -94,6 +100,7 @@ const KpiCard: React.FC<Props> = ({
{!isNA && trendData.length > 0 ? (
<ResponsiveContainer width="100%" height="100%">
<LineChart data={trendData} margin={{ top: 2, right: 2, bottom: 2, left: 2 }}>
<XAxis dataKey="name" hide />
<Line
type="monotone"
dataKey="value"
@@ -104,6 +111,7 @@ const KpiCard: React.FC<Props> = ({
/>
<Tooltip
formatter={(val) => [formatNumber(Number(val ?? 0), 2), title]}
labelFormatter={(label) => String(label ?? '')}
contentStyle={{ fontSize: 12, borderRadius: 8 }}
/>
</LineChart>