summaryrefslogtreecommitdiffhomepage
path: root/template/coins_mintages.templ
blob: 894cb75b79c4d3b7c164e517f9f0e9d697b9d93b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package template

import (
	"strconv"

	"git.thomasvoss.com/euro-cash.eu/lib"
	"git.thomasvoss.com/euro-cash.eu/lib/mintage"
)

const muntrolpakketLinkStart = `<a href="#TODO">`

var denoms = [...]float64{
	0.01, 0.02, 0.05, 0.10,
	0.20, 0.50, 1.00, 2.00,
}

templ CoinsMintages() {
	{{
		code := ctx.Value("code").(string)
		data := ctx.Value("mintages").(mintage.Data)
		ctype := ctx.Value("type").(string)
		p := ctx.Value("printer").(lib.Printer)
	}}
	<header>
		@navbar()
		<h1>{ p.T("Euro Coin Mintages") }</h1>
	</header>
	<main>
		<p>
			{ p.T("Here you’ll be able to view all the known mintages for all coins. You’ll also be able to filter on country, denomination, etc. If you have any mintage data that’s missing from our site, feel free to contact us.") }
		</p>
		<hr/>
		if code == "nl" {
			<h2>{ p.T("Additional Notes") }</h2>
			<ul>
				<li>
					@templ.Raw(p.T("Most coins from the years 2003–2016 are listed as NIFC coins while other popular sources such as Numista claim they were minted for circulation. For more information on why others are wrong, %sclick here%s.", muntrolpakketLinkStart, linkEnd))
				</li>
				<li>
					{ p.T("In 2003 Numista calculated a total of %d coins issued for coin sets per denomination. Our own calculations found only %d. Numista also forgot to include the many hundred thousand coins from the coin roll sets that were produced.", 217503, 177003) }
				</li>
			</ul>
		}
		<section>
			<form>
				<div class="grid">
					<label for="country-dd">
						{ p.T("Country") }
						<select id="country-dd" name="code">
							for _, c := range ctx.Value("countries").
								([]lib.Country) {
								<option
									value={ c.Code }
									selected?={ c.Code == code }
								>
									{ c.Name }
								</option>
							}
						</select>
					</label>
					<fieldset>
						@coinTypeRadio(ctype, "circ", p.T("Circulation Coins"))
						@coinTypeRadio(ctype, "nifc", p.T("NIFC / BU Sets"))
						@coinTypeRadio(ctype, "proof", p.T("Proof Coins"))
					</fieldset>
				</div>
				<button type="submit">{ p.T("Filter") }</button>
			</form>
			<figure>
				<figcaption>{ p.T("Standard Issue Coins") }</figcaption>
				<table class="mintage-table" role="grid">
					<thead>
						<th>{ p.T("Year") }</th>
						for _, x := range denoms {
							<th>{ p.Money(x, false) }</th>
						}
					</thead>
					<tbody>
						for _, row := range data.Standard {
							<tr>
								<th scope="col">
									if len(row.Mintmark) != 0 {
										{ strconv.Itoa(row.Year) }&nbsp;<sub><small>{ row.Mintmark }</small></sub>
									} else {
										{ strconv.Itoa(row.Year) }
									}
								</th>
								for _, col := range row.Mintages[strToCtype(ctype)] {
									switch col {
										case mintage.Unknown:
											<td>{ p.T("Unknown") }</td>
										case 0:
											<td>—</td>
										default:
											<td>{ p.N(col) }</td>
									}
								}
							</tr>
						}
					</tbody>
				</table>
			</figure>
			if len(data.Commemorative) != 0 {
				<figure>
					<figcaption>{ p.T("Commemorative Coins") }</figcaption>
					<table class="mintage-table-cc" role="grid">
						<thead>
							<th>{ p.T("Year") }</th>
							<th>{ p.T("Commemorated Issue") }</th>
							<th>{ p.T("Mintage") }</th>
						</thead>
						<tbody>
							for _, row := range data.Commemorative {
								<tr>
									<th scope="col">
										if len(row.Mintmark) != 0 {
											{ strconv.Itoa(row.Year) }&nbsp;<sub><small>{ row.Mintmark }</small></sub>
										} else {
											{ strconv.Itoa(row.Year) }
										}
									</th>
									<!-- TODO: Translate commemorative names! -->
									<td>{ row.Name }</td>
									switch row.Mintage[strToCtype(ctype)] {
										case mintage.Unknown:
											<td>{ p.T("Unknown") }</td>
										case 0:
											<td>—</td>
										default:
											<td>{ p.N(row.Mintage[strToCtype(ctype)]) }</td>
									}
								</tr>
							}
						</tbody>
					</table>
				</figure>
			}
		</section>
	</main>
}

templ coinTypeRadio(ctype, short, long string) {
	<label for={ "compact-" + short }>
		<input
			id={ "compact-" + short }
			type="radio"
			name="type"
			value={ short }
			checked?={ ctype == short }
		/>
		{ long }
	</label>
}

func strToCtype(s string) int {
	switch s {
	case "circ":
		return mintage.TypeCirc
	case "nifc":
		return mintage.TypeNIFC
	case "proof":
		return mintage.TypeProof
	}

	/* Should never happen, but just incase */
	return mintage.TypeCirc
}