diff --git a/frontend/src/components/AnswerCard.tsx b/frontend/src/components/AnswerCard.tsx index a5736d3e..8de70cc8 100644 --- a/frontend/src/components/AnswerCard.tsx +++ b/frontend/src/components/AnswerCard.tsx @@ -24,7 +24,7 @@ export const AnswerCard: React.FC = ({ author, }) => { return ( - +

{title} diff --git a/frontend/src/components/AnswerItem.tsx b/frontend/src/components/AnswerItem.tsx index 9ffe68fc..6e519d0d 100644 --- a/frontend/src/components/AnswerItem.tsx +++ b/frontend/src/components/AnswerItem.tsx @@ -21,7 +21,7 @@ export const AnswerItem: React.FC = ({ const { token } = useAuthStore(); return ( - +
diff --git a/frontend/src/components/ExerciseCard.tsx b/frontend/src/components/ExerciseCard.tsx index 221a8db6..cae446c5 100644 --- a/frontend/src/components/ExerciseCard.tsx +++ b/frontend/src/components/ExerciseCard.tsx @@ -20,7 +20,7 @@ export const ExerciseCard: React.FC = ({ link, }) => { return ( - +

{title} @@ -28,7 +28,7 @@ export const ExerciseCard: React.FC = ({

{description}

-
+
Difficulty: {difficulty} diff --git a/frontend/src/components/QuestionCard.tsx b/frontend/src/components/QuestionCard.tsx index 6e674181..de7e8b79 100644 --- a/frontend/src/components/QuestionCard.tsx +++ b/frontend/src/components/QuestionCard.tsx @@ -27,7 +27,7 @@ export const QuestionCard = React.forwardRef( ({ id, title, content, votes, answerCount, author, difficulty }, ref) => { return (
@@ -65,7 +65,7 @@ export const QuestionCard = React.forwardRef( )} Go to question diff --git a/frontend/src/components/TagCard.tsx b/frontend/src/components/TagCard.tsx index da470d9c..6e7682a8 100644 --- a/frontend/src/components/TagCard.tsx +++ b/frontend/src/components/TagCard.tsx @@ -12,7 +12,7 @@ export const TagCard = React.forwardRef( ({ tag }, ref) => { return (
diff --git a/mobile/app/question/[questionId].tsx b/mobile/app/question/[questionId].tsx index 7eb83e46..c56ea7e4 100644 --- a/mobile/app/question/[questionId].tsx +++ b/mobile/app/question/[questionId].tsx @@ -27,7 +27,14 @@ import { } from "@/services/api/programmingForumComponents"; import useAuthStore from "@/services/auth"; import { Link, useLocalSearchParams, useRouter } from "expo-router"; -import { ArrowLeftIcon, BookmarkIcon, Flag, MessageSquare, ThumbsUp, Trash } from "lucide-react-native"; +import { + ArrowLeftIcon, + BookmarkIcon, + Flag, + MessageSquare, + ThumbsUp, + Trash, +} from "lucide-react-native"; import { useEffect, useState } from "react"; import { ScrollView, View } from "react-native"; export default function QuestionPage() { @@ -49,13 +56,15 @@ export default function QuestionPage() { } ); const data = result?.data; - const question = data! || {}; + const question = data! || {}; const { mutateAsync: deleteQuestion } = useDeleteQuestionById(); const { selfProfile, token } = useAuthStore(); const [optimisticVotes, setOptimisticVotes] = useState(null); - const [optimisticBookmarked, setOptimisticBookmarked] = useState(question.bookmarked ?? false); + const [optimisticBookmarked, setOptimisticBookmarked] = useState( + question.bookmarked ?? false + ); useEffect(() => { setOptimisticBookmarked(question.bookmarked ?? false); @@ -89,21 +98,25 @@ export default function QuestionPage() { }, }); - const { mutateAsync: bookmarkQuestion, isPending: isPendingBookmark } = useBookmarkQuestion({ - onMutate: async () => { - setOptimisticBookmarked(true); - }, - onSuccess: () => { - refetch().then(() => { + const { mutateAsync: bookmarkQuestion, isPending: isPendingBookmark } = + useBookmarkQuestion({ + onMutate: async () => { setOptimisticBookmarked(true); - }); - }, - onError: () => { - setOptimisticBookmarked(false); - }, - }); + }, + onSuccess: () => { + refetch().then(() => { + setOptimisticBookmarked(true); + }); + }, + onError: () => { + setOptimisticBookmarked(false); + }, + }); - const { mutateAsync: unbookmarkQuestion, isPending: isPendingRemoveBookmark} = useRemoveQuestionBookmark({ + const { + mutateAsync: unbookmarkQuestion, + isPending: isPendingRemoveBookmark, + } = useRemoveQuestionBookmark({ onMutate: async () => { setOptimisticBookmarked(false); }, @@ -117,7 +130,6 @@ export default function QuestionPage() { }, }); - if (isLoading) { return ; } @@ -142,7 +154,7 @@ export default function QuestionPage() { } else { bookmarkQuestion({ pathParams: { questionId: question.id } }); } - } + }; return ( @@ -158,7 +170,7 @@ export default function QuestionPage() {