From 7cb2fd67d153ee3310c1b3406976145338ef77f3 Mon Sep 17 00:00:00 2001 From: nate smith Date: Sun, 1 Sep 2024 15:32:45 -0500 Subject: [PATCH] rsvp form --- cmd/towncon/main.go | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/cmd/towncon/main.go b/cmd/towncon/main.go index f49964f..6b4ba86 100644 --- a/cmd/towncon/main.go +++ b/cmd/towncon/main.go @@ -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 {