import { selectorFamily } from 'recoil';
import contest from './contest';

/**
 * Contest call events can be hydrated by a calls file.
 */
const contestCallEvents = selectorFamily({
  key: 'election.selectors.contestCallEvents',
  get: key => ({
    get
  }) => {
    const data = get(contest(key));
    if (!data) return undefined;
    return {
      metadata: data.metadata,
      data: data.data.callEvents
    };
  }
});
export default contestCallEvents;