Potion/internal/app/handlers/recipe_handler.go
Hayden Hargreaves b17c5774e9 (UI): Implemented much of the frontend recipe creation wizard.
Most everything is implemented, included a state handler and a pretty
simple (but workable) system for managing state in HTML. Nice and simple
for now.

There is still much work to be done, but the rest is simple backend
creation and error handling. And then input validation...a nightmare.
2025-06-29 22:30:20 -07:00

50 lines
1.4 KiB
Go

package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
// domain "github.com/haydenhargreaves/Potion/internal/domain/server"
)
func CreateRecipe(ctx *gin.Context) {
// deps := ctx.MustGet("deps").(*domain.InjectedDependencies)
title := ctx.PostForm("title")
description := ctx.PostForm("description")
preparation := ctx.PostForm("preparation-time")
cook := ctx.PostForm("cook-time")
serving := ctx.PostForm("serving-size")
category := ctx.PostForm("category")
difficulty := ctx.PostForm("difficulty")
ingredients := ctx.PostFormArray("ingredients")
quantity := ctx.PostFormArray("quantity")
instructions := ctx.PostFormArray("instructions")
tags := ctx.PostForm("tags") // this is a list of strings split with a comma (,)
// Have to get the image differently
image, err := ctx.FormFile("image")
if err != nil {
ctx.JSON(http.StatusOK, gin.H{"error": err.Error()})
return
}
ctx.JSON(http.StatusOK, gin.H{
"title": title,
"description": description,
"cook time": cook,
"preparation time": preparation,
"serving size": serving,
"category": category,
"difficulty": difficulty,
"ingredients": ingredients,
"quantity": quantity,
"instructions": instructions,
"tags": tags,
"image": image.Filename,
})
// deps.RecipeService.CreateRecipe(ctx)
// ctx.JSON(http.StatusCreated, gin.H{"recipe": recipe})
}