feat: add rematch functionality for recipe ingredients and enhance inventory management
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
- Added a new API path for rematching recipe ingredients in `api_paths.dart`. - Implemented a manual product creation dialog in `inventory_screen.dart` to allow users to create new products directly. - Integrated the rematch functionality in `recipe_repository.dart` to handle rematching of recipe ingredients. - Updated the recipe detail screen to include a button for triggering the rematch process. - Introduced a new `RecipeMatchingService` in the backend to handle ingredient matching logic. - Added database migration to include `aiEngineEnabled` column in the User table. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -19,6 +19,11 @@ class SetRecipeSharingDto {
|
||||
canShareRecipes: boolean;
|
||||
}
|
||||
|
||||
class SetAiEngineEnabledDto {
|
||||
@IsBoolean()
|
||||
aiEngineEnabled: boolean;
|
||||
}
|
||||
|
||||
class AdminCreateUserDto {
|
||||
@IsString()
|
||||
@MinLength(2)
|
||||
@@ -128,6 +133,16 @@ export class UsersController {
|
||||
return { id: updated.id, username: updated.username, canShareRecipes: updated.canShareRecipes };
|
||||
}
|
||||
|
||||
@Roles('admin')
|
||||
@Patch(':id/ai-engine')
|
||||
async setAiEngineEnabled(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() dto: SetAiEngineEnabledDto,
|
||||
) {
|
||||
const updated = await this.usersService.setAiEngineEnabled(id, dto.aiEngineEnabled);
|
||||
return { id: updated.id, username: updated.username, aiEngineEnabled: updated.aiEngineEnabled };
|
||||
}
|
||||
|
||||
@Roles('admin')
|
||||
@Post()
|
||||
async adminCreateUser(
|
||||
|
||||
@@ -34,6 +34,7 @@ export class UsersService {
|
||||
role: true,
|
||||
isPremium: true,
|
||||
canShareRecipes: true,
|
||||
aiEngineEnabled: true,
|
||||
createdAt: true,
|
||||
},
|
||||
orderBy: { username: 'asc' },
|
||||
@@ -52,6 +53,10 @@ export class UsersService {
|
||||
return this.prisma.user.update({ where: { id }, data: { canShareRecipes } });
|
||||
}
|
||||
|
||||
setAiEngineEnabled(id: number, aiEngineEnabled: boolean) {
|
||||
return this.prisma.user.update({ where: { id }, data: { aiEngineEnabled } });
|
||||
}
|
||||
|
||||
async adminCreate(data: { username: string; email: string; password: string; role?: string }) {
|
||||
const existing = await this.prisma.user.findFirst({
|
||||
where: { OR: [{ username: data.username }, { email: data.email }] },
|
||||
|
||||
Reference in New Issue
Block a user