Use string array for directions in recipes
This commit is contained in:
parent
f0e7e67d77
commit
59af36b3f2
@ -2,14 +2,11 @@ package tech.mercantec.easyeat.helpers
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.serialization.Serializable
|
||||
import tech.mercantec.easyeat.models.Ingredient
|
||||
import tech.mercantec.easyeat.models.Recipe
|
||||
|
||||
@Serializable
|
||||
data class GenerateRecipeRequest(val dish: String, val language: String, val numberOfRecipes: Int, val allergi: Array<String>)
|
||||
|
||||
@Serializable
|
||||
data class GenerateRecipeResponse(val name: String, val description: String, val directions: Array<String>, val ingredients: Array<Ingredient>)
|
||||
|
||||
fun generateRecipeWithAI(ctx: Context, title: String, language: String): GenerateRecipeResponse {
|
||||
return requestJson<GenerateRecipeRequest, GenerateRecipeResponse>(ctx, "POST", "/api/Recipe/chatbot", GenerateRecipeRequest(title, language, 1, arrayOf()))
|
||||
fun generateRecipeWithAI(ctx: Context, title: String, language: String): Recipe {
|
||||
return requestJson<GenerateRecipeRequest, Recipe>(ctx, "POST", "/api/Recipe/chatbot", GenerateRecipeRequest(title, language, 1, arrayOf()))
|
||||
}
|
||||
|
@ -6,16 +6,10 @@ import kotlinx.serialization.Serializable
|
||||
data class Recipe(
|
||||
val name: String,
|
||||
val description: String,
|
||||
val directions: List<Direction>,
|
||||
val directions: List<String>,
|
||||
val ingredients: List<Ingredient>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Direction(
|
||||
val instructions: String
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Ingredient(
|
||||
val amount: Double?,
|
||||
|
@ -48,11 +48,10 @@ class CreateDishActivity : AppCompatActivity() {
|
||||
saveButton.setOnClickListener {
|
||||
val ingredientList = collectIngredients()
|
||||
val instructions = findViewById<EditText>(R.id.instructions).text.toString().trim()
|
||||
val directions: List<Direction> = instructions
|
||||
val directions: List<String> = instructions
|
||||
.split("\n")
|
||||
.map { line -> line.trim() }
|
||||
.filter { it.isNotEmpty() }
|
||||
.map { line -> Direction(instructions = line) }
|
||||
|
||||
val recipe = Recipe(
|
||||
name = findViewById<EditText>(R.id.dishName).text.toString().trim(),
|
||||
@ -61,7 +60,6 @@ class CreateDishActivity : AppCompatActivity() {
|
||||
ingredients = ingredientList
|
||||
)
|
||||
|
||||
|
||||
val progressDialog = ProgressDialog(this)
|
||||
progressDialog.setMessage("Loading...")
|
||||
progressDialog.show()
|
||||
|
Loading…
Reference in New Issue
Block a user