From 8f41d54a8159be476c9e3487a30a53d7b96541a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Mon, 9 Dec 2024 20:24:52 +0300 Subject: [PATCH 1/4] feat(frontend): add followed tags section --- frontend/src/routes/profile.tsx | 23 +++++++++++++++++-- frontend/src/routes/question.test.tsx | 6 +++++ .../services/api/programmingForumSchemas.ts | 4 +++- .../services/api/programmingForumSchemas.ts | 4 +++- swagger/openapi.yml | 8 ++++++- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/frontend/src/routes/profile.tsx b/frontend/src/routes/profile.tsx index 22f6e98f..27473b0b 100644 --- a/frontend/src/routes/profile.tsx +++ b/frontend/src/routes/profile.tsx @@ -17,6 +17,7 @@ import useAuthStore from "@/services/auth"; import { useEffect, useRef, useState } from "react"; import { Link, useParams } from "react-router-dom"; +import { Badge } from "@/components/ui/badge"; import { Textarea } from "@/components/ui/textarea"; export default function Profile() { @@ -83,10 +84,10 @@ export default function Profile() { />
- {/*
+
{profile.questionCount}
Questions
-
*/} +
{profile.answerCount}
Answers
@@ -166,6 +167,24 @@ export default function Profile() { ) )}
+
+
+ + Followed tags: + {profile.followedTags + ?.map((s) => ( + + {s.name} + + )) + .slice(0, 3)}{" "} + {profile.followedTags?.length && + profile.followedTags?.length > 3 && ( + + {profile.followedTags?.length - 3} more + )} + +
+
diff --git a/frontend/src/routes/question.test.tsx b/frontend/src/routes/question.test.tsx index dc1b4ad0..fecfe9c8 100644 --- a/frontend/src/routes/question.test.tsx +++ b/frontend/src/routes/question.test.tsx @@ -36,6 +36,12 @@ const mockQuestionData = vi.hoisted( createdAt: "2023-01-01T00:00:00Z", updatedAt: "2023-01-01T00:00:00Z", dislikeCount: 0, + bookmarked: false, + selfVoted: 1, + selfDifficultyVote: "EASY", + easyCount: 0, + hardCount: 0, + mediumCount: 0, }) satisfies QuestionDetails, ); // Mock the API hook diff --git a/frontend/src/services/api/programmingForumSchemas.ts b/frontend/src/services/api/programmingForumSchemas.ts index 281d26d5..e330ae3e 100644 --- a/frontend/src/services/api/programmingForumSchemas.ts +++ b/frontend/src/services/api/programmingForumSchemas.ts @@ -86,6 +86,7 @@ export type UserProfile = { answerCount?: number; answers?: AnswerDetails[]; questions?: QuestionSummary[]; + followedTags?: TagSummary[]; }; export type UserProfileUpdate = { @@ -150,7 +151,7 @@ export type QuestionDetails = { * @maximum 1 */ selfVoted: number; - selfDifficultyVote: boolean; + selfDifficultyVote: DifficultyLevel; easyCount: number; mediumCount: number; hardCount: number; @@ -261,6 +262,7 @@ export type TagDetails = { export type TagSummary = { id?: string; name?: string; + tagType?: TagType; questionCount?: number; /** * @format url diff --git a/mobile/services/api/programmingForumSchemas.ts b/mobile/services/api/programmingForumSchemas.ts index 281d26d5..e330ae3e 100644 --- a/mobile/services/api/programmingForumSchemas.ts +++ b/mobile/services/api/programmingForumSchemas.ts @@ -86,6 +86,7 @@ export type UserProfile = { answerCount?: number; answers?: AnswerDetails[]; questions?: QuestionSummary[]; + followedTags?: TagSummary[]; }; export type UserProfileUpdate = { @@ -150,7 +151,7 @@ export type QuestionDetails = { * @maximum 1 */ selfVoted: number; - selfDifficultyVote: boolean; + selfDifficultyVote: DifficultyLevel; easyCount: number; mediumCount: number; hardCount: number; @@ -261,6 +262,7 @@ export type TagDetails = { export type TagSummary = { id?: string; name?: string; + tagType?: TagType; questionCount?: number; /** * @format url diff --git a/swagger/openapi.yml b/swagger/openapi.yml index f95bd55f..345fe21d 100644 --- a/swagger/openapi.yml +++ b/swagger/openapi.yml @@ -1297,6 +1297,10 @@ components: type: array items: $ref: "#/components/schemas/QuestionSummary" + followedTags: + type: array + items: + $ref: "#/components/schemas/TagSummary" examples: - id: 1 username: "john_doe" @@ -1447,7 +1451,7 @@ components: minimum: -1 maximum: 1 selfDifficultyVote: - type: boolean + $ref: "#/components/schemas/DifficultyLevel" easyCount: type: integer mediumCount: @@ -1709,6 +1713,8 @@ components: type: string name: type: string + tagType: + $ref: '#/components/schemas/TagType' questionCount: type: integer photo: From f80d4c535b05319412556515d3573979046605e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Mon, 9 Dec 2024 20:31:08 +0300 Subject: [PATCH 2/4] fix question route --- frontend/src/routes/profile.tsx | 36 +++++++++++++++++--------------- frontend/src/routes/question.tsx | 4 ++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/frontend/src/routes/profile.tsx b/frontend/src/routes/profile.tsx index 27473b0b..27858f73 100644 --- a/frontend/src/routes/profile.tsx +++ b/frontend/src/routes/profile.tsx @@ -167,24 +167,26 @@ export default function Profile() { ) )}
-
-
- - Followed tags: - {profile.followedTags - ?.map((s) => ( - - {s.name} - - )) - .slice(0, 3)}{" "} - {profile.followedTags?.length && - profile.followedTags?.length > 3 && ( - + {profile.followedTags?.length - 3} more - )} - + {profile.followedTags && ( +
+
+ + Followed tags: + {profile.followedTags + ?.map((s) => ( + + {s.name} + + )) + .slice(0, 3)} + {profile.followedTags?.length && + profile.followedTags?.length > 3 && ( + + {profile.followedTags?.length - 3} more + )} + +
-
+ )}
diff --git a/frontend/src/routes/question.tsx b/frontend/src/routes/question.tsx index bfe83703..9b28ce7c 100644 --- a/frontend/src/routes/question.tsx +++ b/frontend/src/routes/question.tsx @@ -1,5 +1,6 @@ import LinkIcon from "@/assets/Icon/General/Link.svg?react"; import { Answers } from "@/components/Answers"; +import { ContentWithSnippets } from "@/components/ContentWithSnippets"; import { CreateAnswerForm } from "@/components/CreateAnswerForm"; import ErrorAlert from "@/components/ErrorAlert"; import { ExerciseCard } from "@/components/ExerciseCard"; @@ -19,7 +20,6 @@ import { convertTagToTrack, useExercismSearch } from "@/services/exercism"; import { Flag, MessageSquare, ThumbsDown, ThumbsUp, Trash } from "lucide-react"; import { useState } from "react"; import { Link, useParams } from "react-router-dom"; -import { ContentWithSnippets } from "@/components/ContentWithSnippets"; export default function QuestionPage() { const { questionId } = useParams(); @@ -75,7 +75,7 @@ export default function QuestionPage() { difficulty: (data as unknown as { difficultyLevel: string })?.difficultyLevel ?? "easy", - track: convertTagToTrack(data?.tags[0].name ?? ""), + track: convertTagToTrack(data?.tags?.[0]?.name ?? ""), }, }, { From 3d4abc3ba4590d1514e286b65635b18012cc0a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Mon, 9 Dec 2024 20:33:13 +0300 Subject: [PATCH 3/4] empty commit to rerun checks From d9cc470c8f28f94d6b3bddf4545eddd76257c8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Efe=20Ak=C3=A7a?= Date: Mon, 9 Dec 2024 21:28:40 +0300 Subject: [PATCH 4/4] fix tests --- frontend/src/routes/question.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/routes/question.tsx b/frontend/src/routes/question.tsx index 9efa4341..d7f28b5b 100644 --- a/frontend/src/routes/question.tsx +++ b/frontend/src/routes/question.tsx @@ -2,6 +2,7 @@ import LinkIcon from "@/assets/Icon/General/Link.svg?react"; import { Answers } from "@/components/Answers"; import { ContentWithSnippets } from "@/components/ContentWithSnippets"; import { CreateAnswerForm } from "@/components/CreateAnswerForm"; +import { DifficultyBar } from "@/components/DifficultyBar"; import ErrorAlert from "@/components/ErrorAlert"; import { ExerciseCard } from "@/components/ExerciseCard"; import FollowButton from "@/components/FollowButton"; @@ -20,8 +21,6 @@ import { convertTagToTrack, useExercismSearch } from "@/services/exercism"; import { Flag, MessageSquare, ThumbsDown, ThumbsUp, Trash } from "lucide-react"; import { useState } from "react"; import { Link, useParams } from "react-router-dom"; -import { ContentWithSnippets } from "@/components/ContentWithSnippets"; -import { DifficultyBar } from "@/components/DifficultyBar"; export default function QuestionPage() { const { questionId } = useParams();