mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-31 02:03:35 -04:00 
			
		
		
		
	feat: duplicate recipes (#1750)
* feature/frontend: Add duplicate button to recipe * feature/backend: Add recipe duplication endpoint * feature/frontend: add duplication API call * Regenerate API docs * Fix linter errors * Fix backend linter error * Move recipe duplication logic to recipe service * Add test for recipe duplication * Improve recipe ingredients copy test * generate types * import type Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| import { Recipe } from "../types/recipe"; | ||||
| import { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated"; | ||||
|  | ||||
| export interface CrudAPIInterface { | ||||
| @@ -20,8 +21,7 @@ export abstract class BaseAPI { | ||||
|  | ||||
| export abstract class BaseCRUDAPI<CreateType, ReadType, UpdateType = CreateType> | ||||
|   extends BaseAPI | ||||
|   implements CrudAPIInterface | ||||
| { | ||||
|   implements CrudAPIInterface { | ||||
|   abstract baseRoute: string; | ||||
|   abstract itemRoute(itemId: string | number): string; | ||||
|  | ||||
| @@ -50,4 +50,10 @@ export abstract class BaseCRUDAPI<CreateType, ReadType, UpdateType = CreateType> | ||||
|   async deleteOne(itemId: string | number) { | ||||
|     return await this.requests.delete<ReadType>(this.itemRoute(itemId)); | ||||
|   } | ||||
|  | ||||
|   async duplicateOne(itemId: string | number, newName: string | undefined) { | ||||
|     return await this.requests.post<Recipe>(`${this.itemRoute(itemId)}/duplicate`, { | ||||
|       name: newName, | ||||
|     }); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user