Files
donetick/src/utils/DurationUtils.js
Mo Tarbin 4fa0f5ffeb Refactor duration handling and enhance chore management features
- Replace hardcoded time units with TIME_UNITS constant in NotificationTemplate.
- Introduce DurationInput component for reusable duration selection in ChoreEdit and AddTaskModal.
- Update chore queries to refetch on window focus.
- Adjust completion window logic in ChoreView and HistoryCard for better deadline handling.
- Implement smart insights filter restoration in MyChores.
- Add MyChoreHeader component for improved filter display.
- Enhance activity notes display with truncation and modal view in ActivitiesCard.
2026-03-08 23:21:02 -04:00

19 lines
622 B
JavaScript

export const TIME_UNITS = [
{ label: 'Mins', value: 'm', seconds: 60 },
{ label: 'Hours', value: 'h', seconds: 3600 },
{ label: 'Days', value: 'd', seconds: 86400 },
]
export function secondsToValueAndUnit(totalSeconds) {
if (totalSeconds % 86400 === 0)
return { value: totalSeconds / 86400, unit: 'd' }
if (totalSeconds % 3600 === 0)
return { value: totalSeconds / 3600, unit: 'h' }
return { value: Math.round(totalSeconds / 60), unit: 'm' }
}
export function valueAndUnitToSeconds(value, unit) {
const unitInfo = TIME_UNITS.find(u => u.value === unit)
return value * (unitInfo?.seconds ?? 1)
}