<commit_before>module GiftCertificates.View exposing (..)

import Html exposing (..)
import Html.Attributes exposing (class)
import Html.Events exposing (onClick)
import Material
import Material.Table as Table
import Material.Button as Button
import Material.Options as Options
import Material.Textfield as Textfield
import Material.Icon as Icon
import Material.Tabs as Tabs
import Material.Layout as Layout
import Date exposing (Date, Day(..), day, dayOfWeek, month, year)
import DatePicker exposing (DatePicker)
import GiftCertificates.Messages exposing (..)
import GiftCertificates.Models exposing (..)


type alias Mdl =
    Material.Model


view : Model -> Html Msg
view model =
    Tabs.render Mdl
        [ 10 ]
        model.mdl
        [ Tabs.ripple
        , Tabs.onSelectTab SelectTab
        , Tabs.activeTab model.tab
        ]
        [ Tabs.label
            [ Options.center ]
            [ Options.span [ Options.css "width" "4px" ] []
            , text "New"
            ]
        , Tabs.label
            [ Options.center ]
            [ Options.span [ Options.css "width" "4px" ] []
            , text "Reports"
            ]
        , Tabs.label
            [ Options.center ]
            [ Options.span [ Options.css "width" "4px" ] []
            , text "Redeem"
            ]
        ]
        [ Options.div
            [ Options.center
            ]
            [ case model.tab of
                0 ->
                    newTab model

                1 ->
                    reportsTab model

                2 ->
                    redeemTab model

                _ ->
                    newTab model
            ]
        ]


newTab : Model -> Html Msg
newTab model =
    Options.div
        []
        [ addGiftCertificateView model
        , table model.giftCertificates
        ]


reportsTab : Model -> Html Msg
reportsTab model =
    Options.div
        [ Options.css "margin" "50px 25px"
        ]
        [ text "From"
        , DatePicker.view model.beginDatePicker
            |> Html.map ToBeginDatePicker
        , text "To"
        , DatePicker.view model.endDatePicker
            |> Html.map ToEndDatePicker
        , loadReportsButton model
        , table model.giftCertificates
        ]


loadReportsButton : Model -> Html Msg
loadReportsButton model =
    Button.render Mdl
        [ 13 ]
        model.mdl
        [ Button.raised
        , case model.beginDate of
            Just beginDate ->
                case model.endDate of
                    Just endDate ->
                        Button.colored

                    _ ->
                        Button.disabled

            _ ->
                Button.disabled
        , Options.onClick FetchGiftCertificatesByDates
        , Options.css "margin" "50px 25px"
        ]
        [ Icon.i "load" ]


redeemTab : Model -> Html Msg
redeemTab model =
    Options.div
        []
        [ redeemTextField model
        , redeemButton model
        ]


redeemButton : Model -> Html Msg
redeemButton model =
    Button.render Mdl
        [ 12 ]
        model.mdl
        [ Button.raised
        , if model.redeemId == "" then
            Button.disabled
          else
            Button.colored<commit_msg>Center reports elements<commit_after>module GiftCertificates.View exposing (..)

import Html exposing (..)
import Html.Attributes exposing (class)
import Html.Events exposing (onClick)
import Material
import Material.Table as Table
import Material.Button as Button
import Material.Options as Options
import Material.Textfield as Textfield
import Material.Icon as Icon
import Material.Tabs as Tabs
import Material.Layout as Layout
import Date exposing (Date, Day(..), day, dayOfWeek, month, year)
import DatePicker exposing (DatePicker)
import GiftCertificates.Messages exposing (..)
import GiftCertificates.Models exposing (..)


type alias Mdl =
    Material.Model


view : Model -> Html Msg
view model =
    Tabs.render Mdl
        [ 10 ]
        model.mdl
        [ Tabs.ripple
        , Tabs.onSelectTab SelectTab
        , Tabs.activeTab model.tab
        ]
        [ Tabs.label
            [ Options.center ]
            [ Options.span [ Options.css "width" "4px" ] []
            , text "New"
            ]
        , Tabs.label
            [ Options.center ]
            [ Options.span [ Options.css "width" "4px" ] []
            , text "Reports"
            ]
        , Tabs.label
            [ Options.center ]
            [ Options.span [ Options.css "width" "4px" ] []
            , text "Redeem"
            ]
        ]
        [ Options.div
            [ Options.center
            ]
            [ case model.tab of
                0 ->
                    newTab model

                1 ->
                    reportsTab model

                2 ->
                    redeemTab model

                _ ->
                    newTab model
            ]
        ]


newTab : Model -> Html Msg
newTab model =
    Options.div
        []
        [ addGiftCertificateView model
        , table model.giftCertificates
        ]


reportsTab : Model -> Html Msg
reportsTab model =
    Options.div
        [ Options.css "margin" "50px 25px"
        , Options.css "text-align" "center"
        ]
        [ Options.div
            [ Options.css "margin" "auto"
            ]
            [ text "From "
            , DatePicker.view model.beginDatePicker
                |> Html.map ToBeginDatePicker
            , text "To "
            , DatePicker.view model.endDatePicker
                |> Html.map ToEndDatePicker
            ]
        , loadReportsButton model
        , table model.giftCertificates
        ]


loadReportsButton : Model -> Html Msg
loadReportsButton model =
    Button.render Mdl
        [ 13 ]
        model.mdl
        [ Button.raised
        , case model.beginDate of
            Just beginDate ->
                case model.endDate of
                    Just endDate ->
                        Button.colored

                    _ ->
                        Button.disabled

            _ ->
                Button.disabled
        , Options.onClick FetchGiftCertificatesByDates
        , Options.css "margin" "50px 25px"
        ]
        [ Icon.i "add" ]


redeemTab : Model -> Html Msg
redeemTab model =
    Options.div
        []
        [ redeemTextField model
        , redeemButton model
        ]


redeemButton : Model -> Html Msg
redeemButton model =
    Button.render Mdl
        [ 12 ]
        model.mdl
        [ Button.raised
        , if model.redeemId == "" then
            Button.disabled
          else
            Button.colored
{'fraction_non_alphanumeric': 0.07986058493711168, 'fraction_numerical': 0.006061524473405061, 'mean_word_length': 1.397384671267708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5691679', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1738, 'n_words': 448}