diff --git a/internal/dashboard/handler.go b/internal/dashboard/handler.go
index b936037..a111b0f 100644
--- a/internal/dashboard/handler.go
+++ b/internal/dashboard/handler.go
@@ -6,7 +6,7 @@ import (
"net/http"
"spend-sparrow/internal/core"
"spend-sparrow/internal/dashboard/template"
- "spend-sparrow/internal/service"
+ "spend-sparrow/internal/treasure_chest"
"spend-sparrow/internal/utils"
"strings"
"time"
@@ -21,10 +21,10 @@ type Handler interface {
type HandlerImpl struct {
r *core.Render
s *Service
- treasureChest service.TreasureChest
+ treasureChest treasure_chest.Service
}
-func NewHandler(r *core.Render, s *Service, treasureChest service.TreasureChest) Handler {
+func NewHandler(r *core.Render, s *Service, treasureChest treasure_chest.Service) Handler {
return HandlerImpl{
r: r,
s: s,
diff --git a/internal/dashboard/service.go b/internal/dashboard/service.go
index 06c131b..29631d6 100644
--- a/internal/dashboard/service.go
+++ b/internal/dashboard/service.go
@@ -4,7 +4,8 @@ import (
"context"
"spend-sparrow/internal/auth_types"
"spend-sparrow/internal/core"
- "spend-sparrow/internal/service"
+ "spend-sparrow/internal/treasure_chest"
+ "spend-sparrow/internal/treasure_chest_types"
"spend-sparrow/internal/types"
"time"
@@ -90,14 +91,14 @@ func (s Service) TreasureChests(
return nil, core.ErrUnauthorized
}
- treasureChests := make([]*types.TreasureChest, 0)
+ treasureChests := make([]*treasure_chest_types.TreasureChest, 0)
err := s.db.SelectContext(ctx, &treasureChests, `SELECT * FROM treasure_chest WHERE user_id = ?`, user.Id)
err = core.TransformAndLogDbError(ctx, "dashboard TreasureChests", nil, err)
if err != nil {
return nil, err
}
- treasureChests = service.SortTreasureChests(treasureChests)
+ treasureChests = treasure_chest.SortTreasureChests(treasureChests)
result := make([]*DashboardTreasureChest, 0)
diff --git a/internal/dashboard/template/dashboard.templ b/internal/dashboard/template/dashboard.templ
index 9fe8241..d4c364c 100644
--- a/internal/dashboard/template/dashboard.templ
+++ b/internal/dashboard/template/dashboard.templ
@@ -1,8 +1,8 @@
package template
-import "spend-sparrow/internal/types"
+import "spend-sparrow/internal/treasure_chest_types"
-templ Dashboard(treasureChests []*types.TreasureChest) {
+templ Dashboard(treasureChests []*treasure_chest_types.TreasureChest) {
diff --git a/internal/default.go b/internal/default.go
index 6dffd69..4ba27a9 100644
--- a/internal/default.go
+++ b/internal/default.go
@@ -15,6 +15,7 @@ import (
"spend-sparrow/internal/handler/middleware"
"spend-sparrow/internal/log"
"spend-sparrow/internal/service"
+ "spend-sparrow/internal/treasure_chest"
"spend-sparrow/internal/types"
"sync"
"syscall"
@@ -116,7 +117,7 @@ func createHandlerWithServices(ctx context.Context, d *sqlx.DB, serverSettings *
authService := authentication.NewService(authDb, randomService, clockService, mailService, serverSettings)
accountService := account.NewServiceImpl(d, randomService, clockService)
- treasureChestService := service.NewTreasureChest(d, randomService, clockService)
+ treasureChestService := treasure_chest.NewService(d, randomService, clockService)
transactionService := service.NewTransaction(d, randomService, clockService)
transactionRecurringService := service.NewTransactionRecurring(d, randomService, clockService, transactionService)
dashboardService := dashboard.NewService(d)
@@ -126,7 +127,7 @@ func createHandlerWithServices(ctx context.Context, d *sqlx.DB, serverSettings *
dashboardHandler := dashboard.NewHandler(render, dashboardService, treasureChestService)
authHandler := authentication.NewHandler(authService, render)
accountHandler := account.NewHandler(accountService, render)
- treasureChestHandler := handler.NewTreasureChest(treasureChestService, transactionRecurringService, render)
+ treasureChestHandler := treasure_chest.NewHandler(treasureChestService, transactionRecurringService, render)
transactionHandler := handler.NewTransaction(transactionService, accountService, treasureChestService, render)
transactionRecurringHandler := handler.NewTransactionRecurring(transactionRecurringService, render)
diff --git a/internal/handler/transaction.go b/internal/handler/transaction.go
index 5e330fa..b6cfe6e 100644
--- a/internal/handler/transaction.go
+++ b/internal/handler/transaction.go
@@ -8,6 +8,8 @@ import (
"spend-sparrow/internal/core"
"spend-sparrow/internal/service"
t "spend-sparrow/internal/template/transaction"
+ "spend-sparrow/internal/treasure_chest"
+ "spend-sparrow/internal/treasure_chest_types"
"spend-sparrow/internal/types"
"spend-sparrow/internal/utils"
"strconv"
@@ -24,11 +26,11 @@ type Transaction interface {
type TransactionImpl struct {
s service.Transaction
account account.Service
- treasureChest service.TreasureChest
+ treasureChest treasure_chest.Service
r *core.Render
}
-func NewTransaction(s service.Transaction, account account.Service, treasureChest service.TreasureChest, r *core.Render) Transaction {
+func NewTransaction(s service.Transaction, account account.Service, treasureChest treasure_chest.Service, r *core.Render) Transaction {
return TransactionImpl{
s: s,
account: account,
@@ -280,7 +282,7 @@ func (h TransactionImpl) handleDeleteTransaction() http.HandlerFunc {
}
}
-func (h TransactionImpl) getTransactionData(accounts []*account.Account, treasureChests []*types.TreasureChest) (map[uuid.UUID]string, map[uuid.UUID]string) {
+func (h TransactionImpl) getTransactionData(accounts []*account.Account, treasureChests []*treasure_chest_types.TreasureChest) (map[uuid.UUID]string, map[uuid.UUID]string) {
accountMap := make(map[uuid.UUID]string, 0)
for _, account := range accounts {
accountMap[account.Id] = account.Name
diff --git a/internal/service/transaction.go b/internal/service/transaction.go
index bffe587..ecf7784 100644
--- a/internal/service/transaction.go
+++ b/internal/service/transaction.go
@@ -7,6 +7,7 @@ import (
"log/slog"
"spend-sparrow/internal/auth_types"
"spend-sparrow/internal/core"
+ "spend-sparrow/internal/treasure_chest_types"
"spend-sparrow/internal/types"
"strconv"
"time"
@@ -485,7 +486,7 @@ func (s TransactionImpl) validateAndEnrichTransaction(ctx context.Context, tx *s
}
if input.TreasureChestId != nil {
- var treasureChest types.TreasureChest
+ var treasureChest treasure_chest_types.TreasureChest
err = tx.GetContext(ctx, &treasureChest, `SELECT * FROM treasure_chest WHERE id = ? AND user_id = ?`, input.TreasureChestId, userId)
err = core.TransformAndLogDbError(ctx, "transaction validate", nil, err)
if err != nil {
diff --git a/internal/service/transaction_recurring.go b/internal/service/transaction_recurring.go
index 72769d2..1ac0b6b 100644
--- a/internal/service/transaction_recurring.go
+++ b/internal/service/transaction_recurring.go
@@ -8,6 +8,7 @@ import (
"math"
"spend-sparrow/internal/auth_types"
"spend-sparrow/internal/core"
+ "spend-sparrow/internal/treasure_chest_types"
"spend-sparrow/internal/types"
"strconv"
"time"
@@ -444,7 +445,7 @@ func (s TransactionRecurringImpl) validateAndEnrichTransactionRecurring(
return nil, fmt.Errorf("could not parse treasureChestId: %w", core.ErrBadRequest)
}
treasureChestUuid = &temp
- var treasureChest types.TreasureChest
+ var treasureChest treasure_chest_types.TreasureChest
err = tx.GetContext(ctx, &treasureChest, `SELECT * FROM treasure_chest WHERE id = ? AND user_id = ?`, treasureChestUuid, userId)
err = core.TransformAndLogDbError(ctx, "transactionRecurring validate", nil, err)
if err != nil {
diff --git a/internal/template/transaction/transaction.templ b/internal/template/transaction/transaction.templ
index e55b208..a5a1a34 100644
--- a/internal/template/transaction/transaction.templ
+++ b/internal/template/transaction/transaction.templ
@@ -1,13 +1,16 @@
package transaction
-import "fmt"
-import "time"
-import "spend-sparrow/internal/template/svg"
-import "spend-sparrow/internal/types"
-import "spend-sparrow/internal/account"
-import "github.com/google/uuid"
+import (
+ "fmt"
+ "github.com/google/uuid"
+ "spend-sparrow/internal/account"
+ "spend-sparrow/internal/template/svg"
+ "spend-sparrow/internal/treasure_chest_types"
+ "spend-sparrow/internal/types"
+ "time"
+)
-templ Transaction(items templ.Component, filter types.TransactionItemsFilter, accounts []*account.Account, treasureChests []*types.TreasureChest) {
+templ Transaction(items templ.Component, filter types.TransactionItemsFilter, accounts []*account.Account, treasureChests []*treasure_chest_types.TreasureChest) {