import { Link, useLoaderData } from "@remix-run/react"; import { useState } from "react"; import IconAdd from "~/images/icon-add.svg"; import IconGridView from "~/images/icon-gridview.svg"; import IconListView from "~/images/icon-listview.svg"; import { API_URL } from "~/lib/constants"; import { API_KEY } from "~/lib/constants.server"; import { getPlaylists } from "~/lib/getPlaylists"; import type { Playlists } from "~/types/playlists"; export const loader = 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;