fixed errors in merge

This commit is contained in:
LilleBRG 2025-05-13 15:24:25 +02:00
parent 12427a85f8
commit 1e01d1ee90
3 changed files with 3 additions and 22 deletions

View File

@ -3,9 +3,8 @@ package tech.mercantec.easyeat.helpers
import android.content.Context
import android.util.Log
import kotlinx.serialization.Serializable
import tech.mercantec.easyeat.models.CreateIngredient
import tech.mercantec.easyeat.models.CreateRecipe
import tech.mercantec.easyeat.models.Ingredient
import tech.mercantec.easyeat.models.Recipe
@Serializable
data class LoginRequest(val emailUsr: String, val password: String)
@ -113,28 +112,11 @@ fun changePassword(ctx: Context, oldPassword: String, newPassword: String) {
return requestJson<ChangePasswordRequest, Unit>(ctx, "PUT", "/api/User/change-password", request)
}
@Serializable
data class CreateRecipeRequest(val name: String, val description: String, val directions: List<String>, val ingredients: List<CreateIngredient>)
fun createRecipe(ctx: Context, recipe: CreateRecipe) {
val request = CreateRecipeRequest(recipe.name, recipe.description, recipe.directions, recipe.ingredients)
requestJson<CreateRecipeRequest, Boolean>(ctx, "POST", "/api/recipe/create", request)
}
@Serializable
data class GetAllRecipesResponse(val id: Int, val name: String, val description: String)
fun getAllRecipies(ctx: Context): List<GetAllRecipesResponse> {
return requestJson<Unit, List<GetAllRecipesResponse>>(ctx, "GET", "/api/Recipe/getall", null)
}
@Serializable
data class RecipeDetailsResponse(val id: Int, val name: String, val description: String, val directions: List<String>, val ingredients: List<Ingredient>)
fun getRecipeDetails(ctx: Context, id: Int): RecipeDetailsResponse {
return requestJson<Unit, RecipeDetailsResponse>(ctx, "GET", "/api/Recipe/get/$id", null)
}
@Serializable
data class ShoppingListAddRecipeRequest(val id: Int, val multiplier: Int)

View File

@ -19,7 +19,7 @@ fun createRecipe(ctx: Context, recipe: Recipe) {
@Serializable
data class GetAllRecipesResponse(val id: Int, val name: String, val description: String)
fun getAllRecipes(ctx: Context): List<GetAllRecipesResponse> {
fun getAllRecipies(ctx: Context): List<GetAllRecipesResponse> {
return requestJson<Unit, List<GetAllRecipesResponse>>(ctx, "GET", "/api/Recipe/getall", null)
}
@ -29,3 +29,4 @@ data class RecipeDetailsResponse(val id: Int, val name: String, val description:
fun getRecipeDetails(ctx: Context, id: Int): RecipeDetailsResponse {
return requestJson<Unit, RecipeDetailsResponse>(ctx, "GET", "/api/Recipe/get/$id", null)
}

View File

@ -18,8 +18,6 @@ import android.widget.EditText
import android.widget.TextView
import androidx.core.widget.doAfterTextChanged
import tech.mercantec.easyeat.helpers.AddRecipeToShoppingList
import tech.mercantec.easyeat.helpers.createRecipe
import tech.mercantec.easyeat.models.CreateRecipe
import tech.mercantec.easyeat.models.Ingredient
class DishDetailsActivity : AppCompatActivity() {