Conversation
…elationships; update seed.ts with completion data
… post pages - Added basic CategoryPage layout. - Created initial ThreadDetailPage structure. - Scaffolded CreatePostForm UI without submission logic. - Added placeholder NewPostButton component. - Updated sidebar with static forum link.
- Implemented logic to create new posts via CreatePostForm. - Added utilities and libraries to parse and render markdown content. - Integrated category selection in post creation flow.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
agustin-sanc
left a comment
There was a problem hiding this comment.
Muy buen trabajo hasta ahora Mati! Dejé algunos comentarios
| isPinned Boolean @default(false) | ||
| isLocked Boolean @default(false) |
There was a problem hiding this comment.
Estos nombres podrian ser simplificados a pinned y locked
| return { | ||
| success: true, | ||
| post, | ||
| }; |
There was a problem hiding this comment.
Por qué estamos retornando success true aquí? El patrón que usamos es que si la server action retorna sin lanzar un error con throw, entonces se ejecutó exitosamente
| // Obtener el ID del usuario desde las cookies/sesión | ||
| const cookieStore = await cookies(); | ||
| const sessionId = cookieStore.get('sessionId')?.value; | ||
|
|
||
| if (!sessionId) { | ||
| throw new Error('No hay sesión activa'); | ||
| } | ||
|
|
||
| // Buscar la sesión para obtener el userId | ||
| const session = await prisma.session.findUnique({ | ||
| where: { id: sessionId }, | ||
| select: { userId: true }, | ||
| }); | ||
|
|
||
| if (!session) { | ||
| throw new Error('Sesión inválida'); | ||
| } |
There was a problem hiding this comment.
Creo que pusimos esta lógica en una función porque se repetía en varias server actions
| if (error instanceof Error) { | ||
| throw error; | ||
| } |
There was a problem hiding this comment.
Este if siempre va a ser true, puede ser?
| return { | ||
| success: true, | ||
| message: 'Post eliminado exitosamente', | ||
| }; |
There was a problem hiding this comment.
Esta server action podria no retornar nada directamente cuando se ejecuta exitosamente. El mensaje de post eliminado exitosamente puede estar definido en el frontend para minimizar el traslado de data
| } | ||
|
|
||
| return { | ||
| success: true, |
There was a problem hiding this comment.
Ese success deberíamos sacarlo
| revalidatePath(`/foro/tema/${postId}`); | ||
|
|
||
| return { | ||
| success: true, |
There was a problem hiding this comment.
Este success deberiamos sacarlo
| categoryId: z.string().min(1, 'La categoría es requerida'), | ||
| }); | ||
|
|
||
| export async function updatePost(postId: string, data: z.infer<typeof updatePostSchema>) { |
There was a problem hiding this comment.
Un patrón copado es recibir un objeto en la entrada de una función cuando la función recibe más de un parámetro. Los beneficios de hacer eso es que el orden de los parámetros no importa cuando invocas la función, y también beneficia la lectura del código, porque podes saber mejor qué representa cada parámetro que le estas pasando. La idea seria aplicar este patrón en todas las funciones que cumplan esa condición, capaz algunas necesitan un refactor
| const totalPosts = posts.length; | ||
| const totalComments = await prisma.postComment.count({ | ||
| where: { | ||
| post: { | ||
| categoryId: category.id, | ||
| }, | ||
| }, | ||
| }); | ||
| return ( |
There was a problem hiding this comment.
Acá estaría bueno agregar un par de líneas en blanco
| const totalPosts = posts.length; | |
| const totalComments = await prisma.postComment.count({ | |
| where: { | |
| post: { | |
| categoryId: category.id, | |
| }, | |
| }, | |
| }); | |
| return ( | |
| const totalPosts = posts.length; | |
| const totalComments = await prisma.postComment.count({ | |
| where: { | |
| post: { | |
| categoryId: category.id, | |
| }, | |
| }, | |
| }); | |
| return ( |
Preview V1.0 del foro de PCN con las siguientes funcionalidades:
Screencast.from.2025-07-21.16-06-48.webm
Screencast.from.2025-07-21.16-08-24.webm
Screencast.from.2025-07-21.16-09-55.webm
Screencast.from.2025-07-21.16-11-12.webm