go_templates/services/exercises.go
2024-11-02 14:09:44 +03:00

51 lines
1.3 KiB
Go

package services
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
"git.pro100code.ru/pro100ton/go_templates/models"
// "git.pro100code.ru/pro100ton/go_templates/utils"
)
var exercise []models.ExerciseSandbox
// func ExercisesJSONGetter(c *fiber.Ctx) error {
// exercies := utils.GenerateExercises()
// return c.JSON(exercies)
// }
//
// func ExercisesRenderer(c *fiber.Ctx) error {
// exercies := utils.GenerateExercises()
// return c.Render("exercises/exercises", fiber.Map{
// "data": exercies,
// })
// }
func ExercisesFormRenderer(c *fiber.Ctx) error {
return c.Render("forms/exercise_enter_form", nil)
}
func ExercisesFormHanlder(c *fiber.Ctx) error {
log.Info(c.FormValue("exercise-name"))
log.Info(c.FormValue("attempt-weight-name"))
log.Info(c.FormValue("attempt-reps-name"))
exerciseName := c.FormValue("exercise-name")
attemptWeight := c.FormValue("attempt-weight-name")
attemptReps := c.FormValue("attempt-reps-name")
log.Info(exerciseName, attemptWeight, attemptReps)
exercise = append(
exercise,
models.ExerciseSandbox{
Name: exerciseName,
Weight: attemptWeight,
Reps: attemptReps,
},
)
log.Info("---")
log.Info(exercise)
return c.Render("training/training_table", fiber.Map{
"data": exercise,
})
}