diff --git a/handlers/public/surveymcu.handlers.go b/handlers/public/surveymcu.handlers.go new file mode 100644 index 0000000..3e3be0f --- /dev/null +++ b/handlers/public/surveymcu.handlers.go @@ -0,0 +1,154 @@ +package public_handlers + +import ( + "cpone/models" + "cpone/utils" + surveymcu "cpone/views/public/surveymcu" + + "github.com/a-h/templ" + "github.com/labstack/echo/v4" + "go.uber.org/zap" +) + +type SurveyMcuService interface { + GetSurveyMcuByNoreg(nomorRegistrasi string) ([]models.SurveyMcu, error) +} + +func NewSurveyMcuHandler(us SurveyMcuService) *SurveyMcuHandler { + return &SurveyMcuHandler{ + SurveyMcuService: us, + } +} + +type SurveyMcuHandler struct { + SurveyMcuService SurveyMcuService +} + +func (lh *SurveyMcuHandler) HandlerShowSurveyMcu(c echo.Context) error { + + nomorRegistrasi := c.Param("nomorRegistrasi") + // nomorRegistrasi := "1" + logger, _ := zap.NewProduction() + defer logger.Sync() + + dataSurveyMcu, err := lh.SurveyMcuService.GetSurveyMcuByNoreg(nomorRegistrasi) + + if err != nil { + logger.Info("Error", + zap.Any("Error", err), + zap.Any("prm", nomorRegistrasi), + ) + return err + } + logger.Info("SHOW DATA SURVEY MCU handler", + zap.Any("return", dataSurveyMcu), + zap.Any("prm", nomorRegistrasi), + ) + + stringUrl := "surveymcuproses/" + nomorRegistrasi + var hxInclude string = "" + var idClearMsg []models.IdClearErrorMessage + + if len(dataSurveyMcu) > 0 { + for _, v := range dataSurveyMcu { + if len(v.DataListItemSurveyMcu) > 0 { + hxInclude = utils.ConcatHxIncludeSurveyMcu(v.DataListItemSurveyMcu) + } + } + } + + si := surveymcu.ShowSurveyMcu("Survey Mcu", + surveymcu.MainContentSurveyMcuLayout(dataSurveyMcu, stringUrl, surveymcu.ErrorMessageSurveyMcu("", "", idClearMsg, "alertSaranMcu"), hxInclude), surveymcu.CssSurveyMcu(), surveymcu.JsSurveyMcu()) + + return utils.View(c, si) +} + +func (lh *SurveyMcuHandler) HandlerProcessSurveyMcu(c echo.Context) error { + + nomorRegistrasi := c.Param("nomorRegistrasi") + // nomorRegistrasi := "1" + logger, _ := zap.NewProduction() + defer logger.Sync() + + dataSurveyMcu, err := lh.SurveyMcuService.GetSurveyMcuByNoreg(nomorRegistrasi) + + if err != nil { + logger.Info("Error", + zap.Any("Error", err), + zap.Any("prm", nomorRegistrasi), + ) + return err + } + logger.Info("SHOW DATA SURVEY MCU handler", + zap.Any("return", dataSurveyMcu), + zap.Any("prm", nomorRegistrasi), + ) + + form := c.Request().PostForm + + // stringUrl := "surveymcuproses/" + nomorRegistrasi + + logger.Info("CEK POST handler", + zap.Any("c.FormValue", c.FormValue(form.Get("radio-1"))), + zap.Any("name dari inputan", form.Get("radio-1")), + ) + + // proses validasi + + var si templ.Component + var idFormKosong string = "" + var stringMessage string = "" + var isFormEmpty bool = false + var idClearMsg []models.IdClearErrorMessage + var idSaranMcuAlert string = "" + // var idSaranMcuClear string = "" + + if len(dataSurveyMcu) > 0 { + for _, v := range dataSurveyMcu { + if len(v.DataListItemSurveyMcu) > 0 { + for _, x := range v.DataListItemSurveyMcu { + + if len(c.FormValue("radio-"+x.IDItemSurvey)) > 0 { + idClearMsg = append(idClearMsg, models.IdClearErrorMessage{IdItem: x.IDItemSurvey}) + } + + if "default-"+x.NameRadioButton == c.FormValue("default-"+x.NameRadioButton) && len(c.FormValue("radio-"+x.IDItemSurvey)) == 0 { + stringMessage += "Pertanyaan ke-" + x.IDItemSurvey + " wajib diisi," + idFormKosong += utils.GetIdSurveyMcu(x.IDItemSurvey) + isFormEmpty = true + break + } + } + } + } + } + + // if len(c.FormValue("saranMcu")) == 0 { + // isFormEmpty = true + // stringMessage += " Kemudian Saran Mcu Wajib Diisi" + // idSaranMcuAlert = "alertSaranMcu" + // } + + // if len(c.FormValue("saranMcu")) > 0 { + // isFormEmpty = false + // stringMessage += "" + // idSaranMcuAlert = "alertSaranMcu" + // } + + if isFormEmpty { + si = surveymcu.ErrorMessageSurveyMcu(stringMessage, idFormKosong, idClearMsg, idSaranMcuAlert) + // si = surveymcu.ShowSurveyMcu("Survey Mcu", + // surveymcu.MainContentSurveyMcuLayout(dataSurveyMcu, nomorRegistrasi, surveymcu.ErrorMessageSurveyMcu(stringMessage, idFormKosong)), surveymcu.CssSurveyMcu(), surveymcu.JsSurveyMcu()) + // si = surveymcu.FormSurvey(dataSurveyMcu, stringUrl) + } else { + // var idClearMsgEmpty []models.IdClearErrorMessage + si = surveymcu.ErrorMessageSurveyMcu("", "", idClearMsg, "") + } + + // stringMessage += fmt.Sprintf("Pertanyaan ke-%s", x.IDItemSurvey, " wajib diisi") + + // si := surveymcu.ShowSurveyMcu("Survey Mcu", + // surveymcu.MainContentSurveyMcuLayout(dataSurveyMcu, nomorRegistrasi), surveymcu.CssSurveyMcu(), surveymcu.JsSurveyMcu()) + + return utils.View(c, si) +} diff --git a/handlers/routes.go b/handlers/routes.go index 49f1ee7..21b7490 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -9,6 +9,7 @@ import ( corporate_services "cpone/services/corporate" dev_services "cpone/services/dev" public_services "cpone/services/public" + "net/http" "cpone/db" @@ -76,6 +77,19 @@ func SetupRoutesPublic(app *echo.Echo, appStore db.AppStore) { publicKartuKontrolhandlers := public_handlers.NewKartuKontrolHandler(publicKartuKontrolServices) public.GET("kartukontrol/:nomorRegistrasi", publicKartuKontrolhandlers.HandlerShowKartuKontrol) public.GET("modalsurveykartukontrol", publicKartuKontrolhandlers.HandlerShowWordingModalSurveyMcu) + + // survey mcu page (pertanyaan dan jawaban) + publicSurveyMcuServices := public_services.NewServicesSurveyMcu(appStore) + publicSurveyMcuhandlers := public_handlers.NewSurveyMcuHandler(publicSurveyMcuServices) + public.GET("surveymcu/:nomorRegistrasi", publicSurveyMcuhandlers.HandlerShowSurveyMcu) + + // contoh penggunaan header location spt php + app.GET("/redirectsurveymcu", func(c echo.Context) error { + return c.Redirect(http.StatusFound, "surveymcu/:nomorRegistrasi") + }) + + // surveymcuproses + public.POST("surveymcuproses/:nomorRegistrasi", publicSurveyMcuhandlers.HandlerProcessSurveyMcu) } func SetupRoutesCorporate(app *echo.Echo, appStore db.AppStore) { public := app.Group("/corp") diff --git a/models/surveymcu.models.go b/models/surveymcu.models.go new file mode 100644 index 0000000..2aaebec --- /dev/null +++ b/models/surveymcu.models.go @@ -0,0 +1,19 @@ +package models + +type SurveyMcu struct { + DataListItemSurveyMcu []ItemSurveyMcu `json:"dataListItemSurveyMcu"` +} + +type ItemSurveyMcu struct { + IDItemSurvey string `json:"iditemsurvey"` + Nomor string `json:"nomor"` + Pertanyaan string `json:"pertanyaan"` + Jawaban bool `json:"jawaban"` + NameRadioButton string `json:"nameradiobutton"` + Checked string `json:"checked"` + ErrorMessage string `json:"errorMessage"` +} + +type IdClearErrorMessage struct { + IdItem string `json:"iditem"` +} diff --git a/services/public/surveymcu.services.go b/services/public/surveymcu.services.go new file mode 100644 index 0000000..678e384 --- /dev/null +++ b/services/public/surveymcu.services.go @@ -0,0 +1,129 @@ +package public_services + +import ( + "cpone/db" + "cpone/models" + + "go.uber.org/zap" +) + +func NewServicesSurveyMcu(uStore db.AppStore) *SurveyMcuService { + + return &SurveyMcuService{ + SurveyMcuStore: uStore, + } +} + +type SurveyMcuService struct { + SurveyMcuStore db.AppStore +} + +func (su *SurveyMcuService) GetSurveyMcuByNoreg(nomorRegistrasi string) ([]models.SurveyMcu, error) { + + logger, _ := zap.NewProduction() + defer logger.Sync() + logger.Info("QUERY SEARCH GET SURVEY MCU BY NOMOR REGISTRASI", + zap.String("query search", ""), + ) + + dataItemSurveyMcu := []models.ItemSurveyMcu{ + { + IDItemSurvey: "1", + Nomor: "1", + Pertanyaan: "Bagaimana Penilaian Sikap & Keramahan Petugas?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-1", + }, + { + IDItemSurvey: "2", + Nomor: "2", + Pertanyaan: "Bagaimana Penilaian Penampilan Petugas?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-2", + }, + { + IDItemSurvey: "3", + Nomor: "3", + Pertanyaan: "Bagaimana Penilaian Ketrampilan Petugas?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-3", + }, + { + IDItemSurvey: "4", + Nomor: "4", + Pertanyaan: "Bagaimana Penilaian Pemberian Informasi Petugas?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-4", + }, + { + IDItemSurvey: "5", + Nomor: "5", + Pertanyaan: "Bagaimana Penilaian Kelengkapan Alat?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-5", + }, + { + IDItemSurvey: "6", + Nomor: "6", + Pertanyaan: "Bagaimana Penilaian Kelayakan Alat?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-6", + }, + { + IDItemSurvey: "7", + Nomor: "7", + Pertanyaan: "Bagaimana Penilaian Kebersihan Ruangan?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-7", + }, + { + IDItemSurvey: "8", + Nomor: "8", + Pertanyaan: "Bagaimana Penilaian Kebersihan Ruangan?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-8", + }, + { + IDItemSurvey: "9", + Nomor: "9", + Pertanyaan: "Bagaimana Penilaian Alur Pelayanan?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-9", + }, + { + IDItemSurvey: "10", + Nomor: "10", + Pertanyaan: "Bagaimana Penilaian Ketepatan Waktu?", + Jawaban: false, + Checked: "", + ErrorMessage: "", + NameRadioButton: "radio-10", + }, + } + + surveymcu := []models.SurveyMcu{ + { + DataListItemSurveyMcu: dataItemSurveyMcu, + }, + } + + return surveymcu, nil +} diff --git a/utils/surveymcu.utils.go b/utils/surveymcu.utils.go new file mode 100644 index 0000000..120e136 --- /dev/null +++ b/utils/surveymcu.utils.go @@ -0,0 +1,24 @@ +package utils + +import "cpone/models" + +func GetIdSurveyMcu(id string) string { + return id +} + +func ConcatHxIncludeSurveyMcu(data []models.ItemSurveyMcu) string { + var stringx string + + if len(data) > 0 { + for i, v := range data { + if i > 0 { + stringx += ", " + } + stringx += "[name='radio-" + v.IDItemSurvey + "'], [name='default-radio-" + v.IDItemSurvey + "'], [name='id-radio']" + } + } + + stringx += ",[name='saranMcu']" + + return stringx +} diff --git a/views/public/surveymcu/surveymcu.templ b/views/public/surveymcu/surveymcu.templ new file mode 100644 index 0000000..32b2071 --- /dev/null +++ b/views/public/surveymcu/surveymcu.templ @@ -0,0 +1,304 @@ +package public_surveymcu + +import ( + "cpone/models" + "cpone/layout" +) + +func concatNameRadioButtonBaik(idPertanyaan string) string { + return "radio-baik-" + idPertanyaan +} + +func concatNameRadioButtonKurang(idPertanyaan string) string { + return "radio-kurang-" + idPertanyaan +} + +func concatIdErrorMessage(idPertanyaan string) string { + return "errorMessage-" + idPertanyaan +} + +func concatNameDefault(NameRadioButton string) string { + return "default-" + NameRadioButton +} + +func isIDInClearList(IDItemSurvey string, idclear []models.IdClearErrorMessage) bool { + for _, item := range idclear { + if item.IdItem == IDItemSurvey { + return true + } + } + return false +} + +templ MainContentSurveyMcuLayout(dataSurveyMcu []models.SurveyMcu, urlPost string, errorComp templ.Component, hxInclude string) { +
+ +
+

Survey MCU

+
+ +
+ //
+
+ if len(dataSurveyMcu) > 0 { + for _, v := range dataSurveyMcu { + if len(v.DataListItemSurveyMcu) > 0 { + for _, k := range v.DataListItemSurveyMcu { + +
+
+ +
+
+ { k.Nomor }  +
+
+ { k.Pertanyaan } +
+
+ +
+
+
+
+ + +
+ + +
+
+
+
+
+ + +
+
+ + } + } + } + } + + + + + + + + +
+
+ //
+
+} + +templ ErrorMessageSurveyMcu(ErrorMessage string, IDItemSurvey string, idclear []models.IdClearErrorMessage, idSaranMcuAlert string) { + if len(idclear) > 0 { + for _, v := range idclear { + + + + } + } + +
+
+ { ErrorMessage } +
+
+ + // saran mcu + //
+ //
+ // { ErrorMessage } + //
+ //
+} + +// templ ErrorMessageSurveyMcu(ErrorMessage string, IDItemSurvey string, idclear []models.IdClearErrorMessage) { +// +//
+//
+// { ErrorMessage } +//
+//
+// +// } +templ CssSurveyMcu() { + + + + +} + +templ JsSurveyMcu() { +} + +templ ShowSurveyMcu(title string, cmp templ.Component, css templ.Component, js templ.Component) { + @layout.PlaygroundLayout(title, css, js) { + @cmp + } +} diff --git a/views/public/surveymcu/surveymcu_templ.go b/views/public/surveymcu/surveymcu_templ.go new file mode 100644 index 0000000..9aba47f --- /dev/null +++ b/views/public/surveymcu/surveymcu_templ.go @@ -0,0 +1,391 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.663 +package public_surveymcu + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +import ( + "cpone/layout" + "cpone/models" +) + +func concatNameRadioButtonBaik(idPertanyaan string) string { + return "radio-baik-" + idPertanyaan +} + +func concatNameRadioButtonKurang(idPertanyaan string) string { + return "radio-kurang-" + idPertanyaan +} + +func concatIdErrorMessage(idPertanyaan string) string { + return "errorMessage-" + idPertanyaan +} + +func concatNameDefault(NameRadioButton string) string { + return "default-" + NameRadioButton +} + +func isIDInClearList(IDItemSurvey string, idclear []models.IdClearErrorMessage) bool { + for _, item := range idclear { + if item.IdItem == IDItemSurvey { + return true + } + } + return false +} + +func MainContentSurveyMcuLayout(dataSurveyMcu []models.SurveyMcu, urlPost string, errorComp templ.Component, hxInclude string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Survey MCU

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(dataSurveyMcu) > 0 { + for _, v := range dataSurveyMcu { + if len(v.DataListItemSurveyMcu) > 0 { + for _, k := range v.DataListItemSurveyMcu { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(k.Nomor) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\public\surveymcu\surveymcu.templ`, Line: 55, Col: 20} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" \r
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var3 string + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(k.Pertanyaan) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\public\surveymcu\surveymcu.templ`, Line: 60, Col: 25} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
hello\r
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + } + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
hello\r
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ErrorMessageSurveyMcu(ErrorMessage string, IDItemSurvey string, idclear []models.IdClearErrorMessage, idSaranMcuAlert string) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var12 := templ.GetChildren(ctx) + if templ_7745c5c3_Var12 == nil { + templ_7745c5c3_Var12 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if len(idclear) > 0 { + for _, v := range idclear { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(ErrorMessage) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\public\surveymcu\surveymcu.templ`, Line: 150, Col: 19} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var16 string + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(ErrorMessage) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\public\surveymcu\surveymcu.templ`, Line: 163, Col: 17} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +// templ ErrorMessageSurveyMcu(ErrorMessage string, IDItemSurvey string, idclear []models.IdClearErrorMessage) { +// +//
+//
+// { ErrorMessage } +//
+//
+// +// } +func CssSurveyMcu() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var17 := templ.GetChildren(ctx) + if templ_7745c5c3_Var17 == nil { + templ_7745c5c3_Var17 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func JsSurveyMcu() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var18 := templ.GetChildren(ctx) + if templ_7745c5c3_Var18 == nil { + templ_7745c5c3_Var18 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func ShowSurveyMcu(title string, cmp templ.Component, css templ.Component, js templ.Component) templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var19 := templ.GetChildren(ctx) + if templ_7745c5c3_Var19 == nil { + templ_7745c5c3_Var19 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var20 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + templ_7745c5c3_Err = cmp.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer) + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = layout.PlaygroundLayout(title, css, js).Render(templ.WithChildren(ctx, templ_7745c5c3_Var20), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}