+export const canApplyForEpisode = (user, episode, as) => {
+ if (!user) return false;
+ if (as === 'commentary') return Episode.acceptsComms(episode) && !isCommentator(user, episode);
+ if (as === 'tracking') return Episode.acceptsTrackers(episode) && !isTracker(user, episode);
+ return false;
+};
+
+export const applicableChannels = (user, episode, as) => {
+ if (!user || !episode) return [];
+ const assigned_channels = (episode.crew || [])
+ .filter(c => c.user_id === user.id)
+ .map(c => c.channel_id);
+ const channels = episode.channels || [];
+ if (as === 'commentary') return channels.filter(c =>
+ c.pivot && c.pivot.accept_comms && !assigned_channels.includes(c.id));
+ if (as === 'tracking') return channels.filter(c =>
+ c.pivot && c.pivot.accept_tracker && !assigned_channels.includes(c.id));
+ return [];
+};
+