Files
vapor-po/Sources/App/Views/Vendors/VendorTable.swift

35 lines
621 B
Swift

import Elementary
import ElementaryHTMX
import SharedModels
struct VendorTable: HTML {
let vendors: [Vendor]
var content: some HTML {
table {
thead {
th { "Name" }
th {}
th { Button.add() }
}
tbody(.id("vendor-table")) {
for vendor in vendors {
Row(vendor: vendor)
}
}
}
}
struct Row: HTML {
let vendor: Vendor
var content: some HTML<HTMLTag.tr> {
tr(.id("vendor_\(vendor.id)")) {
td { vendor.name.capitalized }
td { "(\(vendor.branches?.count ?? 0)) Branches" }
td {}
}
}
}
}