feat(transaction): #114 add error filter
This commit was merged in pull request #116.
This commit is contained in:
@@ -53,6 +53,7 @@ func (h TransactionImpl) handleTransactionPage() http.HandlerFunc {
|
|||||||
filter := types.TransactionItemsFilter{
|
filter := types.TransactionItemsFilter{
|
||||||
AccountId: r.URL.Query().Get("account-id"),
|
AccountId: r.URL.Query().Get("account-id"),
|
||||||
TreasureChestId: r.URL.Query().Get("treasure-chest-id"),
|
TreasureChestId: r.URL.Query().Get("treasure-chest-id"),
|
||||||
|
Error: r.URL.Query().Get("error"),
|
||||||
}
|
}
|
||||||
|
|
||||||
transactions, err := h.s.GetAll(user, filter)
|
transactions, err := h.s.GetAll(user, filter)
|
||||||
|
|||||||
@@ -254,7 +254,12 @@ func (s TransactionImpl) GetAll(user *types.User, filter types.TransactionItemsF
|
|||||||
WHERE user_id = ?
|
WHERE user_id = ?
|
||||||
AND (? = '' OR account_id = ?)
|
AND (? = '' OR account_id = ?)
|
||||||
AND (? = '' OR treasure_chest_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)
|
err = db.TransformAndLogDbError("transaction GetAll", nil, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -41,6 +41,17 @@ templ Transaction(items templ.Component, filter types.TransactionItemsFilter, ac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</select>
|
</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>
|
</form>
|
||||||
<button
|
<button
|
||||||
hx-get="/transaction/new"
|
hx-get="/transaction/new"
|
||||||
|
|||||||
@@ -49,4 +49,5 @@ type TransactionInput struct {
|
|||||||
type TransactionItemsFilter struct {
|
type TransactionItemsFilter struct {
|
||||||
AccountId string
|
AccountId string
|
||||||
TreasureChestId string
|
TreasureChestId string
|
||||||
|
Error string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user