Skip to content

Commit adcd396

Browse files
authored
fix : 문제목록에서 내가 푼 문제 api 변경, 내가 푼 문제 모달 마크다운 적용 (#131)
1 parent c2147bb commit adcd396

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

src/app/(auth)/(navigationsBarLayout)/mypage/tab/Mine.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ export const Mine = () => {
134134
request: body,
135135
image: editForm.profileImage ?? undefined,
136136
});
137-
// setUser()
138-
console.log(response);
137+
139138
setUser(response.result);
140139
toast.success(response.message, {
141140
richColors: false,

src/app/(auth)/(navigationsBarLayout)/mypage/ui/SolvedModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AlertDialogHeader } from '@/components/ui/alert-dialog';
22

33
import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
44
import { SubmissionsResonse } from '@/entities/mypage/model/types';
5+
import MarkdownRenderer from '@/shared/mdx/MdxRenderer';
56
import { Button } from '@/shared/ui/button/Button';
67
import { useRouter } from 'next/navigation';
78

@@ -40,7 +41,10 @@ export const SolvedModal = ({
4041
<div className="flex flex-row gap-1">
4142
<span className="w-25 shrink-0">설명</span>
4243

43-
<span className="whitespace-pre-line">{data?.problemDescription}</span>
44+
{/* <span className="whitespace-pre-line">{}</span> */}
45+
<div className="flex flex-col">
46+
<MarkdownRenderer source={data?.problemDescription} />
47+
</div>
4448
</div>
4549
<div className="flex flex-col gap-1 ">
4650
{data?.submissions.map((item, index) => {

src/app/(auth)/(navigationsBarLayout)/problems/ui/Table.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useState, useEffect, useMemo } from 'react';
33
import { useRouter } from 'next/navigation';
44
import { SkeletonBox } from '@/shared/ui/loading-indicators';
55
import { ProblemsContent } from '@/entities/problems/model/types';
6-
import { useSubmissionList } from '@/entities/mypage/model/query';
6+
import { useMyDailySolved, useSubmissionList } from '@/entities/mypage/model/query';
77
import { CheckCircle, ChevronLeft, ChevronRight } from 'lucide-react';
88
import { Button } from '@/components/ui/button';
99
import Cookies from 'js-cookie';
@@ -57,19 +57,31 @@ export default function ProblemTable({
5757
const router = useRouter();
5858
const [pageGroupStart, setPageGroupStart] = useState<number>(0); // 0-based group start
5959
const [myProblemsList, setMyProblemsList] = useState<number[]>([]);
60-
const { data: myProblems } = useSubmissionList();
60+
const { data: myProblems } = useMyDailySolved();
6161
// const { data: session } = useSession();
6262
const token = Cookies.get('accessToken');
6363

6464
useEffect(() => {
6565
setMyProblemsList([]);
6666
// if (!session) return;
6767
if (!token) return;
68-
console.log('123');
68+
6969
if (!myProblems) return;
70-
myProblems.result.forEach((item) => setMyProblemsList((prev) => [...prev, item.problemId]));
70+
// myProblems.forEach((item) => setMyProblemsList((prev) => [...prev, item.problemId]));
71+
// myProblems.data.result.dailySolvedCounts.map((item) =>
72+
// item.problems.map((item2) => console.log(item2))
73+
// );
74+
const solved = Array.from(
75+
new Set(myProblems.data.result.dailySolvedCounts.flatMap((item) => item.problemIds))
76+
);
77+
console.log(myProblems.data.result.dailySolvedCounts);
78+
setMyProblemsList(solved); // 하나의 배열에 담김
7179
}, [myProblems, token]);
7280

81+
useEffect(() => {
82+
console.log(myProblemsList);
83+
}, [myProblemsList]);
84+
7385
// currentPage가 page group 범위를 벗어나면 group start 재조정
7486
useEffect(() => {
7587
if (currentPage < pageGroupStart || currentPage >= pageGroupStart + PAGE_LIMIT) {

src/entities/mypage/model/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export interface DailySolved {
3131
dailySolvedCounts: {
3232
date: string;
3333
count: number;
34+
problemIds : number[]
3435
}[];
35-
userId: number;
3636
}
3737

3838
export interface IHeatmapItem {

0 commit comments

Comments
 (0)