import * as React from "react";
import { ChannelItem } from "./channel";
import { View } from "react-native";
import { VideoPreview } from "../video/video-preview";
import { Playlist } from "../playlist";

export const Channel = ({ item }: { item: ChannelItem }) => {
  if (item.data.gate.kind === "none") return null;
  return (
    <View>
      {item.data.content.offline?.video_content?.map((item) =>
        item.kind !== "video" ? (
          <Playlist
            key={item.playlist?._id}
            id={item.playlist?._id as string}
          />
        ) : (
          <VideoPreview key={item.video?._id} id={item.video?._id as string} />
        )
      )}
      {item.data.content.live?.schedule.map((item) => (
        <VideoPreview key={item.video._id} id={item.video._id} />
      ))}
    </View>
  );
};

export * from "./channel";
