summaryrefslogtreecommitdiff
path: root/internal/tui/form.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tui/form.go')
-rw-r--r--internal/tui/form.go28
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"