aboutsummaryrefslogtreecommitdiff
path: root/front/src
diff options
context:
space:
mode:
authorGuillermo Ramos2025-03-06 20:01:15 +0100
committerGuillermo Ramos2025-03-06 23:26:15 +0100
commit21352bf0dd245c747fe265abbd9b6283d7a088bd (patch)
treeab269639c70f619b16a4e6ac0dabc644ae045254 /front/src
parent2a493c121edefd21d2c25f6a175fce53d3e082c1 (diff)
downloadhiccup-21352bf0dd245c747fe265abbd9b6283d7a088bd.tar.gz
Not xxxTxt anymore
Diffstat (limited to 'front/src')
-rw-r--r--front/src/Main.elm94
1 files changed, 47 insertions, 47 deletions
diff --git a/front/src/Main.elm b/front/src/Main.elm
index 7f25043..4ead1d6 100644
--- a/front/src/Main.elm
+++ b/front/src/Main.elm
@@ -87,24 +87,24 @@ type alias Simulation =
type alias SimSpecsRaw =
- { titleTxt : String
- , totalValueTxt : String
- , initialTxt : String
- , financedRateTxt : String
- , i1Txt : String
- , yearsTxt : String
+ { title : String
+ , totalValue : String
+ , initial : String
+ , financedRate : String
+ , i1 : String
+ , years : String
}
simSpecsParse : SimSpecsRaw -> Maybe SimSpecs
-simSpecsParse { totalValueTxt, financedRateTxt, i1Txt, yearsTxt } =
+simSpecsParse { totalValue, financedRate, i1, years } =
case
- ( List.map String.toFloat [ totalValueTxt, i1Txt ]
- , List.map String.toInt [ financedRateTxt, yearsTxt ]
+ ( List.map String.toFloat [ totalValue, i1 ]
+ , List.map String.toInt [ financedRate, years ]
)
of
- ( [ Just totalValue, Just i1 ], [ Just rate, Just years ] ) ->
- Just { principal = totalValue * toFloat rate / 100, i1 = i1, years = years }
+ ( [ Just totalValueF, Just i1F ], [ Just rate, Just yearsI ] ) ->
+ Just { principal = totalValueF * toFloat rate / 100, i1 = i1F, years = yearsI }
_ ->
Nothing
@@ -161,12 +161,12 @@ init : () -> ( Model, Cmd Msg )
init () =
let
simSpecsRaw =
- { titleTxt = ""
- , totalValueTxt = "200000"
- , financedRateTxt = "80"
- , initialTxt = "40000"
- , i1Txt = "1.621"
- , yearsTxt = "30"
+ { title = ""
+ , totalValue = "200000"
+ , financedRate = "80"
+ , initial = "40000"
+ , i1 = "1.621"
+ , years = "30"
}
in
( { error = "", simSpecsRaw = simSpecsRaw, expandedYears = Set.empty, simulation = Nothing }, Cmd.none )
@@ -196,10 +196,10 @@ rateToInitial rate principal =
convertInitialRate : (Float -> Int -> Float) -> String -> String -> Maybe String
-convertInitialRate convert val totalValueTxt =
- case ( String.toFloat val, String.toInt totalValueTxt ) of
- ( Just x, Just totalValue ) ->
- Just <| String.fromFloat <| convert x totalValue
+convertInitialRate convert val totalValue =
+ case ( String.toFloat val, String.toInt totalValue ) of
+ ( Just x, Just totalValueF ) ->
+ Just <| String.fromFloat <| convert x totalValueF
_ ->
Nothing
@@ -223,7 +223,7 @@ update msg model =
( { model
| simulation =
Just
- { initial = Maybe.withDefault 0 <| String.toFloat m.simSpecsRaw.initialTxt
+ { initial = Maybe.withDefault 0 <| String.toFloat m.simSpecsRaw.initial
, financed = financed
}
}
@@ -244,37 +244,37 @@ update msg model =
newSimSpecsTxt =
case u of
Title ->
- { simSpecsRaw | titleTxt = val }
+ { simSpecsRaw | title = val }
Principal ->
{ simSpecsRaw
- | totalValueTxt = val
- , initialTxt =
- Maybe.withDefault simSpecsRaw.initialTxt <|
- convertInitialRate rateToInitial simSpecsRaw.financedRateTxt val
+ | totalValue = val
+ , initial =
+ Maybe.withDefault simSpecsRaw.initial <|
+ convertInitialRate rateToInitial simSpecsRaw.financedRate val
}
Rate ->
{ simSpecsRaw
- | financedRateTxt = val
- , initialTxt =
- Maybe.withDefault simSpecsRaw.initialTxt <|
- convertInitialRate rateToInitial val simSpecsRaw.totalValueTxt
+ | financedRate = val
+ , initial =
+ Maybe.withDefault simSpecsRaw.initial <|
+ convertInitialRate rateToInitial val simSpecsRaw.totalValue
}
Initial ->
{ simSpecsRaw
- | initialTxt = val
- , financedRateTxt =
- Maybe.withDefault simSpecsRaw.financedRateTxt <|
- convertInitialRate initialToRate val simSpecsRaw.totalValueTxt
+ | initial = val
+ , financedRate =
+ Maybe.withDefault simSpecsRaw.financedRate <|
+ convertInitialRate initialToRate val simSpecsRaw.totalValue
}
I1 ->
- { simSpecsRaw | i1Txt = val }
+ { simSpecsRaw | i1 = val }
Years ->
- { simSpecsRaw | yearsTxt = val }
+ { simSpecsRaw | years = val }
in
( { model | simSpecsRaw = newSimSpecsTxt }, Cmd.none )
@@ -328,7 +328,7 @@ errorToString error =
specsView : SimSpecsRaw -> Html Msg
specsView simSpecsRaw =
let
- { titleTxt, totalValueTxt, financedRateTxt, initialTxt, i1Txt, yearsTxt } =
+ { title, totalValue, financedRate, initial, i1, years } =
simSpecsRaw
simSpecs =
@@ -347,7 +347,7 @@ specsView simSpecsRaw =
[ input
[ class "min-w-full mb-2 py-1 px-3 text-xl font-bold lime-100"
, placeholder "Title..."
- , value titleTxt
+ , value title
, onInput (UpdateSimSpecs Title)
]
[]
@@ -360,11 +360,11 @@ specsView simSpecsRaw =
, Html.Attributes.min "0"
, Html.Attributes.max "1000000"
, step "5000"
- , value totalValueTxt
+ , value totalValue
, onInput (UpdateSimSpecs Principal)
]
[]
- , text totalValueTxt
+ , text totalValue
]
, div [ class "flex my-1" ]
[ div [ class "" ]
@@ -372,8 +372,8 @@ specsView simSpecsRaw =
, input
[ class "w-[100px] border border-lime-500 border-2 px-2 focus:outline focus:outline-lime-500"
, Html.Attributes.min "0"
- , Html.Attributes.max totalValueTxt
- , value initialTxt
+ , Html.Attributes.max totalValue
+ , value initial
, onInput (UpdateSimSpecs Initial)
]
[]
@@ -384,7 +384,7 @@ specsView simSpecsRaw =
[ class "w-[55px] border border-lime-500 border-2 px-2 focus:outline focus:outline-lime-500"
, Html.Attributes.min "10"
, Html.Attributes.max "100"
- , value financedRateTxt
+ , value financedRate
, onInput (UpdateSimSpecs Rate)
]
[]
@@ -397,7 +397,7 @@ specsView simSpecsRaw =
[ class "w-[80px] border border-lime-500 border-2 px-2 focus:outline focus:outline-lime-500"
, Html.Attributes.min "0"
, Html.Attributes.max "100"
- , value i1Txt
+ , value i1
, onInput (UpdateSimSpecs I1)
]
[]
@@ -411,11 +411,11 @@ specsView simSpecsRaw =
, Html.Attributes.min "1"
, Html.Attributes.max "50"
, step "1"
- , value yearsTxt
+ , value years
, onInput (UpdateSimSpecs Years)
]
[]
- , text yearsTxt
+ , text years
]
, button (butAttrs ++ simButAttrs) [ text "Simulate" ]
]