Bugfixes
This commit is contained in:
@@ -18,8 +18,8 @@ interface WakeupBedtimeProps {
|
||||
bedtime_ref: string;
|
||||
}
|
||||
|
||||
const BedtimePlot: React.FC<WakeupBedtimeProps> = ({ from_date, to_date, bedtime_ref }) => {
|
||||
const { wakeupBedtime, isLoading } = useStats(from_date, to_date, '07:00', '20:00');
|
||||
const BedtimePlot: React.FC<WakeupBedtimeProps> = ({ from_date, to_date, wakeup_ref, bedtime_ref }) => {
|
||||
const { wakeupBedtime, isLoading } = useStats(from_date, to_date, '07:00', '20:00', wakeup_ref, bedtime_ref);
|
||||
const [chartData, setChartData] = useState<{ date: string; minutes: number; time: string }[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -40,9 +40,9 @@ const DailySummary: React.FC<DailySummaryProps> = ({ from_date, to_date, day_sta
|
||||
|
||||
const data = dailySummary.days.map((day) => ({
|
||||
date: day.date,
|
||||
daySleep: day.day_minutes,
|
||||
nightSleep: day.night_minutes,
|
||||
total: day.total_minutes,
|
||||
daySleep: day.day_minutes / 60,
|
||||
nightSleep: day.night_minutes / 60,
|
||||
total: day.total_minutes / 60,
|
||||
}));
|
||||
|
||||
setChartData(data.reverse());
|
||||
@@ -58,9 +58,9 @@ const DailySummary: React.FC<DailySummaryProps> = ({ from_date, to_date, day_sta
|
||||
);
|
||||
const count = data.length;
|
||||
setAvgStats({
|
||||
avgTotal: Math.round(totals.total / count),
|
||||
avgDay: Math.round(totals.day / count),
|
||||
avgNight: Math.round(totals.night / count),
|
||||
avgTotal: totals.total / count,
|
||||
avgDay: totals.day / count,
|
||||
avgNight: totals.night / count,
|
||||
count,
|
||||
});
|
||||
}
|
||||
@@ -81,7 +81,12 @@ const DailySummary: React.FC<DailySummaryProps> = ({ from_date, to_date, day_sta
|
||||
margin={{ top: 5, right: 30, left: 60, bottom: 5 }}
|
||||
>
|
||||
<CartesianGrid strokeDasharray="3 3" stroke="#e5e7eb" />
|
||||
<XAxis type="number" tick={{ fontSize: 12 }} tickLine={false} />
|
||||
<XAxis
|
||||
type="number"
|
||||
tickFormatter={(value) => `${Math.round(value)}h`}
|
||||
tick={{ fontSize: 12 }}
|
||||
tickLine={false}
|
||||
/>
|
||||
<YAxis
|
||||
type="category"
|
||||
dataKey="date"
|
||||
@@ -91,7 +96,7 @@ const DailySummary: React.FC<DailySummaryProps> = ({ from_date, to_date, day_sta
|
||||
/>
|
||||
<Tooltip
|
||||
formatter={(value: number, name: string) => [
|
||||
formatMinutes(value),
|
||||
formatMinutes(Math.round(value * 60)),
|
||||
name === 'daySleep' ? 'Day' : 'Night',
|
||||
]}
|
||||
/>
|
||||
@@ -102,15 +107,15 @@ const DailySummary: React.FC<DailySummaryProps> = ({ from_date, to_date, day_sta
|
||||
<div className="mt-4 grid grid-cols-3 gap-4 text-center">
|
||||
<div className="p-3 bg-gray-50 rounded-lg">
|
||||
<div className="text-xs text-gray-500">Avg Total</div>
|
||||
<div className="text-lg font-semibold text-gray-800">{formatMinutes(avgStats.avgTotal)}</div>
|
||||
<div className="text-lg font-semibold text-gray-800">{formatMinutes(Math.round(avgStats.avgTotal * 60))}</div>
|
||||
</div>
|
||||
<div className="p-3 bg-gray-50 rounded-lg">
|
||||
<div className="text-xs text-gray-500">Avg Day</div>
|
||||
<div className="text-lg font-semibold text-gray-800">{formatMinutes(avgStats.avgDay)}</div>
|
||||
<div className="text-lg font-semibold text-gray-800">{formatMinutes(Math.round(avgStats.avgDay * 60))}</div>
|
||||
</div>
|
||||
<div className="p-3 bg-gray-50 rounded-lg">
|
||||
<div className="text-xs text-gray-500">Avg Night</div>
|
||||
<div className="text-lg font-semibold text-gray-800">{formatMinutes(avgStats.avgNight)}</div>
|
||||
<div className="text-lg font-semibold text-gray-800">{formatMinutes(Math.round(avgStats.avgNight * 60))}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,8 +18,8 @@ interface WakeupBedtimeProps {
|
||||
bedtime_ref: string;
|
||||
}
|
||||
|
||||
const WakeupPlot: React.FC<WakeupBedtimeProps> = ({ from_date, to_date, wakeup_ref }) => {
|
||||
const { wakeupBedtime, isLoading } = useStats(from_date, to_date, '07:00', '20:00');
|
||||
const WakeupPlot: React.FC<WakeupBedtimeProps> = ({ from_date, to_date, wakeup_ref, bedtime_ref }) => {
|
||||
const { wakeupBedtime, isLoading } = useStats(from_date, to_date, '07:00', '20:00', wakeup_ref, bedtime_ref);
|
||||
const [chartData, setChartData] = useState<{ date: string; minutes: number; time: string }[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user