import moment from 'moment'; import {IPlanningAPI, IFeaturedPlanningItem, IFeaturedPlanningLock} from '../interfaces'; import {superdeskApi} from '../superdeskApi'; import {getIdForFeauturedPlanning} from '../utils'; function lockFeaturedPlanning(): Promise> { return superdeskApi.dataApi.create>('planning_featured_lock', {}); } function unlockFeaturedPlanning(): Promise { return superdeskApi.dataApi.create('planning_featured_unlock', {}) .then(() => undefined); } function fetchFeaturedPlanningItemById(id: string): Promise { return superdeskApi.dataApi.findOne('planning_featured', id); } function fetchFeaturedPlanningItemByDate(date: moment.Moment): Promise { return fetchFeaturedPlanningItemById( getIdForFeauturedPlanning(date) ); } export const featured: IPlanningAPI['planning']['featured'] = { lock: lockFeaturedPlanning, unlock: unlockFeaturedPlanning, getById: fetchFeaturedPlanningItemById, getByDate: fetchFeaturedPlanningItemByDate, };