diff --git a/backend/src/contents/contents.controller.ts b/backend/src/contents/contents.controller.ts index e2dbe8d..8743f45 100644 --- a/backend/src/contents/contents.controller.ts +++ b/backend/src/contents/contents.controller.ts @@ -19,11 +19,11 @@ import { UseInterceptors, } from "@nestjs/common"; import { FileInterceptor } from "@nestjs/platform-express"; -import type { Request, Response } from "express"; +import type { Response } from "express"; +import { Roles } from "../auth/decorators/roles.decorator"; import { AuthGuard } from "../auth/guards/auth.guard"; import { OptionalAuthGuard } from "../auth/guards/optional-auth.guard"; import { RolesGuard } from "../auth/guards/roles.guard"; -import { Roles } from "../auth/decorators/roles.decorator"; import type { AuthenticatedRequest } from "../common/interfaces/request.interface"; import { ContentsService } from "./contents.service"; import { CreateContentDto } from "./dto/create-content.dto"; @@ -144,10 +144,7 @@ export class ContentsController { @Req() req: AuthenticatedRequest, @Res() res: Response, ) { - const content = await this.contentsService.findOne( - idOrSlug, - req.user?.sub, - ); + const content = await this.contentsService.findOne(idOrSlug, req.user?.sub); if (!content) { throw new NotFoundException("Contenu non trouvé"); } diff --git a/backend/src/contents/repositories/contents.repository.ts b/backend/src/contents/repositories/contents.repository.ts index 6041756..126b09c 100644 --- a/backend/src/contents/repositories/contents.repository.ts +++ b/backend/src/contents/repositories/contents.repository.ts @@ -135,9 +135,10 @@ export class ContentsRepository { fileSize: contents.fileSize, views: contents.views, usageCount: contents.usageCount, - favoritesCount: sql`(SELECT count(*) FROM ${favorites} WHERE ${favorites.contentId} = ${contents.id})`.mapWith( - Number, - ), + favoritesCount: + sql`(SELECT count(*) FROM ${favorites} WHERE ${favorites.contentId} = ${contents.id})`.mapWith( + Number, + ), isLiked: userId ? sql`EXISTS(SELECT 1 FROM ${favorites} WHERE ${favorites.contentId} = ${contents.id} AND ${favorites.userId} = ${userId})` : sql`false`, @@ -235,9 +236,10 @@ export class ContentsRepository { fileSize: contents.fileSize, views: contents.views, usageCount: contents.usageCount, - favoritesCount: sql`(SELECT count(*) FROM ${favorites} WHERE ${favorites.contentId} = ${contents.id})`.mapWith( - Number, - ), + favoritesCount: + sql`(SELECT count(*) FROM ${favorites} WHERE ${favorites.contentId} = ${contents.id})`.mapWith( + Number, + ), isLiked: userId ? sql`EXISTS(SELECT 1 FROM ${favorites} WHERE ${favorites.contentId} = ${contents.id} AND ${favorites.userId} = ${userId})` : sql`false`, diff --git a/frontend/src/components/content-card.tsx b/frontend/src/components/content-card.tsx index 9ae2151..1971d08 100644 --- a/frontend/src/components/content-card.tsx +++ b/frontend/src/components/content-card.tsx @@ -16,6 +16,7 @@ import { CardHeader, } from "@/components/ui/card"; import { useAuth } from "@/providers/auth-provider"; +import { ContentService } from "@/services/content.service"; import { FavoriteService } from "@/services/favorite.service"; import type { Content } from "@/types/content";