feat(budget): rename description to name
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 1m25s

This commit is contained in:
2026-01-06 19:41:26 +01:00
parent faf28b559a
commit 70d6110bc4
7 changed files with 33 additions and 26 deletions

View File

@@ -27,9 +27,9 @@ func NewDbSqlite(db *sqlx.DB) *DbSqlite {
func (db DbSqlite) Insert(ctx context.Context, budget Budget) (*Budget, error) {
r, err := db.db.ExecContext(ctx, `
INSERT INTO budget (id, user_id, description, value, created_at, created_by, updated_at, updated_by)
INSERT INTO budget (id, user_id, name, value, created_at, created_by, updated_at, updated_by)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
budget.Id, budget.UserId, budget.Description, budget.Value, budget.CreatedAt, budget.CreatedBy, budget.UpdatedAt, budget.UpdatedBy,
budget.Id, budget.UserId, budget.Name, budget.Value, budget.CreatedAt, budget.CreatedBy, budget.UpdatedAt, budget.UpdatedBy,
)
err = core.TransformAndLogDbError(ctx, "budget", r, err)
if err != nil {
@@ -42,13 +42,13 @@ func (db DbSqlite) Insert(ctx context.Context, budget Budget) (*Budget, error) {
func (db DbSqlite) Update(ctx context.Context, budget Budget) (*Budget, error) {
_, err := db.db.ExecContext(ctx, `
UPDATE budget
SET description = ?,
SET name = ?,
value = ?,
updated_at = ?,
updated_by = ?
WHERE user_id = ?
AND id = ?`,
budget.Description, budget.Value, budget.UpdatedAt, budget.UpdatedBy, budget.UserId, budget.Id)
budget.Name, budget.Value, budget.UpdatedAt, budget.UpdatedBy, budget.UserId, budget.Id)
if err != nil {
slog.ErrorContext(ctx, "SQL error UpdateUser", "err", err)

View File

@@ -50,7 +50,7 @@ func (h HandlerImpl) handlePage() http.HandlerFunc {
budgets, err := h.s.GetAll(r.Context(), user)
if err != nil {
core.HandleError(w, r, err)
h.r.RenderLayout(r, w, core.ErrorComp(err), user)
return
}
@@ -133,9 +133,9 @@ func (h HandlerImpl) handlePost() http.HandlerFunc {
value := int64(math.Round(valueF * DECIMALS_MULTIPLIER))
input := Budget{
Id: id,
Description: r.FormValue("name"),
Value: value,
Id: id,
Name: r.FormValue("name"),
Value: value,
}
if idStr == "new" {

View File

@@ -63,7 +63,7 @@ func (s ServiceImpl) Update(ctx context.Context, user *auth_types.User, input Bu
return nil, err
}
budget.Description = input.Description
budget.Name = input.Name
budget.Value = input.Value
if user.Id != budget.UserId {
@@ -107,7 +107,7 @@ func (s ServiceImpl) GetAll(ctx context.Context, user *auth_types.User) ([]Budge
}
func (s ServiceImpl) isBudgetValid(budget Budget) bool {
err := core.ValidateString(budget.Description, "description")
err := core.ValidateString(budget.Name, "description")
if err != nil {
return false
}

View File

@@ -59,7 +59,7 @@ templ editNew() {
templ edit(budget Budget) {
<div class="flex flex-col h-full">
@core.Breadcrumb([]string{"Home", "Budget", budget.Description}, []string{"/", "/budget", "/budget/" + budget.Id.String()})
@core.Breadcrumb([]string{"Home", "Budget", budget.Name}, []string{"/", "/budget", "/budget/" + budget.Id.String()})
<div class="flex justify-center items-center flex-1">
<form
hx-post={ "/budget/" + budget.Id.String() }
@@ -70,7 +70,7 @@ templ edit(budget Budget) {
autofocus
name="name"
type="text"
value={ budget.Description }
value={ budget.Name }
class="bg-white input datetime col-span-3"
/>
<label for="value" class="text-sm text-gray-500">Value</label>
@@ -80,15 +80,11 @@ templ edit(budget Budget) {
value={ budget.Value / 100 }
class="bg-white input col-span-3"
/>
<div class="flex gap-6 justify-end col-span-4">
<button
hx-delete={ "/budget/" + budget.Id.String() }
hx-confirm={ "Do you really want to delete '" + budget.Description + "'" }
class="col-start-4 p-2 px-4 decoration-yellow-400 decoration-[0.25rem] hover:bg-red-50 rounded-lg hover:underline flex items-center gap-2 justify-center"
>
@svg.Delete()
<div class="flex flex-row-reverse gap-6 justify-end col-span-4">
<button type="submit" class="col-start-4 p-2 px-4 decoration-yellow-400 decoration-[0.25rem] hover:bg-gray-200 rounded-lg hover:underline flex items-center gap-2 justify-center">
@svg.Save()
<span>
Delete
Save
</span>
</button>
<a href="/budget" class="col-start-3 p-2 px-4 decoration-yellow-400 decoration-[0.25rem] hover:bg-gray-200 rounded-lg hover:underline flex items-center gap-2 justify-center">
@@ -99,10 +95,14 @@ templ edit(budget Budget) {
Cancel
</span>
</a>
<button type="submit" class="col-start-4 p-2 px-4 decoration-yellow-400 decoration-[0.25rem] hover:bg-gray-200 rounded-lg hover:underline flex items-center gap-2 justify-center">
@svg.Save()
<button
hx-delete={ "/budget/" + budget.Id.String() }
hx-confirm={ "Do you really want to delete '" + budget.Name + "'" }
class="col-start-4 p-2 px-4 decoration-yellow-400 decoration-[0.25rem] hover:bg-red-50 rounded-lg hover:underline flex items-center gap-2 justify-center"
>
@svg.Delete()
<span>
Save
Delete
</span>
</button>
</div>
@@ -126,7 +126,7 @@ templ newItem() {
templ item(budget Budget) {
<a href={ "/budget/" + budget.Id.String() } class="p-5 w-64 h-64 flex gap-10 active:bg-gray-200 flex-col justify-center items-center hover:bg-gray-100 transition-all cursor-pointer rounded-lg bg-gray-50 border-1 border-gray-300">
<span>
{ budget.Description }
{ budget.Name }
</span>
<span>
{ core.FormatEuros(budget.Value) }

View File

@@ -10,8 +10,8 @@ type Budget struct {
Id uuid.UUID `db:"id"`
UserId uuid.UUID `db:"user_id"`
Description string `db:"description"`
Value int64 `db:"value"`
Name string `db:"name"`
Value int64 `db:"value"`
CreatedAt time.Time `db:"created_at"`
CreatedBy uuid.UUID `db:"created_by"`

View File

@@ -97,3 +97,9 @@ templ navigation(path string) {
<a class={ layoutLinkClass(strings.HasPrefix(path, "/budget")) } href="/budget">Budget</a>
</nav>
}
templ ErrorComp(err error) {
<div>
The following error occured: { err.Error() }
</div>
}

View File

@@ -0,0 +1 @@
ALTER TABLE "budget" RENAME COLUMN description TO name;