Fix daily summary to display real activity counts and add medicine tracker
## Backend Changes - Update tracking.service.ts getDailySummary to calculate actual counts - Import ActivityType enum for proper type comparisons - Calculate feedingCount, sleepTotalMinutes, diaperCount, medicationCount - Sleep duration now correctly calculated from startedAt/endedAt timestamps ## Frontend API Changes - Add medicationCount to DailySummary interface - Extract endTime from metadata and send as endedAt to backend - Enables proper sleep duration tracking with start/end times ## Homepage Updates - Add Medicine and Activities quick action buttons - Update summary grid from 3 to 4 columns (responsive layout) - Add medication count display with MedicalServices icon - Improve grid responsiveness (xs=6, sm=3) - Replace Analytics button with Activities button ## New Activities Page - Create /activities page to show recent activity history - Display last 7 days of activities with color-coded icons - Show smart timestamps (Today/Yesterday/date format) - Activity-specific descriptions (feeding amount, sleep duration, etc.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ export interface DailySummary {
|
||||
feedingCount: number;
|
||||
sleepTotalMinutes: number;
|
||||
diaperCount: number;
|
||||
medicationCount: number;
|
||||
activities: Activity[];
|
||||
}
|
||||
|
||||
@@ -68,12 +69,18 @@ export const trackingApi = {
|
||||
// Create a new activity
|
||||
createActivity: async (childId: string, data: CreateActivityData): Promise<Activity> => {
|
||||
// Transform frontend data structure to backend DTO format
|
||||
const payload = {
|
||||
const payload: any = {
|
||||
type: data.type,
|
||||
startedAt: data.timestamp, // Backend expects startedAt, not timestamp
|
||||
metadata: data.data, // Backend expects metadata, not data
|
||||
notes: data.notes,
|
||||
};
|
||||
|
||||
// Extract endTime from metadata and set as endedAt (for sleep tracking)
|
||||
if (data.data?.endTime) {
|
||||
payload.endedAt = data.data.endTime;
|
||||
}
|
||||
|
||||
const response = await apiClient.post(`/api/v1/activities?childId=${childId}`, payload);
|
||||
const activity = response.data.data.activity;
|
||||
// Transform backend response to frontend format
|
||||
|
||||
Reference in New Issue
Block a user