diff --git a/features/survey/views.go b/features/survey/views.go index d427558..15e9451 100644 --- a/features/survey/views.go +++ b/features/survey/views.go @@ -2,10 +2,88 @@ package features_survey import ( "github.com/gofiber/fiber/v2" - . "MY/webapp/common" + // . "MY/webapp/common" ) +type Question struct { + Id int64 + Question string + Answer bool + Result int +} + +type Survey struct { + Id int64 + Title string + Description string + Date string + Respondents int + State string + Questions []Question +} + +func QueryData() Survey { + return Survey{ + Title: "Sample Survey", + Description: "The description.", + Date: "01/20/26", + Respondents: 200, + State: "Finished", + Questions: []Question{ + { + Id: 1, + Question: "Do you like HTML?", + Answer: true, + // TODO: just for prototyping, needs to be a better model + Result: 20, + }, + { + Id: 2, + Question: "Do you like CSS?", + Answer: false, + Result: 11, + }, + { + Id: 3, + Question: "Do you like JavaScript?", + Answer: true, + Result: 43, + }, + { + Id: 4, + Question: "Are you a programmer?", + Answer: true, + Result: 28, + }, + }, + } +} + +func GetPageIndex(c *fiber.Ctx) error { + return c.Render("survey/index", fiber.Map{ + "Survey": QueryData(), + }) +} + +func GetPageSubmit(c *fiber.Ctx) error { + return c.Render("survey/submit", fiber.Map{ + "Survey": QueryData(), + }) +} + +func GetPageFinalize(c *fiber.Ctx) error { + return c.Render("survey/finalize", fiber.Map{}) +} + +func GetPageResults(c *fiber.Ctx) error { + return c.Render("survey/results", fiber.Map{ + "Survey": QueryData(), + }) +} + func SetupViews(app *fiber.App) { - err := ConfigViews(app, "views/survey") - if err != nil { panic(err) } + app.Get("/survey/", GetPageIndex) + app.Get("/survey/submit", GetPageSubmit) + app.Get("/survey/finalize", GetPageFinalize) + app.Get("/survey/results", GetPageResults) } diff --git a/views/survey/index.html b/views/survey/index.html index bfcb813..cb3e003 100644 --- a/views/survey/index.html +++ b/views/survey/index.html @@ -1,37 +1,4 @@ - -
Street art kettlebell burrata offal portra decolonize are.na akerman shabby chic blue bottle post-ironic breathwork. Roof party natural wine bell hooks cold plunge metrograph granny square ugh dad shoes garum before they sold out zines tahini side hustle. Indigo dye pork belly amaro, post-ironic health goth candle making van life hairpin robert walser.
+{{ .Survey.Description }}