diff --git a/maternal-web/app/track/feeding/page.tsx b/maternal-web/app/track/feeding/page.tsx index 32731c2..88bf450 100644 --- a/maternal-web/app/track/feeding/page.tsx +++ b/maternal-web/app/track/feeding/page.tsx @@ -54,6 +54,8 @@ import { motion } from 'framer-motion'; import { useLocalizedDate } from '@/hooks/useLocalizedDate'; import { useTranslation } from '@/hooks/useTranslation'; import { UnitInput } from '@/components/forms/UnitInput'; +import { convertVolume, getUnitSymbol } from '@/lib/utils/unitConversion'; +import { MeasurementSystem } from '@/hooks/useLocale'; interface FeedingData { feedingType: 'breast' | 'bottle' | 'solid'; @@ -302,7 +304,12 @@ function FeedingTrackPage() { if (data.feedingType === 'breast') { return `${data.side?.toUpperCase()} - ${data.duration || 0} min`; } else if (data.feedingType === 'bottle') { - return `${data.amount || 0} ml - ${data.bottleType}`; + // Convert amount based on user preference + const measurementSystem: MeasurementSystem = + (user?.preferences?.measurementUnit as MeasurementSystem) || 'metric'; + const converted = convertVolume(data.amount || 0, measurementSystem); + const roundedValue = Math.round(converted.value * 10) / 10; // Round to 1 decimal + return `${roundedValue} ${converted.unit} - ${data.bottleType}`; } else if (data.feedingType === 'solid') { return `${data.foodDescription}${data.amountDescription ? ` - ${data.amountDescription}` : ''}`; } diff --git a/maternal-web/app/track/medicine/page.tsx b/maternal-web/app/track/medicine/page.tsx index 16953c3..4bd4ef6 100644 --- a/maternal-web/app/track/medicine/page.tsx +++ b/maternal-web/app/track/medicine/page.tsx @@ -46,6 +46,8 @@ import { motion } from 'framer-motion'; import { useLocalizedDate } from '@/hooks/useLocalizedDate'; import { useTranslation } from '@/hooks/useTranslation'; import { UnitInput } from '@/components/forms/UnitInput'; +import { convertVolume, getUnitSymbol } from '@/lib/utils/unitConversion'; +import { MeasurementSystem } from '@/hooks/useLocale'; interface MedicineData { medicineName: string; @@ -223,6 +225,24 @@ function MedicineTrackPage() { const getMedicineDetails = (activity: Activity) => { const data = activity.data as MedicineData; + + // Only convert if unit is ml (liquid medicine) + if (data.unit === 'ml') { + const measurementSystem: MeasurementSystem = + (user?.preferences?.measurementUnit as MeasurementSystem) || 'metric'; + const converted = convertVolume(parseFloat(data.dosage), measurementSystem); + const roundedValue = Math.round(converted.value * 10) / 10; // Round to 1 decimal + let details = `${roundedValue} ${converted.unit}`; + if (data.route) { + details += ` - ${data.route.charAt(0).toUpperCase() + data.route.slice(1)}`; + } + if (data.reason) { + details += ` - ${data.reason}`; + } + return details; + } + + // For non-liquid units (mg, tablets, drops), display as-is let details = `${data.dosage} ${data.unit || ''}`; if (data.route) { details += ` - ${data.route.charAt(0).toUpperCase() + data.route.slice(1)}`;