add basic survey intro

This commit is contained in:
Robin Olsen
2026-02-16 12:17:16 +01:00
parent eb8427ea46
commit 1fe92d1972
2 changed files with 80 additions and 0 deletions

76
cmd/survey/intro.go Normal file
View File

@@ -0,0 +1,76 @@
package main
import (
"github.com/LazyBachelor/LazyPM/internal/style"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/huh"
)
const (
IntroTitle = "Welcome to the Task Survey!"
IntroductionText = `This survey is designed to gather feedback on task management interfaces.
Your responses will help us improve our services. Please note that all data collected will be anonymized and used solely for research purposes.
By participating, you consent to the collection and use of your data as described in this disclaimer.
Press any key to continue...`
Disclaimer = `This survey is designed to gather feedback on task management interfaces.
Your responses will help us improve our services. Please note that all data collected will be anonymized and used solely for research purposes.
By participating, you consent to the collection and use of your data as described in this disclaimer.`
)
type introModel struct {
form *huh.Form
width, height int
}
func newIntroModel() introModel {
return introModel{
form: huh.NewForm(
huh.NewGroup(
huh.NewNote().Title(IntroTitle).Description(IntroductionText),
),
huh.NewGroup(
huh.NewNote().Title("Disclaimer").Description(Disclaimer),
),
),
}
}
func (m introModel) Init() tea.Cmd {
m.form.Init()
return nil
}
func (m introModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.Type {
case tea.KeyEsc, tea.KeyCtrlC:
return m, tea.Quit
}
case tea.WindowSizeMsg:
m.SetSize(msg.Width, msg.Height)
}
form, cmd := m.form.Update(msg)
if f, ok := form.(*huh.Form); ok {
m.form = f
}
return m, cmd
}
func (m introModel) View() string {
return m.form.WithTheme(style.HuhCenterTheme()).View()
}
func (m introModel) Run() error {
_, err := tea.NewProgram(m, tea.WithAltScreen()).Run()
return err
}
func (m *introModel) SetSize(width, height int) {
m.width, m.height = width, height
}

View File

@@ -13,6 +13,10 @@ import (
func main() {
ctx := context.Background()
if err := newIntroModel().Run(); err != nil {
log.Fatalf("Failed to run intro screen: %v\n", err)
}
svc, close, err := initializeServices(ctx)
if err != nil {
log.Fatalf("Failed to initialize services: %v\n", err)