Add CreateRecipePage component for recipe creation with ingredients. Updated UX
This commit is contained in:
@@ -4,9 +4,27 @@ import {
|
||||
IsString,
|
||||
ValidateNested,
|
||||
ArrayMinSize,
|
||||
IsInt,
|
||||
IsNumber,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { CreateRecipeIngredientDto } from './create-recipe-ingredient.dto';
|
||||
|
||||
class CreateRecipeIngredientDto {
|
||||
@IsInt()
|
||||
productId!: number;
|
||||
|
||||
@IsNumber()
|
||||
@Min(0.01)
|
||||
quantity!: number;
|
||||
|
||||
@IsString()
|
||||
unit!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export class CreateRecipeDto {
|
||||
@IsString()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Body, Controller, Get, Param, ParseIntPipe, Post } from '@nestjs/common';
|
||||
import { CreateRecipeDto } from './dto/create-recipe.dto';
|
||||
import { RecipesService } from './recipes.service';
|
||||
import { CreateRecipeDto } from './dto/create-recipe.dto';
|
||||
|
||||
@Controller('recipes')
|
||||
export class RecipesController {
|
||||
@@ -22,7 +22,7 @@ export class RecipesController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() body: CreateRecipeDto) {
|
||||
return this.recipesService.create(body);
|
||||
async create(@Body() createRecipeDto: CreateRecipeDto) {
|
||||
return this.recipesService.create(createRecipeDto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user