import { ActionIcon, Button, Group, Overlay, ScrollArea, Stack, Text, } from '@mantine/core'; import { useCommonHooks } from 'hooks'; import { useState } from 'react'; import { FiEdit, FiRefreshCcw, FiTrash } from 'react-icons/fi'; import ThemeMiniCard from './ThemeMiniCard'; function ThemePlaylistCard({ cardPlaylist, handleOpen, handleDeletePlaylist, createPlaylist, allThemes, }: any) { const [hover, setHover] = useState(false); const { currentThemePlaylist, setCurrentThemePlaylist, theme } = useCommonHooks(); const syncableLists = ['All', 'Backgrounds', 'No Backgrounds']; const themeList = JSON.parse( cardPlaylist.themeList.name === 'Time of Day' ? '[]' : cardPlaylist.themeList, ); return ( setHover(true)} onMouseLeave={() => setHover(false)} > {cardPlaylist.name} {syncableLists.includes(cardPlaylist.name) ? ( { event.stopPropagation(); if (cardPlaylist.name === 'All') { createPlaylist({ method: 'PATCH', endpoint: 'api/themePlaylists', body: { id: cardPlaylist.id, name: 'All', themeList: JSON.stringify(allThemes.map((theme: any) => theme.id)), }, }); } if (cardPlaylist.name === 'Backgrounds') { createPlaylist({ method: 'PATCH', endpoint: 'api/themePlaylists', body: { id: cardPlaylist.id, name: 'Backgrounds', themeList: JSON.stringify( allThemes .filter((theme: any) => theme.backgroundImage !== 'none') .map((theme: any) => theme.id), ), }, }); } if (cardPlaylist.name === 'No Backgrounds') { createPlaylist({ method: 'PATCH', endpoint: 'api/themePlaylists', body: { id: cardPlaylist.id, name: 'No Backgrounds', themeList: JSON.stringify( allThemes .filter((theme: any) => theme.backgroundImage === 'none') .map((theme: any) => theme.id), ), }, }); } }} > ) : ( <> { handleOpen(cardPlaylist); }} > {cardPlaylist.default === 0 && ( handleDeletePlaylist(cardPlaylist)} > )} )} ); } export default ThemePlaylistCard;