<!DOCTYPE html>
<html>

<head>
    <title>delphi.market</title>
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
    <link rel="manifest" href="/site.webmanifest" />
    <link rel="stylesheet" href="/index.css" />
    <link rel="stylesheet" href="/market.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#091833" />
    {{ if eq .ENV "development" }}
    <script defer src="/hotreload.js"></script>
    {{ end }}
</head>

<body>
    <header class="flex flex-row text-center justify-center pt-1">
        <nav>
            <a href="/">home</a>
            {{ if .session }}
            <a href='/user'>user</a>
            {{ else }} <a href="/login">login</a> {{ end }}
        </nav>
    </header>
    <div class="container flex flex-column text-center">
        <code>
        <strong>
          <pre>
 _   _ ___  ___ _ __ 
| | | / __|/ _ \ '__|
| |_| \__ \  __/ |   
 \__,_|___/\___|_|   </pre>
        </strong>
      </code>
        <div class="font-mono mb-1 align-left word-wrap">
            <div class="mb-1">
                You are: {{substr .session.Pubkey 0 8}}
            </div>
            <div>
                <form class="align-left" action="/logout" method="post">
                    <button type="submit">logout</button>
                </form>
            </div>
        </div>
        <div class="align-left mb-1">
            <span class="font-mono mb-1"><strong>Open Orders</strong></span>
            <table class="w-100p mb-1">
                <tr>
                    <th class="align-center">Market</th>
                    <th class="align-center"></th>
                    <th class="align-center"></th>
                    <th class="align-right"></th>
                </tr>
                {{ range .Orders }}
                {{ if .Invoice.ConfirmedAt.Valid }}
                <tr class='{{ if eq .Side "BUY" }}yes{{ else }}no{{ end }}'>
                    <td class="align-center">
                        <a href="/market/{{.Share.MarketId}}">{{.Share.MarketId}}</a>
                    </td>
                    <td class="align-center">{{.Side}}</td>
                    <td class="align-center">{{.Share.Description}}</td>
                    <td class="align-right">{{.Quantity}} @ {{.Price}} ⚡</td>
                </tr>
                {{ end }}
                {{ end }}
            </table>
        </div>
        <div class="align-left mb-1">
            <span class="font-mono mb-1"><strong>Unpaid Orders</strong></span>
            <table class="w-100p mb-1">
                <tr>
                    <th class="align-center">Market</th>
                    <th class="align-center"></th>
                    <th class="align-center"></th>
                    <th class="align-right"></th>
                    <th class="align-center">Invoice</th>
                </tr>
                {{ range .Orders }}
                {{ if not .Invoice.ConfirmedAt.Valid }}
                <tr class='{{ if eq .Side "BUY" }}yes{{ else }}no{{ end }}'>
                    <td class="align-center">
                        <a href="/market/{{.Share.MarketId}}">{{.Share.MarketId}}</a>
                    </td>
                    <td class="align-center">{{.Side}}</td>
                    <td class="align-center">{{.Share.Description}}</td>
                    <td class="align-right">{{.Quantity}} @ {{.Price}} ⚡</td>
                    <td class="align-center"><a href="/invoice/{{.InvoiceId}}">invoice</a></td>
                </tr>
                {{ end }}
                {{ end }}
            </table>
        </div>
    </div>
    <footer class="flex justify-center">
        <div>
            <hr />
            <code><a href="https://github.com/ekzyis/delphi.market/commit/{{.COMMIT_LONG_SHA}}">{{.VERSION}}</a></code>
        </div>
    </footer>
</body>

</html>