diff options
author | T <t@tjp.lol> | 2025-08-05 12:36:30 -0600 |
---|---|---|
committer | T <t@tjp.lol> | 2025-08-06 12:13:11 -0600 |
commit | 65e2ed65775d64afbc6065a3b4ac1069020093ca (patch) | |
tree | f94fabfed5be2d2622429ebc7c8af1bf51085824 /internal/tui/commands.go | |
parent | 665bd389a0a1c8adadcaa1122e846cc81f5ead31 (diff) |
most features in TUI working, remaining unimplemented keybinds need a modal view
Diffstat (limited to 'internal/tui/commands.go')
-rw-r--r-- | internal/tui/commands.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/internal/tui/commands.go b/internal/tui/commands.go new file mode 100644 index 0000000..c54df29 --- /dev/null +++ b/internal/tui/commands.go @@ -0,0 +1,65 @@ +package tui + +import ( + "context" + + "punchcard/internal/actions" + + tea "github.com/charmbracelet/bubbletea" +) + +type ( + navigationMsg struct{ Forward bool } + selectionMsg struct{ Forward bool } + drillDownMsg struct{} + drillUpMsg struct{} +) + +func navigate(forward bool) tea.Cmd { + return func() tea.Msg { return navigationMsg{forward} } +} + +func punchIn(m AppModel) tea.Cmd { + return func() tea.Msg { + _, _ = actions.New(m.queries).PunchInMostRecent(context.Background(), "", nil) + // TODO: use the returned TimerSession instead of re-querying everything + return m.refreshCmd() + } +} + +func punchOut(m AppModel) tea.Cmd { + return func() tea.Msg { + _, _ = actions.New(m.queries).PunchOut(context.Background()) + // TODO: use the returned TimerSession instead of re-querying everything + return m.refreshCmd() + } +} + +func punchInOnSelection(m AppModel) tea.Cmd { + return func() tea.Msg { + var clientID, projectID, description string + var entryRate *float64 + switch m.selectedBox { + case ProjectsBox: + clientID, projectID, description, entryRate = m.projectsBox.selection() + case HistoryBox: + clientID, projectID, description, entryRate = m.historyBox.selection() + } + + _, _ = actions.New(m.queries).PunchIn(context.Background(), clientID, projectID, description, entryRate) + // TODO: use the returned TimerSession instead of re-querying everything + return m.refreshCmd() + } +} + +func selectHistorySummary() tea.Cmd { + return func() tea.Msg { return drillDownMsg{} } +} + +func backToHistorySummary() tea.Cmd { + return func() tea.Msg { return drillUpMsg{} } +} + +func changeSelection(forward bool) tea.Cmd { + return func() tea.Msg { return selectionMsg{forward} } +} |