Skip to content

Commit 325f34b

Browse files
committed
fix: use slug instead of _id for comment section identifiers
1 parent dd23c17 commit 325f34b

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

apps/uno/http/routes/api/comment_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestGetCommentsByIDHandler(t *testing.T) {
6464
tt.setupMocks(mockCommentRepo)
6565

6666
commentService := service.NewCommentService(mockCommentRepo)
67-
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, handler.NoMiddleware)
67+
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, nil, handler.NoMiddleware)
6868

6969
r := httptest.NewRequest(http.MethodGet, "/"+tt.commentID, nil)
7070
r.SetPathValue("id", tt.commentID)
@@ -130,7 +130,7 @@ func TestCreateCommentHandler(t *testing.T) {
130130
tt.setupMocks(mockCommentRepo)
131131

132132
commentService := service.NewCommentService(mockCommentRepo)
133-
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, handler.NoMiddleware)
133+
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, nil, handler.NoMiddleware)
134134

135135
var r *http.Request
136136
if tt.name == "invalid json" {
@@ -205,7 +205,7 @@ func TestReactToCommentHandler(t *testing.T) {
205205
tt.setupMocks(mockCommentRepo)
206206

207207
commentService := service.NewCommentService(mockCommentRepo)
208-
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, handler.NoMiddleware)
208+
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, nil, handler.NoMiddleware)
209209

210210
var r *http.Request
211211
if tt.name == "invalid json" {
@@ -268,7 +268,7 @@ func TestDeleteCommentHandler(t *testing.T) {
268268
tt.setupMocks(mockCommentRepo)
269269

270270
commentService := service.NewCommentService(mockCommentRepo)
271-
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, handler.NoMiddleware)
271+
mux := api.NewCommentMux(testutil.NewTestLogger(), commentService, nil, handler.NoMiddleware)
272272

273273
r := httptest.NewRequest(http.MethodDelete, "/"+tt.commentID, nil)
274274
r.SetPathValue("id", tt.commentID)

apps/web/src/app/(default)/for-studenter/innlegg/[slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async function PostPage(props: Props) {
5353
<Authors authors={post.authors} />
5454
<Markdown content={post.body} />
5555
<Suspense fallback={null}>
56-
<CommentSection id={`post_${post._id}`} />
56+
<CommentSection id={`post_${post.slug}`} />
5757
</Suspense>
5858
</Container>
5959
);

apps/web/src/components/happening/event-page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const EventPage = ({ event }: EventPageProps) => {
2525
event.title.toLowerCase().includes(keyword) || event.body?.toLowerCase().includes(keyword),
2626
) && event.happeningType === "event";
2727

28+
const commentSectionId = `event_${event.slug}`;
29+
2830
return (
2931
<div>
3032
{isCompanyLeague && (
@@ -63,7 +65,7 @@ export const EventPage = ({ event }: EventPageProps) => {
6365
</article>
6466

6567
<Suspense fallback={null}>
66-
<CommentSection className="mt-10" id={`event_${event._id}`} />
68+
<CommentSection className="mt-10" id={commentSectionId} />
6769
</Suspense>
6870
</div>
6971
</Container>

0 commit comments

Comments
 (0)