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:
11
src/models/UserFavorites.ts
Normal file
11
src/models/UserFavorites.ts
Normal 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);
|
||||
Reference in New Issue
Block a user