package day import ( "github.com/charmbracelet/huh" "ticktock/internal/store" "ticktock/internal/tui/form" ) // formValues aliases the shared form value type so existing day code/tests keep // their names. type formValues = form.Values // newEditForm builds the edit form bound to fv, prefilled from e, with history // suggestions attached. func newEditForm(e store.Entry, fv *formValues, sug form.Suggest) *huh.Form { return form.New(e, fv, sug) } // buildUpdated turns edited form values into a new Entry on the given date. func buildUpdated(date string, orig store.Entry, f formValues) (store.Entry, error) { return form.BuildEntry(date, orig, f) } // applyEdit validates and writes an edit through the store. func applyEdit(s store.Store, date string, orig store.Entry, f formValues) error { up, err := buildUpdated(date, orig, f) if err != nil { return err } return s.SafeReplace(orig.Key, up, orig) }