module IHP.IDE.SchemaDesigner.View.Enums.Show where

import IHP.ViewPrelude
import IHP.IDE.SchemaDesigner.Types
import IHP.IDE.SchemaDesigner.View.Layout

data ShowEnumView = ShowEnumView
    { ShowEnumView -> [Statement]
statements :: [Statement]
    , ShowEnumView -> Text
name :: Text
    }


instance View ShowEnumView where
    html :: ShowEnumView -> Html
html ShowEnumView { [Statement]
Text
name :: Text
statements :: [Statement]
$sel:name:ShowEnumView :: ShowEnumView -> Text
$sel:statements:ShowEnumView :: ShowEnumView -> [Statement]
.. } = [hsx|
        {renderFlashMessages}
        <div class="row no-gutters bg-white" id="schema-designer-viewer">
            {renderObjectSelector (zip [0..] statements) (Just name)}
            {renderEnumSelector name (zip [0..] values)}
        </div>
        {migrationStatus}
    |]
        where
            table :: Maybe Statement
table = Text -> [Statement] -> Maybe Statement
forall (t :: * -> *).
Foldable t =>
Text -> t Statement -> Maybe Statement
findStatementByName Text
name [Statement]
statements
            values :: [Text]
values = [Text] -> (Statement -> [Text]) -> Maybe Statement -> [Text]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (Proxy "values" -> Statement -> [Text]
forall model (name :: Symbol) value.
(KnownSymbol name, HasField name model value) =>
Proxy name -> model -> value
get IsLabel "values" (Proxy "values")
Proxy "values"
#values) Maybe Statement
table