diff --git a/client/index.tsx b/client/index.tsx index 3a7e416c..59b292eb 100644 --- a/client/index.tsx +++ b/client/index.tsx @@ -8,6 +8,10 @@ import {AvatarContentText} from 'superdesk-ui-framework'; import belgaImage from './belga/image'; import belga360Archive from './belga/360archive'; import belgaPress from './belga/belgapress'; +import moment from 'moment'; +import {IEventItem, IPlanningItem} from 'superdesk-planning/client/interfaces'; +import {setCoverageDueDateStrategy} from 'superdesk-planning/client/configure'; +import {eventUtils} from 'superdesk-planning/client/utils'; class UserAvatar extends React.PureComponent<{user: Partial}> { render() { @@ -24,6 +28,33 @@ class UserAvatar extends React.PureComponent<{user: Partial}> { } } +function getCoverageDueDate( + planningItem: IPlanningItem, + eventItem?: IEventItem, +): moment.Moment | null { + let coverageTime: moment.Moment | null = null; + + if (eventItem && eventUtils.isEventAllDay(eventItem.dates?.start, eventItem.dates?.end)) { + coverageTime = moment(eventItem.dates?.end); + coverageTime.set('hour', 20); + coverageTime.set('minute', 0); + coverageTime.set('second', 0); + } else if (eventItem) { + coverageTime = moment(eventItem.dates?.end); + coverageTime.add(1, 'hour'); + if (eventItem.dates?.end && !coverageTime.isSame(eventItem.dates?.end, 'day')) { + // make sure we're not going into the next day + coverageTime = moment(eventItem.dates?.end); + } + } else if (planningItem) { + coverageTime = moment(planningItem.planning_date); + } + + return coverageTime; +} + +setCoverageDueDateStrategy(getCoverageDueDate); + setTimeout(() => { startApp([ {