From 2881ae73f203d90cb3f725658cbae716320220c2 Mon Sep 17 00:00:00 2001 From: Howard Sun Date: Mon, 17 Jun 2024 16:23:39 -0400 Subject: [PATCH] CHE-120 added typing to post-reply to pass tests --- client/src/components/Forums/ThreadDetails/ThreadDetails.tsx | 2 +- client/src/components/Forums/ThreadsDisplay/ThreadsDisplay.tsx | 2 +- client/types/forums.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/components/Forums/ThreadDetails/ThreadDetails.tsx b/client/src/components/Forums/ThreadDetails/ThreadDetails.tsx index ecf01af..f655256 100644 --- a/client/src/components/Forums/ThreadDetails/ThreadDetails.tsx +++ b/client/src/components/Forums/ThreadDetails/ThreadDetails.tsx @@ -59,7 +59,7 @@ const ThreadDetail = ({ forumId, threadId }: ThreadDetailProps) => { } }; - const totalPosts = posts.length + 1; + const totalPosts: number = posts.length + 1; if (loading) return
Loading...
; if (error) return
Error: {error}
; diff --git a/client/src/components/Forums/ThreadsDisplay/ThreadsDisplay.tsx b/client/src/components/Forums/ThreadsDisplay/ThreadsDisplay.tsx index 2177c1e..2bf2bd5 100644 --- a/client/src/components/Forums/ThreadsDisplay/ThreadsDisplay.tsx +++ b/client/src/components/Forums/ThreadsDisplay/ThreadsDisplay.tsx @@ -45,7 +45,7 @@ const ThreadsDisplay = ({ forumId, onThreadSelect }: ThreadsDisplayProps) => { setCreatingThread(!creatingThread); }; - function formatReplies(count) { + function formatReplies(count: number) { if (count === 0) return 'No replies'; if (count === 1) return '1 reply'; return `${count} replies`; diff --git a/client/types/forums.ts b/client/types/forums.ts index 496cfea..6e30beb 100644 --- a/client/types/forums.ts +++ b/client/types/forums.ts @@ -12,6 +12,7 @@ export interface Thread { content: string; user: IUser; createdAt: string; + postCount: number; } export interface IForum {