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{} modalClosed struct{} openTimeEntryEditor struct{} openModalUnchanged struct{} openDeleteConfirmation struct{} recheckBounds struct{} openCreateClientModal struct{} openCreateProjectModal 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() } if clientID == "" { return nil } _, _ = 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} } } func closeModal() tea.Cmd { return func() tea.Msg { return modalClosed{} } } func editCurrentEntry() tea.Cmd { return func() tea.Msg { return openTimeEntryEditor{} } } func reOpenModal() tea.Cmd { return func() tea.Msg { return openModalUnchanged{} } } func confirmDeleteEntry() tea.Cmd { return func() tea.Msg { return openDeleteConfirmation{} } } func createClientModal() tea.Cmd { return func() tea.Msg { return openCreateClientModal{} } } func createProjectModal() tea.Cmd { return func() tea.Msg { return openCreateProjectModal{} } }