package components

import "gitea.henriburau.de/haw-lan/cod4watcher/models"
import "strconv"

templ CaptureTable(table models.ResultTable) {
	<div class="relative overflow-x-auto">
		<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
			<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
				<tr>
					for _, header := range table.Header {
						<th scope="col" class="px-6 py-3">
							<div>
								{ header.Title }
							</div>
							<div class="lowercase font-light">
								{ header.Subtitle }
							</div>
						</th>
					}
				</tr>
			</thead>
			<tbody>
				for _, row := range table.Rows {
					<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
						<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
							{ row.Name }
						</th>
						<td class="px-6 py-4">
							{ strconv.Itoa(row.Total) }
						</td>
						for _, score := range row.Individual {
							<td class="px-6 py-4">
								{ strconv.Itoa(score) }
							</td>
						}
					</tr>
				}
			</tbody>
		</table>
	</div>
}
