{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module WikiMusic.SSR.View.GenreHtml ( genreListPage', genreDetailPage', genreCreatePage', ) where import Data.Map qualified as Map import Optics import Relude import Text.Blaze.Html import Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes as A import WikiMusic.Interaction.Model.Genre import WikiMusic.SSR.Language import WikiMusic.SSR.Model.Api import WikiMusic.SSR.Model.Env import WikiMusic.SSR.View.Components.Forms import WikiMusic.SSR.View.Components.Meta import WikiMusic.SSR.View.Components.Other import WikiMusic.SSR.View.Components.PageTop genreListPage' :: (MonadIO m) => Env -> UiMode -> Language -> Palette -> SortOrder -> GetGenresQueryResponse -> m Html genreListPage' env mode language palette sortOrder xs = do sharedHead <- mkSharedHead env mode palette (dictionary ^. #titles % #genresPage |##| language) pure $ H.html $ do sharedHead body $ section $ do sharedPageTop (Just $ dictionary ^. #titles % #genresPage |##| language) mode language palette section ! class_ "flex direction-row justify-content-center gap-small align-items-baseline" $ do H.a ! href "/genres/create" $ button $ H.small "+ new genre" mkSortingForm language sortOrder "/user-preferences/genre-sorting" "genre-sorting" section ! class_ "entity-card-section" $ mapM_ (simpleEntityCard language "genres") sortedXs where sortedXs = mapMaybe (\identifier -> (xs ^. #genres) Map.!? identifier) (xs ^. #sortOrder) genreDetailPage' :: (MonadIO m) => Env -> UiMode -> Language -> Palette -> Genre -> m Html genreDetailPage' env mode language palette x = do sharedHead <- mkSharedHead env mode palette (dictionary ^. #titles % #genresPage |##| language) pure $ H.html $ do sharedHead body $ section $ do sharedPageTop Nothing mode language palette entityDetails language "genres" x genreCreatePage' :: (MonadIO m) => Env -> UiMode -> Language -> Palette -> m Html genreCreatePage' env mode language palette = do sharedHead <- mkSharedHead env mode palette (dictionary ^. #titles % #genresPage |##| language) pure $ H.html $ do sharedHead body $ section $ do sharedPageTop Nothing mode language palette section $ do H.h2 "Create genre" postForm "/genres/create" $ do requiredTextInput "displayName" "genre name" optionalTextArea "description" "description" optionalTextInput "spotifyUrl" "spotify URL" optionalTextInput "youtubeUrl" "youtube URL" optionalTextInput "wikipediaUrl" "wikipedia URL" optionalTextInput "soundcloudUrl" "soundcloud URL" submitButton language