feat(transaction): #114 add error filter
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m0s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m31s

This commit was merged in pull request #116.
This commit is contained in:
2025-05-19 18:55:53 +02:00
parent 8b67cfccfa
commit b18863038c
4 changed files with 19 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ func (h TransactionImpl) handleTransactionPage() http.HandlerFunc {
filter := types.TransactionItemsFilter{
AccountId: r.URL.Query().Get("account-id"),
TreasureChestId: r.URL.Query().Get("treasure-chest-id"),
Error: r.URL.Query().Get("error"),
}
transactions, err := h.s.GetAll(user, filter)

View File

@@ -254,7 +254,12 @@ func (s TransactionImpl) GetAll(user *types.User, filter types.TransactionItemsF
WHERE user_id = ?
AND (? = '' OR account_id = ?)
AND (? = '' OR treasure_chest_id = ?)
ORDER BY timestamp DESC`, user.Id, filter.AccountId, filter.AccountId, filter.TreasureChestId, filter.TreasureChestId)
AND (? = ''
OR (? = "true" AND error IS NOT NULL)
OR (? = "false" AND error IS NULL)
)
ORDER BY timestamp DESC`,
user.Id, filter.AccountId, filter.AccountId, filter.TreasureChestId, filter.TreasureChestId, filter.Error, filter.Error, filter.Error)
err = db.TransformAndLogDbError("transaction GetAll", nil, err)
if err != nil {
return nil, err

View File

@@ -41,6 +41,17 @@ templ Transaction(items templ.Component, filter types.TransactionItemsFilter, ac
}
}
</select>
<select name="error" class="bg-white input">
<option value="">- Filter Error -</option>
<option
value="true"
selected?={ filter.Error == "true" }
>Has Errors</option>
<option
value="false"
selected?={ filter.Error == "false" }
>Has no Errors</option>
</select>
</form>
<button
hx-get="/transaction/new"

View File

@@ -49,4 +49,5 @@ type TransactionInput struct {
type TransactionItemsFilter struct {
AccountId string
TreasureChestId string
Error string
}