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
This commit is contained in:
2025-09-01 20:18:57 +02:00
parent e668fbfeae
commit fffd271c06
11 changed files with 460 additions and 1 deletions
+11
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);