module Pages.Services.Nutrition exposing (Model, Msg, page)

import Config.Helpers.Articles.Article exposing (contentList)
import Config.Helpers.Articles.Markdown as Markdown
import Config.Helpers.Cards.Inner.BuyButton exposing (buyButton)
import Config.Helpers.Cards.Outer.Helpers exposing (cardMaker)
import Config.Helpers.Cards.Outer.Types as C exposing (Cardable(..))
import Config.Helpers.Headers.Types exposing (Header)
import Config.Helpers.Response
    exposing
        ( pageList
        , topLevelContainer
        )
import Config.Helpers.Viewport exposing (resetViewport)
import Config.Pages.Blogs.Types exposing (BlogArticle)
import Config.Pages.Services.Records.NutritionScience exposing (servicesNutritionScience)
import Config.Style.Colour.Helpers exposing (colourTheme)
import Effect exposing (Effect)
import Element as E
    exposing
        ( Device
        , DeviceClass(..)
        , Element
        , Orientation(..)
        , centerX
        , column
        , el
        , paddingXY
        )
import Layouts
import Page exposing (Page)
import Ports
import Route exposing (Route)
import Route.Path as Path
import Shared
import View exposing (View)


page : Shared.Model -> Route () -> Page Model Msg
page shared route =
    Page.new
        { init = init
        , update = update
        , subscriptions = subscriptions
        , view = view shared
        }
        |> Page.withLayout toLayout


toLayout : Model -> Layouts.Layout Msg
toLayout model =
    Layouts.Navbar {}



-- INIT


type alias Model =
    {}


init : () -> ( Model, Effect Msg )
init () =
    ( {}
    , Effect.map
        (\_ -> NoOp)
        (Effect.sendCmd resetViewport)
    )



-- UPDATE


type Msg
    = NoOp
    | MarkdownMsg Markdown.Msg


update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
    case msg of
        NoOp ->
            ( model
            , Effect.none
            )

        MarkdownMsg (Markdown.ScrollToElement elementId) ->
            ( model
            , Effect.sendCmd (Ports.scrollToElement elementId)
            )



-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.none



-- VIEW


view : Shared.Model -> Model -> View Msg
view shared model =
    { title = "services (nutritionChat)"
    , attributes = []
    , element = nutritionContainer shared.device
    }


nutritionContainer : Device -> Element Msg
nutritionContainer device =
    topLevelContainer (nutritionList device)


nutritionList : Device -> Element Msg
nutritionList device =
    column
        (case ( device.class, device.orientation ) of
            _ ->
                pageList device
        )
    <|
        List.concat
            [ List.map
                (\service ->
                    cardMaker device
                        (C.BlogArticle service)
                        (contentList service
                            [ el
                                [ paddingXY 0 10
                                , centerX
                                ]
                              <|
                                buyButton "Book!" "https://buy.stripe.com/5kA5lz77pdJq6J28wz"
                            ]
                            MarkdownMsg
                        )
                )
                [ nutritionQA ]
            ]


nutritionQA : BlogArticle
nutritionQA =
    { articleName = String.toUpper "Nutrition Q&A"
    , articleLink = ""
    , articleAuthor = ""
    , isNewTabLink = False
    , hasReferences = False
    , hasTableOfContents = False
    , articleImage = ""
    , articlePublished = ""
    , articleBody = """
This service is designed to help those interested in honing their nutrition science knowledge and boosting their intuition when reading nutrition science literature. Whether the client's goals are to achieve their academic ambitions, satisfy their personal curiosity, or improve their empirical debate chops. The client is free to guide the session in any direction they choose, so long as it is relevant to nutrition science.

# BENEFITS

1. One hour to ask me anything about nutrition science.

2. Access to nutrition science evaluation cheat sheets.

3. Sharper nutrition science critical appraisal skills.

# REQUIREMENTS

• A list of five clear questions related to nutrition science.

"""
    , articleReferences =
        [ { author = ""
          , title = ""
          , journal = ""
          , year = ""
          , link = ""
          }
        ]
    }
