package treasurechest import "spend-sparrow/internal/template/svg" import "spend-sparrow/internal/types" import "github.com/google/uuid" templ TreasureChest(treasureChests []*types.TreasureChest, monthlySums map[uuid.UUID]int64) {
for _, treasureChest := range treasureChests { @TreasureChestItem(treasureChest, monthlySums) }
} templ EditTreasureChest(treasureChest *types.TreasureChest, parents []*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 *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 { + { types.FormatEuros(monthlySums[treasureChest.Id]) }  per month }

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

{ types.FormatEuros(treasureChest.CurrentBalance) }

} else {

{ types.FormatEuros(treasureChest.CurrentBalance) }

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