From 94b2b1e50ccf52dc7d3f85e8de2944db33184df6 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 16 Jan 2025 12:32:07 -0500 Subject: [PATCH] fix: Adds missing delete button from employee view. --- Sources/App/Views/Employees/EmployeeForm.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/App/Views/Employees/EmployeeForm.swift b/Sources/App/Views/Employees/EmployeeForm.swift index 525a22f..a727710 100644 --- a/Sources/App/Views/Employees/EmployeeForm.swift +++ b/Sources/App/Views/Employees/EmployeeForm.swift @@ -46,6 +46,17 @@ struct EmployeeForm: HTML { button(.type(.submit), .class("btn-primary")) { buttonLabel } + if let employee { + Button.danger { + "Delete" + } + .attributes( + .hx.delete("/api/v1/employees/\(employee.id)"), + .hx.confirm("Are you sure you want to delete this employee?"), + .hx.target("#employee_\(employee.id)"), + .hx.swap(.outerHTML.transition(true).swap("1s")) + ) + } } } }