export function getVideo()

in public/video-ui/src/actions/VideoActions/getVideo.js [31:53]


export function getVideo(id) {
  return dispatch => {
    dispatch(requestVideo(id));
    return VideosApi.fetchVideo(id)
      .then(res => {
        // We and downstream consumers expect the scheduled launch to be an integer, but our API provides a string representation
        const scheduledLaunch = res?.contentChangeDetails?.scheduledLaunch?.date;
        if (scheduledLaunch) {
          res.contentChangeDetails.scheduledLaunch.date = moment(scheduledLaunch).valueOf();
        }
        const embargo = res?.contentChangeDetails?.embargo?.date;
        if (embargo) {
          res.contentChangeDetails.embargo.date = moment(embargo).valueOf();
        }
        const expiry = res?.contentChangeDetails?.expiry?.date;
        if (expiry) {
          res.contentChangeDetails.expiry.date = moment(expiry).valueOf();
        }
        dispatch(receiveVideo(res));
      })
      .catch(error => dispatch(errorReceivingVideo(error)));
  };
}