diff --git a/server/router/pages/components/marketForm.templ b/server/router/pages/components/marketForm.templ index 9ca09a0..ef51ebf 100644 --- a/server/router/pages/components/marketForm.templ +++ b/server/router/pages/components/marketForm.templ @@ -4,6 +4,7 @@ import ( "fmt" "git.ekzyis.com/ekzyis/delphi.market/types" "strconv" + "math" ) templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) { @@ -18,14 +19,16 @@ templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) { >
- -
{ formatPrice(q.AvgPrice) }
- + +
{ formatPrice(q.AvgPrice, 3) }
+ - -
{ formatPrice(q.TotalPrice) }
- -
+{ formatPrice(q.Reward) }
+ +
{ formatPrice(q.TotalPrice, 3) }
+ + +{ formatPrice(q.Reward, 3) }
{ fmt.Sprint(uQ) }
@@ -61,6 +64,17 @@ func hxIndicator(outcome int) string { formId(outcome), formId(outcome), formId(outcome)) } -func formatPrice(p float64) string { - return fmt.Sprintf("%v sats", strconv.FormatFloat(p, 'f', 3, 64)) +func formatPrice(p float64, n int) string { + if p == 0 || math.IsNaN(p) { + return "0 sats" + } + return fmt.Sprintf("%v sats", strconv.FormatFloat(p, 'f', n, 64)) } + +func colorize(f float64) string { + eps := 1e-5 + if f-eps > 0 { + return "text-success" + } + return "text-reset" +} \ No newline at end of file