import { Body, Controller, Get, HttpCode, Post } from '@nestjs/common'; import { CurrentCustomer, CustomerAuth } from '../customer-auth/customer.guards'; import type { AuthenticatedCustomer } from '../customer-auth/customer-jwt.strategy'; import { CustomerFavoritesService } from './customer-favorites.service'; import { ToggleFavoriteDto } from './dto/toggle-favorite.dto'; /** * Legacy endpoints (routes/api.php:84-85, customer guard): * POST add-to-fav -> POST customer/me/favorites/toggle * POST get-favorites -> GET customer/me/favorites * The customer always comes from the token (D21); for a sales expert that is * their trading account. */ @Controller('customer/me/favorites') export class CustomerFavoritesController { constructor(private readonly favorites: CustomerFavoritesService) {} @CustomerAuth() @Get() list(@CurrentCustomer() me: AuthenticatedCustomer) { return this.favorites.list(me.id); } @CustomerAuth() @Post('toggle') @HttpCode(200) toggle(@Body() dto: ToggleFavoriteDto, @CurrentCustomer() me: AuthenticatedCustomer) { return this.favorites.toggle(me.id, dto.productId); } }