import { Link, useLoaderData } from "@remix-run/react"; import type { LoaderFunction, MetaFunction } from "@remix-run/server-runtime"; import { useState } from "react"; import { API_URL } from "~/lib/constants"; import { API_KEY } from "~/lib/constants.server"; import { getChannels } from "~/lib/getChannels"; import type { Channels } from "~/types/channels"; import { formatNumbers } from "../../lib/utils"; export const loader: LoaderFunction = async () => { const channels = await getChannels(API_KEY); return channels; }; export const meta: MetaFunction = () => { return { title: "Channels", }; }; type ViewStyle = "grid" | "list"; const ChannelsPage = () => { const channels = useLoaderData(); const [viewStyle, setViewStyle] = useState("grid"); const handleSetViewstyle = (selectedViewStyle: ViewStyle) => { setViewStyle(selectedViewStyle); }; return ( <>

Channels

console.log("showForm()")} src="/img/icon-add.svg" alt="add-icon" title="Subscribe to Channels" />
{/* {% csrf_token %} {{ subscribe_form }} */}
Show subscribed only:
console.log("toggleCheckbox(this)")} type="checkbox" /> {/* {% if not show_subed_only %} */} {/* {% else %} */} {/* {% endif %} */}
handleSetViewstyle("grid")} alt="grid view" /> handleSetViewstyle("list")} alt="list view" />

Total matching channels: {channels?.data?.length}

{!channels.data ? (

No channels found...

) : ( channels.data?.map((channel) => { return (
{{ channel.source.channel_id }}-banner
channel-thumb

{channel?.channel_name}

{/* {% if channel.source.channel_subs >= 1000000 %} */}

Subscribers: {formatNumbers(channel?.channel_subs)}

{/* {% else %} */}

Last refreshed: {channel?.channel_last_refresh}

{/* {% if channel.source.channel_subscribed %} */} {/* {% else %} */} {/* */} {/* {% endif %} */}
); }) )} {/* {% endfor %} {% else %} */} {/*

No channels found...

*/} {/* {% endif %} */}
); }; export default ChannelsPage;