Finish migration

This commit is contained in:
Eden Kirin
2024-02-01 22:05:44 +01:00
parent 15ba332ae5
commit 89a3c63dd8
5 changed files with 27 additions and 273 deletions

View File

@ -7,7 +7,7 @@ import (
"templ-tests/app/templates"
"templ-tests/app/types"
"github.com/gin-gonic/gin"
"github.com/gofiber/fiber/v2"
)
var pcInteractive templates.PageContext = templates.PageContext{
@ -15,22 +15,24 @@ var pcInteractive templates.PageContext = templates.PageContext{
ActivePage: "interactive",
}
func Interactive(c *gin.Context) {
templates.Interactive(pcInteractive, data.CatBreeds).Render(c, c.Writer)
func Interactive(f *fiber.Ctx) error {
Render(f, templates.Interactive(pcInteractive, data.CatBreeds))
return nil
}
func InteractiveSwapContent(c *gin.Context) {
contentIndexStr := c.Query("content")
func InteractiveSwapContent(f *fiber.Ctx) error {
contentIndexStr := f.Query("content")
contentIndex, err := strconv.Atoi(contentIndexStr)
if err != nil {
contentIndex = 0
}
templates.InteractiveSwapContent(pcInteractive, contentIndex).Render(c, c.Writer)
Render(f, templates.InteractiveSwapContent(pcInteractive, contentIndex))
return nil
}
func FilterCatBreeds(c *gin.Context) {
breedQuery := strings.ToLower(c.Query("breed"))
countryQuery := c.Query("country")
func FilterCatBreeds(f *fiber.Ctx) error {
breedQuery := strings.ToLower(f.Query("breed"))
countryQuery := f.Query("country")
var catBreeds []types.CatBreed = []types.CatBreed{}
@ -48,14 +50,15 @@ func FilterCatBreeds(c *gin.Context) {
}
}
templates.RenderCatBreedsTable(catBreeds).Render(c, c.Writer)
Render(f, templates.RenderCatBreedsTable(catBreeds))
return nil
}
func ValidateForm(c *gin.Context) {
func ValidateForm(f *fiber.Ctx) error {
content := templates.ValidateFormContent{
Validated: true,
NumValue: c.PostForm("number-value"),
StrValue: c.PostForm("string-value"),
NumValue: f.FormValue("number-value"),
StrValue: f.FormValue("string-value"),
}
numValue, err := strconv.Atoi(content.NumValue)
@ -83,5 +86,6 @@ func ValidateForm(c *gin.Context) {
content.StrValueError = "String length is more than 10"
}
templates.RenderInteractiveForm(content).Render(c, c.Writer)
Render(f, templates.RenderInteractiveForm(content))
return nil
}