package views

import (
    "strconv"    
    "mocksnow/components/core"
)

type IncomingRow struct {
	ID               int
	IncidentNumber   string
	Description      string
	ShortDescription string
	Urgency          string
	Impact           string
	State            string
	ExternalID       string
	WorkNotes        string
	AssignmentGroup  string
	AssignedTo       string
	Category         string
	Subcategory      string
	CreatedAt        string
}

templ IncomingTable(rows []IncomingRow) {
	<!DOCTYPE html>
	<html lang="en">
		@core.Header()
        <body class="flex flex-col min-h-screen bg-gray-50">
            <main class="flex-grow p-8">
                <div class="max-w-7xl mx-auto">
                    <h1 class="text-4xl font-bold mb-6 text-gray-800">Incoming Incidents</h1>
                    <div class="overflow-x-auto shadow-md sm:rounded-lg">
                        <table class="w-full text-sm text-left text-gray-600">
                            <thead class="text-xs text-gray-700 uppercase bg-gray-200">
                                <tr>
                                    <th class="px-4 py-2">ID</th>
                                    <th class="px-4 py-2">Incident #</th>
                                    <th class="px-4 py-2">Description</th>
                                    <th class="px-4 py-2">Short Description</th>
                                    <th class="px-4 py-2">Urgency</th>
                                    <th class="px-4 py-2">Impact</th>
                                    <th class="px-4 py-2">State</th>
                                    <th class="px-4 py-2">External ID</th>
                                    <th class="px-4 py-2">Work Notes</th>
                                    <th class="px-4 py-2">Assignment Group</th>
                                    <th class="px-4 py-2">Assigned To</th>
                                    <th class="px-4 py-2">Category</th>
                                    <th class="px-4 py-2">Subcategory</th>
                                    <th class="px-4 py-2">Created At</th>
                                </tr>
                            </thead>
                            <tbody>
                                for _, row := range rows {
                                <tr class="bg-white border-b hover:bg-gray-100">
                                    <td class="px-4 py-2">{ strconv.Itoa(row.ID) }</td>
                                    <td class="px-4 py-2">{ row.IncidentNumber }</td>
                                    <td class="px-4 py-2">{ row.Description }</td>
                                    <td class="px-4 py-2">{ row.ShortDescription }</td>
                                    <td class="px-4 py-2">{ row.Urgency }</td>
                                    <td class="px-4 py-2">{ row.Impact }</td>
                                    <td class="px-4 py-2">{ row.State }</td>
                                    <td class="px-4 py-2">{ row.ExternalID }</td>
                                    <td class="px-4 py-2">{ row.WorkNotes }</td>
                                    <td class="px-4 py-2">{ row.AssignmentGroup }</td>
                                    <td class="px-4 py-2">{ row.AssignedTo }</td>
                                    <td class="px-4 py-2">{ row.Category }</td>
                                    <td class="px-4 py-2">{ row.Subcategory }</td>
                                    <td class="px-4 py-2">{ row.CreatedAt }</td>
                                </tr>
                                }
                            </tbody>
                        </table>
                    </div>
                </div>
            </main>
			@core.Footer()            
        </body>
	</html>
}