delphi.market/server/router/pages/market.templ

47 lines
1.3 KiB
Plaintext
Raw Normal View History

package pages
import (
"git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components"
"git.ekzyis.com/ekzyis/delphi.market/types"
"github.com/dustin/go-humanize"
2024-08-25 05:48:00 +00:00
"strconv"
"fmt"
)
// TODO: Add countdown? Use or at least show somewhere precise timestamps?
2024-08-25 05:48:00 +00:00
templ Market(m types.Market, p types.MarketP) {
<html>
@components.Head()
<body class="container">
@components.Nav()
<div id="content" class="flex flex-col">
<small>
@components.Figlet("random", "market")
</small>
<div class="text-center font-bold my-1">{ m.Question }</div>
<div class="text-center text-muted my-1">{humanize.Time(m.EndDate)}</div>
<div class="text-center text-muted my-1"></div>
<blockquote cite="ekzyis" class="p-4 mb-4 border-s-4 border-muted">
{ m.Description }
<div class="text-muted text-right pt-4">― {m.User.Name}, { humanize.Time(m.CreatedAt) }</div>
</blockquote>
<div class="flex justify-center my-1">
<button class="neon success mx-1">BET YES</button>
<button class="neon error mx-1">BET NO</button>
</div>
</div>
@components.Modal(nil)
@components.Footer()
</body>
</html>
2024-08-25 05:48:00 +00:00
}
func formatPrice(p float64) string {
return fmt.Sprintf("%v msats", strconv.FormatInt(pToPrice(p), 10))
}
func pToPrice(p float64) int64 {
// 0.513 means 513 msats
return int64(p * 1e3)
}