diff --git a/src/assets/htmx/category.html b/src/assets/htmx/category.html
index f551539..789aa26 100644
--- a/src/assets/htmx/category.html
+++ b/src/assets/htmx/category.html
@@ -5,7 +5,13 @@
+
+{{ template "deleteModal" }}
{{ end }}
diff --git a/src/assets/htmx/typeNew.html b/src/assets/htmx/typeNew.html
deleted file mode 100644
index 7517c09..0000000
--- a/src/assets/htmx/typeNew.html
+++ /dev/null
@@ -1,23 +0,0 @@
-{{ define "typeNew" }}
-
-{{ end }}
diff --git a/src/expenses/types.go b/src/expenses/types.go
index 9f1381e..b1fd6fe 100644
--- a/src/expenses/types.go
+++ b/src/expenses/types.go
@@ -4,7 +4,6 @@ import (
"database/sql"
"fmt"
"log"
- "strconv"
_ "github.com/mattn/go-sqlite3"
)
@@ -58,12 +57,12 @@ func GetType(typID int) (Type, error) {
query := "SELECT TypeID,TypeName " +
"FROM expenseTypes " +
- "WHERE TypeID = " + strconv.Itoa(typID)
+ "WHERE TypeID = ?"
- var nType Type
- err = db.QueryRow(query).Scan(&nType.TypeID, &nType.TypeName)
+ nType := Type{TypeID: -1}
+ err = db.QueryRow(query, typID).Scan(&nType.TypeID, &nType.TypeName)
if err != nil {
- return Type{}, nil
+ return Type{TypeID: -1}, nil
}
return nType, nil
diff --git a/src/pages/types.go b/src/pages/types.go
index 5875039..d44f3c1 100644
--- a/src/pages/types.go
+++ b/src/pages/types.go
@@ -39,6 +39,11 @@ func typePage(c *gin.Context) {
typ, err := expenses.GetType(typeID)
if err != nil {
ServerErrorView(c, "failed to retrieve requested type")
+ return
+ }
+ if typ.TypeID == -1 {
+ NotFoundView(c, fmt.Sprintf("Couldn't find type `%d`", typeID))
+ return
}
c.HTML(http.StatusOK, "terminal", gin.H{
@@ -46,6 +51,7 @@ func typePage(c *gin.Context) {
"renderNavBar": false,
"content": "type",
"type": typ,
+ "method": "put",
})
}
@@ -53,7 +59,8 @@ func newTypePage(c *gin.Context) {
c.HTML(http.StatusOK, "terminal", gin.H{
"page": "typeNew",
"renderNavBar": false,
- "content": "typeNew",
+ "content": "type",
+ "method": "post",
})
}