diff options
author | T <t@tjp.lol> | 2025-08-08 10:11:07 -0600 |
---|---|---|
committer | T <t@tjp.lol> | 2025-08-08 10:11:19 -0600 |
commit | 54c791927b2851fb6739ed75897090c3c39ecca1 (patch) | |
tree | 8f97b3509ccffed1351fe3d101e70c1cf0d861a9 /internal/tui/form.go | |
parent | a7ee7f7280d593481501446008acc05e32abcd22 (diff) |
create forms for clients and projects
Diffstat (limited to 'internal/tui/form.go')
-rw-r--r-- | internal/tui/form.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/tui/form.go b/internal/tui/form.go index 4b12762..71d5299 100644 --- a/internal/tui/form.go +++ b/internal/tui/form.go @@ -74,6 +74,7 @@ func newOptionalFloatField(label string) FormField { type Form struct { fields []FormField selIdx int + err error SelectedStyle *lipgloss.Style UnselectedStyle *lipgloss.Style @@ -106,6 +107,28 @@ func NewEntryEditorForm() Form { return form } +func NewClientForm() Form { + form := NewForm([]FormField{ + {Model: textinput.New(), label: "Name"}, + {Model: textinput.New(), label: "Email"}, + newOptionalFloatField("Hourly Rate"), + }) + form.SelectedStyle = &modalFocusedInputStyle + form.UnselectedStyle = &modalBlurredInputStyle + return form +} + +func NewProjectForm() Form { + form := NewForm([]FormField{ + {Model: textinput.New(), label: "Name"}, + {Model: textinput.New(), label: "Client"}, + newOptionalFloatField("Hourly Rate"), + }) + form.SelectedStyle = &modalFocusedInputStyle + form.UnselectedStyle = &modalBlurredInputStyle + return form +} + func (ff Form) Update(msg tea.Msg) (Form, tea.Cmd) { if msg, ok := msg.(tea.KeyMsg); ok { switch msg.String() { @@ -130,6 +153,11 @@ func (ff Form) Update(msg tea.Msg) (Form, tea.Cmd) { func (ff Form) View() string { content := "" + + if ff.err != nil { + content += errorStyle.Render(ff.err.Error()) + "\n\n" + } + for i, field := range ff.fields { if i > 0 { content += "\n\n" |