diff --git a/app/app/src/main/java/tech/mercantec/easyeat/helpers/dishes.kt b/app/app/src/main/java/tech/mercantec/easyeat/helpers/dishes.kt index d907915..e0aa866 100644 --- a/app/app/src/main/java/tech/mercantec/easyeat/helpers/dishes.kt +++ b/app/app/src/main/java/tech/mercantec/easyeat/helpers/dishes.kt @@ -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) -@Serializable -data class GenerateRecipeResponse(val name: String, val description: String, val directions: Array, val ingredients: Array) - -fun generateRecipeWithAI(ctx: Context, title: String, language: String): GenerateRecipeResponse { - return requestJson(ctx, "POST", "/api/Recipe/chatbot", GenerateRecipeRequest(title, language, 1, arrayOf())) +fun generateRecipeWithAI(ctx: Context, title: String, language: String): Recipe { + return requestJson(ctx, "POST", "/api/Recipe/chatbot", GenerateRecipeRequest(title, language, 1, arrayOf())) } diff --git a/app/app/src/main/java/tech/mercantec/easyeat/models/recipe.kt b/app/app/src/main/java/tech/mercantec/easyeat/models/recipe.kt index 1215baa..adda852 100644 --- a/app/app/src/main/java/tech/mercantec/easyeat/models/recipe.kt +++ b/app/app/src/main/java/tech/mercantec/easyeat/models/recipe.kt @@ -6,16 +6,10 @@ import kotlinx.serialization.Serializable data class Recipe( val name: String, val description: String, - val directions: List, + val directions: List, val ingredients: List ) -@Serializable -data class Direction( - val instructions: String -) - - @Serializable data class Ingredient( val amount: Double?, diff --git a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/CreateDishActivity.kt b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/CreateDishActivity.kt index e6fdd74..be9b294 100644 --- a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/CreateDishActivity.kt +++ b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/CreateDishActivity.kt @@ -48,11 +48,10 @@ class CreateDishActivity : AppCompatActivity() { saveButton.setOnClickListener { val ingredientList = collectIngredients() val instructions = findViewById(R.id.instructions).text.toString().trim() - val directions: List = instructions + val directions: List = instructions .split("\n") .map { line -> line.trim() } .filter { it.isNotEmpty() } - .map { line -> Direction(instructions = line) } val recipe = Recipe( name = findViewById(R.id.dishName).text.toString().trim(), @@ -61,7 +60,6 @@ class CreateDishActivity : AppCompatActivity() { ingredients = ingredientList ) - val progressDialog = ProgressDialog(this) progressDialog.setMessage("Loading...") progressDialog.show()