import { useState } from "react"; import { Link, useLoaderData } from "@remix-run/react"; import IconAdd from "~/images/icon-add.svg"; import IconGridView from "~/images/icon-gridview.svg"; import IconListView from "~/images/icon-listview.svg"; import type { LoaderFunction } from "@remix-run/server-runtime"; import { getPlaylists } from "~/lib/getPlaylists"; import { API_KEY } from "~/lib/constants.server"; import type { Playlists } from "~/types/playlists"; import { API_URL } from "~/lib/constants"; export const loader: LoaderFunction = async () => { const playlists = await getPlaylists(API_KEY); return playlists; }; type ViewStyle = "grid" | "list"; const Playlist = () => { const playlists = useLoaderData(); const [viewStyle, setViewStyle] = useState("grid"); const handleSetViewstyle = (selectedViewStyle: ViewStyle) => { setViewStyle(selectedViewStyle); }; return ( <>

Playlists

add-icon
{/* {% csrf_token %} {{ subscribe_form }} */}
{/*
*/}
Show subscribed only:
{/* {% if not show_subed_only %} */} {/* {% else %} */} {/* {% endif %} */}
handleSetViewstyle("grid")} alt="grid view" /> handleSetViewstyle("list")} alt="list view" />
{/* {% if results %} {% for playlist in results %} */} {!playlists ? (

No playlists found...

) : ( playlists.data.map((playlist) => { return (
{`${playlist.playlist_id}-thumbnail`}

{playlist.playlist_channel}

{playlist.playlist_name}

Last refreshed: {playlist.playlist_last_refresh}

{playlist.playlist_subscribed ? ( ) : ( )}
); }) )}
); }; export default Playlist;