Files
sonr/internal/dwn/islands/forms.go
T
Prad NukalaandGitHub 8022428e37 feature/driver indexed db (#12)
* fix: update commitizen version

* feat: add WASM build tags to db actions

* feat: Update all actions to follow `AddAsset` for error handling

* feat: remove database dependency in dwn and motr commands

* feat: add basic info form to registration view

* feat: implement basic browser navigation component

* refactor: move database related files to middleware

* fix: remove unused test command

* fix: update source directory for buf-publish workflow
2024-09-16 01:06:00 -04:00

42 lines
879 B
Go

package islands
import (
"bytes"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
)
func echoFormResponse(c echo.Context, cmp templ.Component, state FormState) error {
// Create a buffer to store the rendered HTML
buf := &bytes.Buffer{}
// Render the component to the buffer
err := cmp.Render(c.Request().Context(), buf)
if err != nil {
return err
}
// Set the content type
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
c.Response().Header().Set("X-Status", string(state))
// Write the buffered content to the response
_, err = c.Response().Write(buf.Bytes())
return err
}
type FormState string
const (
InitialForm FormState = "initial"
ErrorForm FormState = "error"
SuccessForm FormState = "success"
WarningForm FormState = "warning"
)
type Form struct {
State FormState
Title string
Description string
}