Implement user favorites feature for recipes

- Add UserFavorites MongoDB model with ObjectId references
- Create authenticated API endpoints for favorites management
- Add Heart icon and FavoriteButton components with toggle functionality
- Display favorite button below recipe tags for logged-in users
- Add Favoriten navigation link (visible only when authenticated)
- Create favorites page with grid layout and search functionality
- Store favorites by MongoDB ObjectId for data integrity

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-01 20:18:57 +02:00
parent 77d335ad8d
commit cd54ad0498
11 changed files with 460 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
import mongoose from 'mongoose';
const UserFavoritesSchema = new mongoose.Schema(
{
username: { type: String, required: true, unique: true },
favorites: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Recipe' }] // Recipe MongoDB ObjectIds
},
{ timestamps: true }
);
export const UserFavorites = mongoose.model("UserFavorites", UserFavoritesSchema);