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

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

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

instance View ShowView where
    html :: ShowView -> Html
html ShowView { [Statement]
Text
Statement
table :: Statement
name :: Text
statements :: [Statement]
$sel:table:ShowView :: ShowView -> Statement
$sel:name:ShowView :: ShowView -> Text
$sel:statements:ShowView :: ShowView -> [Statement]
.. } = [hsx|
        {renderFlashMessages}
        <div class="row no-gutters bg-white" id="schema-designer-viewer">
            {renderObjectSelector (zip [0..] statements) (Just name)}
            {renderColumnSelector name (zip [0..] columns) statements}
        </div>
        {migrationStatus}
    |]
        where
            columns :: [Column]
columns = Proxy "columns" -> CreateTable -> [Column]
forall model (name :: Symbol) value.
(KnownSymbol name, HasField name model value) =>
Proxy name -> model -> value
get IsLabel "columns" (Proxy "columns")
Proxy "columns"
#columns (Statement -> CreateTable
unsafeGetCreateTable Statement
table)