feat: Moves vendor branch views to their own files, starts to implement snapshot testing for html

This commit is contained in:
2025-01-21 09:51:11 -05:00
parent 40726c8bd7
commit 97b231767e
15 changed files with 231 additions and 71 deletions

View File

@@ -2,11 +2,9 @@ import CasePathsCore
import Foundation
@preconcurrency import URLRouting
// swiftlint:disable file_length
// TODO: Need vendor branch index route, to load branches when vendor form is displayed.
// Also need a home / index route that will redirect to login or purchase orders.
public enum ViewRoute: Sendable, Equatable {
case index
case employee(EmployeeRoute)
case login(LoginRoute)
case purchaseOrder(PurchaseOrderRoute)
@@ -15,6 +13,9 @@ public enum ViewRoute: Sendable, Equatable {
case vendorBranch(VendorBranchRoute)
public static let router = OneOf {
Route(.case(Self.index)) {
Method.get
}
Route(.case(Self.employee)) { EmployeeRoute.router }
Route(.case(Self.login)) { LoginRoute.router }
Route(.case(Self.purchaseOrder)) { PurchaseOrderRoute.router }
@@ -388,6 +389,7 @@ public extension ViewRoute {
enum VendorBranchRoute: Sendable, Equatable {
case create(VendorBranch.Create)
case delete(id: VendorBranch.ID)
case index(for: Vendor.ID? = nil)
case select(context: ViewRoute.SelectContext)
public static let router = OneOf {
@@ -406,6 +408,13 @@ public extension ViewRoute {
Path { "vendors"; "branches"; VendorBranch.ID.parser() }
Method.delete
}
Route(.case(Self.index(for:))) {
Path { "vendors"; "branches" }
Method.get
Query {
Optionally { Field("vendorID") { Vendor.ID.parser() } }
}
}
Route(.case(Self.select(context:))) {
Path { "vendors"; "branches"; "select" }
Method.get
@@ -416,5 +425,3 @@ public extension ViewRoute {
}
}
}
// swiftlint:enable file_length