rsvp form

trunk
nate smith 2024-09-01 15:32:45 -05:00
parent ebadba99af
commit 7cb2fd67d1
1 changed files with 31 additions and 5 deletions

View File

@ -13,6 +13,7 @@ import (
"git.tilde.town/tildetown/town/email"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/huh"
"gopkg.in/yaml.v3"
)
//go:embed banners/*
@ -53,18 +54,27 @@ func info() error {
}
type physicalData struct {
Arriving string
Departing string
Transportation bool
Lodging bool
Allergies string
Couch bool
}
type rsvpData struct {
Being string
PhysicalData physicalData
PhysicalData *physicalData `yaml:"PhysicalData,omitempty"`
Freeform string
}
func sendRSVPEmail(rd rsvpData) error {
body := "TODO"
bs, err := yaml.Marshal(rd)
if err != nil {
return err
}
return email.SendLocalEmail("vilmibm", "RSVP TOWNCON24", body)
return email.SendLocalEmail("vilmibm", "RSVP TOWNCON24", string(bs))
}
func rsvp(o opts) error {
@ -127,9 +137,25 @@ func rsvp(o opts) error {
return err
}
// TODO email
var pd *physicalData
return nil
if being == "physical" {
pd = &physicalData{
Arriving: arriving,
Departing: departing,
Transportation: transportation,
Lodging: lodging,
Allergies: allergies,
Couch: couch,
}
}
rd := rsvpData{
Being: being,
Freeform: freeform,
PhysicalData: pd}
return sendRSVPEmail(rd)
}
type opts struct {