package treasure_chest import ( "github.com/google/uuid" "spend-sparrow/internal/core" "spend-sparrow/internal/template/svg" "spend-sparrow/internal/treasure_chest_types" ) templ TreasureChestComp(treasureChests []*treasure_chest_types.TreasureChest, monthlySums map[uuid.UUID]int64) {
for _, treasureChest := range treasureChests { @TreasureChestItem(treasureChest, monthlySums) }
} templ EditTreasureChest(treasureChest *treasure_chest_types.TreasureChest, parents []*treasure_chest_types.TreasureChest, transactionsRecurring templ.Component) { {{ var ( id string name string parentId uuid.UUID cancelUrl string ) indentation := " mt-10" if treasureChest == nil { id = "new" name = "" parentId = uuid.Nil cancelUrl = "/empty" } else { id = treasureChest.Id.String() name = treasureChest.Name if treasureChest.ParentId != nil { parentId = *treasureChest.ParentId indentation = " mt-2 ml-14" } cancelUrl = "/treasurechest/" + id } }}
if id != "new" {

Monthly Transactions

@transactionsRecurring }
} templ TreasureChestItem(treasureChest *treasure_chest_types.TreasureChest, monthlySums map[uuid.UUID]int64) { {{ var indentation string viewTransactions := "" if treasureChest.ParentId != nil { indentation = " mt-2 ml-14" } else { indentation = " mt-10" viewTransactions = "hidden" } }}

{ treasureChest.Name }

if treasureChest.ParentId != nil { + { core.FormatEuros(monthlySums[treasureChest.Id]) }  per month }

if treasureChest.ParentId != nil { if treasureChest.CurrentBalance < 0 {

{ core.FormatEuros(treasureChest.CurrentBalance) }

} else {

{ core.FormatEuros(treasureChest.CurrentBalance) }

} } @svg.Eye() View
} func filterNoChildNoSelf(nodes []*treasure_chest_types.TreasureChest, selfId string) []*treasure_chest_types.TreasureChest { var result []*treasure_chest_types.TreasureChest for _, node := range nodes { if node.ParentId == nil && node.Id.String() != selfId { result = append(result, node) } } return result }