Add contentFormatter for tooltips and error/warning bubbles, format i18n texts, add missing high-dose warning
This commit is contained in:
@@ -19,6 +19,7 @@ import { IconButtonWithTooltip } from './ui/icon-button-with-tooltip';
|
||||
import CollapsibleCardHeader from './ui/collapsible-card-header';
|
||||
import { Plus, Copy, Trash2, ArrowDownAZ, TrendingUp, TrendingDown, Utensils } from 'lucide-react';
|
||||
import type { DayGroup } from '../constants/defaults';
|
||||
import { formatText } from '../utils/contentFormatter';
|
||||
|
||||
interface DayScheduleProps {
|
||||
days: DayGroup[];
|
||||
@@ -243,6 +244,8 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
|
||||
|
||||
// Check for zero dose
|
||||
const isZeroDose = dose.ldx === '0' || dose.ldx === '0.0';
|
||||
// Check for dose > 70 mg
|
||||
const isHighDose = parseFloat(dose.ldx) > 70;
|
||||
|
||||
return (
|
||||
<div key={dose.id} className="space-y-2">
|
||||
@@ -252,8 +255,8 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
|
||||
onChange={(value) => onUpdateDose(day.id, dose.id, 'time', value)}
|
||||
required={true}
|
||||
warning={hasDuplicateTime}
|
||||
errorMessage={t('errorTimeRequired')}
|
||||
warningMessage={t('warningDuplicateTime')}
|
||||
errorMessage={formatText(t('errorTimeRequired'))}
|
||||
warningMessage={formatText(t('warningDuplicateTime'))}
|
||||
/>
|
||||
<FormNumericInput
|
||||
value={dose.ldx}
|
||||
@@ -263,9 +266,13 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
|
||||
max={200}
|
||||
//unit="mg"
|
||||
required={true}
|
||||
warning={isZeroDose}
|
||||
errorMessage={t('errorNumberRequired')}
|
||||
warningMessage={t('warningZeroDose')}
|
||||
warning={isZeroDose || isHighDose}
|
||||
errorMessage={formatText(t('errorNumberRequired'))}
|
||||
warningMessage={
|
||||
isZeroDose ? formatText(t('warningZeroDose'))
|
||||
: isHighDose ? formatText(t('warningDoseAbove70mg'))
|
||||
: undefined // should not happen since warning is false
|
||||
}
|
||||
inputWidth="w-[72px]"
|
||||
/>
|
||||
<div className="flex gap-2 sm:contents">
|
||||
|
||||
Reference in New Issue
Block a user