Skip to content

#52 feat: 문제 선택 페이지 구현 및 과제 API 연동#57

Open
suminb99 wants to merge 15 commits intodevelopfrom
feat/52-select-manage-assignment-api
Open

#52 feat: 문제 선택 페이지 구현 및 과제 API 연동#57
suminb99 wants to merge 15 commits intodevelopfrom
feat/52-select-manage-assignment-api

Conversation

@suminb99
Copy link
Contributor

@suminb99 suminb99 commented Feb 26, 2026

⚙️ Related ISSUE Number

Related #52



📄 Work Description

API 연동

  • 과제 관련 조회/연결/해제 API 추가
  • 과제 응답 타입 추가 및 쿼리/뮤테이션 옵션 구성
  • 강의 삭제 뮤테이션 옵션 추가
  • query 파일 구조 개선 및 리팩토링된 query/mutation 적용

과제 선택 페이지

  • 과제 선택 방식을 ID 기반 → Assignment 객체 기반으로 변경
  • 선택 확인 시 useUnitStore에 저장 후 이전 페이지로 복귀

단원 폼 상태 유지

  • 과제 선택 페이지 이동 시 단원 폼 데이터를 sessionStorage에 임시 저장 (useUnitStore)
  • 복귀 시 저장된 폼 상태(title, releaseDate, dueDate, assignments) 복원



📷 Screenshot



💬 To Reviewers

TODO

  • API 응답/요청 타입을 zod 스키마 기반으로 변경



🔗 Reference

@suminb99 suminb99 linked an issue Feb 26, 2026 that may be closed by this pull request
4 tasks
@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
snow-code-client Ready Ready Preview, Comment Feb 26, 2026 7:35am

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

새 할당, 과정 API 함수 추가 및 React Query 패턴을 *QueryOptions.ts에서 *Queries.ts/*Mutations.ts로 리팩토링했습니다. Unit Store를 도입하고 AssignmentSelectPage, UnitEditorPage를 상태 관리 및 네비게이션과 통합했습니다.

Changes

Cohort / File(s) Summary
Assignment API 및 쿼리 구성
src/entities/assignment/api/assignmentApi.ts, src/entities/assignment/api/assignmentQueries.ts, src/entities/assignment/api/assignmentQueryOptions.ts
새로운 API 함수 3개 추가(getAllAssignments, getAssignmentsByCourse, deleteAssignment); 레거시 assignmentQueryOptions.ts 제거 및 새로운 assignmentQueries.ts로 통합하여 React Query 패턴 표준화.
Assignment 타입 정의
src/entities/assignment/model/types.ts
새로운 AssignmentsResponse 인터페이스 추가 (count, assignments 필드).
Course API 및 쿼리 구성
src/entities/course/api/courseApi.ts, src/entities/course/api/courseQueries.ts, src/entities/course/api/courseMutations.ts, src/entities/course/api/courseQueryOptions.ts, src/entities/course/index.ts
새로운 API 함수 2개 추가(getAllCourses, deleteCourse); 레거시 courseQueryOptions.ts 제거 및 새로운 courseQueries.ts, courseMutations.ts 도입; index.ts에서 함수 내보내기 제거.
Unit API 및 뮤테이션
src/entities/unit/api/unitApi.ts, src/entities/unit/api/unitMutations.ts
deleteAssignmentFromUnit 함수 추가; createUnit 뮤테이션 파라미터 이름 unitunitForm으로 변경.
Unit Store
src/entities/unit/model/useUnitStore.ts
sessionStorage를 사용하는 새로운 Zustand store 추가 (title, releaseDate, dueDate, assignments 상태 관리).
할당 선택 페이지 및 컴포넌트
src/pages/select-assignment/AssignmentSelectPage.tsx, src/pages/select-assignment/ui/AssignmentListContainer.tsx
동적 데이터 페칭 추가, 위치 상태 기반 네비게이션 구현, 선택 핸들러 변경 (ID → 전체 Assignment 객체 전달).
Unit 편집 페이지 및 폼
src/pages/unit-editor/UnitEditorPage.tsx, src/pages/unit-editor/ui/UnitForm.tsx
위치 상태 기반 초기화, useUnitStore 통합, 할당 선택 네비게이션 추가, form 초기값을 store 값으로 설정.
Dashboard 페이지
src/pages/dashboard/Dashboard.tsx
레거시 쿼리 옵션 제거, 새로운 courseQueries, courseMutations, assignmentQueries 사용으로 업데이트; 쿼리 무효화 키 변경.
Layout 컴포넌트
src/shared/ui/Layout.tsx
className에서 flex-center 유틸리티를 표준 Tailwind flex justify-center로 변경.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested labels

🧩 feature, 🛠️ refactor

Suggested reviewers

  • JiiminHa

💡 추가 검토 사항

긍정적인 부분:

  • React Query 패턴을 QueryOptionsQueries/Mutations 구조로 일관되게 리팩토링하여 구조가 더 명확해졌습니다. 👌

개선 제안:

  1. Console.log 제거 권장

    • src/entities/assignment/api/assignmentApi.tsgetAssignmentsByCourse()에서 console.log 구문 제거를 고려하세요. 프로덕션 코드에는 디버깅 로그가 남아있지 않아야 합니다.
  2. Location state 타입 안정성

    • AssignmentSelectPage.tsx, UnitEditorPage.tsx, UnitForm.tsx에서 useLocation()state 객체를 사용할 때, TypeScript 타입 정의를 명시적으로 추가하는 것이 권장됩니다. 예를 들어:
      interface LocationState {
        mode?: string;
        unitId?: number;
        currentIndex?: number;
        backPath?: string;
      }
      const location = useLocation<LocationState>();

    이렇게 하면 타입 안정성이 증가하고 런타임 오류를 사전에 방지할 수 있습니다. React Router 공식 문서를 참고하세요.

  3. useUnitStore의 enabled 조건 검토

    • unitMutations.ts에서 createUnit 뮤테이션 시 store의 assignments가 비어있는 상태를 허용하는지 확인하세요. 필요하면 enabled 조건을 추가하여 할당 없이 생성되는 것을 방지할 수 있습니다.
  4. 쿼리 키 일관성

    • assignmentQueries.getAssignmentsByCourse()의 queryKey가 ['courses', courseId, 'assignments']인데, 다른 assignment 쿼리 키와의 네이밍 일관성을 재검토해보세요 (['assignments', courseId] 구조도 고려).
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed PR 제목이 주요 변경 사항을 정확하게 요약합니다. 문제 선택 페이지 구현과 과제 API 연동이 실제 변경 내용과 일치합니다.
Description check ✅ Passed PR 설명은 변경사항과 명확하게 관련되어 있으며, API 연동, 과제 선택 페이지 개선, 단원 폼 상태 유지 등 실제 코드 변경사항을 구체적으로 설명하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/52-select-manage-assignment-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pages/select-assignment/ui/AssignmentListContainer.tsx (1)

4-10: ⚠️ Potential issue | 🟠 Major

제네릭 타입과 onSelect 콜백의 타입 불일치 해결 필요

TAssignmentSelectCourse['assignments'][number](즉, Pick<Assignment, 'id' | 'title'>)으로 정의되지만, onSelect 콜백과 handleSelect는 완전한 Assignment 타입을 기대합니다. 구조적 호환성으로 인해 TypeScript는 컴파일하지만, 의도하지 않은 타입 불일치입니다.

제네릭을 일관되게 사용하여 타입 안전성을 강화하세요.

♻️ 제네릭 제약 추가 제안
-type T = AssignmentSelectCourse['assignments'][number];
-
 interface AssignmentListContainerProps<T> {
   items: T[];
   renderItem: (item: T) => React.ReactNode;
   title: string;
-  onSelect: (item: Assignment) => void;
+  onSelect: (item: T) => void;
 }
 
 const AssignmentListContainer = ({
   onSelect,
   items,
   renderItem,
   title,
-}: AssignmentListContainerProps<T>) => {
-  const handleSelect = (item: Assignment, event: React.MouseEvent) => {
+}: AssignmentListContainerProps<T extends Assignment>) => {
+  const handleSelect = (item: T, event: React.MouseEvent) => {
     event.stopPropagation();
     onSelect(item);
   };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/select-assignment/ui/AssignmentListContainer.tsx` around lines 4 -
10, The props type is inconsistent: T is defined as
AssignmentSelectCourse['assignments'][number] (a partial Pick) while onSelect
and handleSelect expect a full Assignment; change AssignmentListContainerProps
to use a generic T for the item type consistently and update the
callback/signature to match that generic (for example declare interface
AssignmentListContainerProps<T> { items: T[]; renderItem: (item: T) =>
React.ReactNode; title: string; onSelect: (item: T) => void } and ensure the
component’s handleSelect(item: T) and any usages pass the same T), or
alternatively constrain T with T extends Assignment if you need full Assignment
fields—apply the same T to renderItem, onSelect, and handleSelect to ensure type
safety.
🧹 Nitpick comments (3)
src/pages/select-assignment/ui/AssignmentListContainer.tsx (1)

19-21: handleSelect의 item 타입도 제네릭으로 통일 권장

현재 handleSelectitem: Assignment로 고정되어 있어 제네릭 T와 일치하지 않습니다. 위의 제네릭 제약 수정과 함께 이 부분도 T로 변경하면 타입 일관성이 향상됩니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/select-assignment/ui/AssignmentListContainer.tsx` around lines 19 -
21, handleSelect 함수의 인자 item이 구체적 타입 Assignment로 고정되어 있어 컴포넌트의 제네릭 T와 불일치하므로
handleSelect 시그니처를 Assignment 대신 제네릭 T로 변경하고 내부 호출(onSelect)에 전달되는 타입도 일치시키세요;
관련 식별자는 handleSelect, onSelect, 그리고 기존 Assignment 타입 제약이며 제네릭 T가 선언된 상위 컴포넌트 타입과
함께 업데이트하면 타입 일관성이 유지됩니다.
src/entities/unit/api/unitMutations.ts (1)

8-22: 파라미터 네이밍 일관성 부족

createUnitunitForm을 사용하고, updateUnitunit을 사용합니다. 동일한 TUnitFormSchema 타입을 받으므로 네이밍을 통일하는 것이 좋습니다.

♻️ 네이밍 통일 제안
   // 단원 수정 뮤테이션 옵션
   updateUnit: {
     mutationKey: ['updateUnit'],
-    mutationFn: ({unitId, unit}: {unitId: number; unit: TUnitFormSchema}) =>
-      updateUnit(unitId, unit),
+    mutationFn: ({unitId, unitForm}: {unitId: number; unitForm: TUnitFormSchema}) =>
+      updateUnit(unitId, unitForm),
   },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/entities/unit/api/unitMutations.ts` around lines 8 - 22, The parameter
naming is inconsistent between the createUnit and updateUnit mutationFns;
updateUnit destructures and types the unit payload as "unit" while createUnit
uses "unitForm". Update the updateUnit mutationFn to destructure ({unitId,
unitForm}: {unitId: number; unitForm: TUnitFormSchema}) and call
updateUnit(unitId, unitForm) so both mutations use the same "unitForm" name
(referencing createUnit, updateUnit, and the mutationFn definitions).
src/entities/unit/model/useUnitStore.ts (1)

31-32: 주석 의미가 현재 저장 구조와 다릅니다.

Line 31 주석은 “ID 저장”인데, 실제 구현은 Assignment[] 전체를 저장합니다. 유지보수 시 오해를 줄이도록 주석을 맞춰주세요.

✏️ 제안 수정안
-      // 선택된 과제 ID 저장
+      // 선택된 과제 객체 목록 저장
       setAssignments: (assignments) => set({assignments}),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/entities/unit/model/useUnitStore.ts` around lines 31 - 32, 주석과 구현이
불일치합니다: useUnitStore.ts의 setAssignments 함수는 "선택된 과제 ID 저장"이라고 주석돼 있지만 실제로는
Assignment[] 전체를 상태에 저장합니다; setAssignments 주석을 해당 동작을 정확히 반영하도록 수정하고(예: "선택된 과제
배열 저장" 또는 "선택된 Assignment들 저장"), 필요하면 파라미터 타입 설명(Assignment[])도 함께 업데이트하여 오해를
방지하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/entities/assignment/api/assignmentApi.ts`:
- Around line 45-46: Remove the development console.log in the
getAssignmentsByCourse API function (the line logging response.data) to avoid
leaking data and noisy logs in production; either delete that console.log
entirely or guard it behind a debug flag/config check (e.g., use a
process.env.DEBUG or isLocalDebug boolean) so logging only occurs in local/dev
runs, and keep the function return value (response.data) unchanged.

In `@src/pages/select-assignment/AssignmentSelectPage.tsx`:
- Around line 52-58: The navigate call currently passes state even when using
delta navigation (navigate(-1)), but React Router v7 ignores state for delta
moves; update the logic around the navigate(location.state?.backPath ?? -1, {
state: ... }) call in AssignmentSelectPage so that if location.state?.backPath
exists you call navigate(backPath, { state: { mode: location.state?.mode,
unitId: location.state?.unitId, currentIndex: location.state?.currentIndex } }),
otherwise call navigate(-1) (no state) to perform a history delta move; adjust
the branch around navigate to separate path navigation from delta navigation and
use the same state object only for path-based navigation.

In `@src/pages/unit-editor/ui/UnitForm.tsx`:
- Around line 155-159: The current conditional in UnitForm.tsx renders the
global `assignments` when `mode === 'editing'` and `unit.assignmentCount === 0`,
leaking temporary assignments into the edit UI; update the render logic so that
when `mode === 'editing'` you always use `unit.assignments` (even if empty) or
otherwise do not fall through to the global `assignments`. Concretely, change
the branching around `mode`, `unit`, `unit.assignmentCount`, and `assignments`
so `UnitAssignmentList assignmentList={unit.assignments}` is chosen whenever
`mode === 'editing' && unit` (or add an explicit `mode !== 'editing'` guard
before showing `assignments`) to prevent global `assignments` from being shown
in edit mode.

In `@src/pages/unit-editor/UnitEditorPage.tsx`:
- Around line 81-85: After deleting a unit you switch UI to creating mode but
forget to clear the editor store, causing residual form values to persist;
update the onSuccess handler to call resetStore() (the same store reset used
after create) before or immediately after setMode('creating'), keeping
invalidateUnitList(), setSelectedUnitId(null), setMode('creating'), and then
resetStore() so the create form is cleared and state stays consistent.

---

Outside diff comments:
In `@src/pages/select-assignment/ui/AssignmentListContainer.tsx`:
- Around line 4-10: The props type is inconsistent: T is defined as
AssignmentSelectCourse['assignments'][number] (a partial Pick) while onSelect
and handleSelect expect a full Assignment; change AssignmentListContainerProps
to use a generic T for the item type consistently and update the
callback/signature to match that generic (for example declare interface
AssignmentListContainerProps<T> { items: T[]; renderItem: (item: T) =>
React.ReactNode; title: string; onSelect: (item: T) => void } and ensure the
component’s handleSelect(item: T) and any usages pass the same T), or
alternatively constrain T with T extends Assignment if you need full Assignment
fields—apply the same T to renderItem, onSelect, and handleSelect to ensure type
safety.

---

Nitpick comments:
In `@src/entities/unit/api/unitMutations.ts`:
- Around line 8-22: The parameter naming is inconsistent between the createUnit
and updateUnit mutationFns; updateUnit destructures and types the unit payload
as "unit" while createUnit uses "unitForm". Update the updateUnit mutationFn to
destructure ({unitId, unitForm}: {unitId: number; unitForm: TUnitFormSchema})
and call updateUnit(unitId, unitForm) so both mutations use the same "unitForm"
name (referencing createUnit, updateUnit, and the mutationFn definitions).

In `@src/entities/unit/model/useUnitStore.ts`:
- Around line 31-32: 주석과 구현이 불일치합니다: useUnitStore.ts의 setAssignments 함수는 "선택된 과제
ID 저장"이라고 주석돼 있지만 실제로는 Assignment[] 전체를 상태에 저장합니다; setAssignments 주석을 해당 동작을 정확히
반영하도록 수정하고(예: "선택된 과제 배열 저장" 또는 "선택된 Assignment들 저장"), 필요하면 파라미터 타입
설명(Assignment[])도 함께 업데이트하여 오해를 방지하세요.

In `@src/pages/select-assignment/ui/AssignmentListContainer.tsx`:
- Around line 19-21: handleSelect 함수의 인자 item이 구체적 타입 Assignment로 고정되어 있어 컴포넌트의
제네릭 T와 불일치하므로 handleSelect 시그니처를 Assignment 대신 제네릭 T로 변경하고 내부 호출(onSelect)에 전달되는
타입도 일치시키세요; 관련 식별자는 handleSelect, onSelect, 그리고 기존 Assignment 타입 제약이며 제네릭 T가 선언된
상위 컴포넌트 타입과 함께 업데이트하면 타입 일관성이 유지됩니다.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7661bd and d4428d1.

📒 Files selected for processing (18)
  • src/entities/assignment/api/assignmentApi.ts
  • src/entities/assignment/api/assignmentQueries.ts
  • src/entities/assignment/api/assignmentQueryOptions.ts
  • src/entities/assignment/model/types.ts
  • src/entities/course/api/courseApi.ts
  • src/entities/course/api/courseMutations.ts
  • src/entities/course/api/courseQueries.ts
  • src/entities/course/api/courseQueryOptions.ts
  • src/entities/course/index.ts
  • src/entities/unit/api/unitApi.ts
  • src/entities/unit/api/unitMutations.ts
  • src/entities/unit/model/useUnitStore.ts
  • src/pages/dashboard/Dashboard.tsx
  • src/pages/select-assignment/AssignmentSelectPage.tsx
  • src/pages/select-assignment/ui/AssignmentListContainer.tsx
  • src/pages/unit-editor/UnitEditorPage.tsx
  • src/pages/unit-editor/ui/UnitForm.tsx
  • src/shared/ui/Layout.tsx
💤 Files with no reviewable changes (3)
  • src/entities/course/api/courseQueryOptions.ts
  • src/entities/course/index.ts
  • src/entities/assignment/api/assignmentQueryOptions.ts

Comment on lines +45 to +46
console.log('getAssignmentsByCourse API 응답:', response.data); // 응답 데이터 로깅
return response.data;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

API 응답 디버그 로그는 릴리스 전에 제거해 주세요.

Line 45의 console.log는 운영 환경에서 불필요한 데이터 노출과 콘솔 노이즈를 만듭니다. 필요하면 로컬 디버깅 플래그 기반으로 제한해 주세요.

🧼 제안 수정안
-  console.log('getAssignmentsByCourse API 응답:', response.data); // 응답 데이터 로깅
   return response.data;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('getAssignmentsByCourse API 응답:', response.data); // 응답 데이터 로깅
return response.data;
return response.data;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/entities/assignment/api/assignmentApi.ts` around lines 45 - 46, Remove
the development console.log in the getAssignmentsByCourse API function (the line
logging response.data) to avoid leaking data and noisy logs in production;
either delete that console.log entirely or guard it behind a debug flag/config
check (e.g., use a process.env.DEBUG or isLocalDebug boolean) so logging only
occurs in local/dev runs, and keep the function return value (response.data)
unchanged.

Comment on lines +52 to +58
navigate(location.state?.backPath ?? -1, {
state: {
mode: location.state?.mode,
unitId: location.state?.unitId,
currentIndex: location.state?.currentIndex,
},
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cd /tmp && git ls-files | grep -i "AssignmentSelectPage" | head -5

Repository: 2025-snowCode/snowCode-Client

Length of output: 141


🌐 Web query:

React Router v7 useNavigate delta navigation state parameter behavior

💡 Result:

In React Router v7, useNavigate() has two distinct call forms: navigate(to, options?) and navigate(delta) (history stack movement). When you use the delta form (e.g. navigate(-1)), you are effectively calling the underlying history “go” operation, which does not create a new location entry—so there’s nowhere to attach a new state payload. As a result, any “state parameter” you might expect to pass is not applied; you simply land on the existing entry and get whatever location.state was stored on that entry. [1], [2]

If you need to send new state, use path navigation instead: navigate("/path", { state }) (or the v7-supported navigate({ pathname, state })). [1]

Sources:
[1] React Router v7 useNavigate API reference (api.reactrouter.com)
[2] React Router Navigator interface (go(delta) vs push/replace(..., state)) (api.reactrouter.com)

Citations:


🏁 Script executed:

fd "AssignmentSelectPage.tsx" --type f

Repository: 2025-snowCode/snowCode-Client

Length of output: 125


🏁 Script executed:

cat -n src/pages/select-assignment/AssignmentSelectPage.tsx 2>/dev/null || find . -name "AssignmentSelectPage.tsx" -type f -exec cat -n {} \;

Repository: 2025-snowCode/snowCode-Client

Length of output: 3720


Delta 이동 시 state 파라미터가 적용되지 않습니다.

52줄의 navigate(location.state?.backPath ?? -1, { state }) 호출은 backPath가 없으면 navigate(-1, { state })가 되는데, React Router v7에서 delta 이동(navigate(-1))은 브라우저의 history.go() 동작을 수행하므로 state 파라미터가 무시됩니다. 따라서 이전 페이지로 돌아갈 때 모드, unitId, currentIndex 정보가 손실됩니다.

해결 방법: path와 delta를 분리하여 처리하세요. backPath가 있으면 path 이동으로 state를 함께 전달하고, 없으면 delta 이동만 수행하세요.

🔧 수정 제안
  const returnToPreviousPage = () => {
+   const backPath = location.state?.backPath;
+   const nextState = {
+     mode: location.state?.mode,
+     unitId: location.state?.unitId,
+     currentIndex: location.state?.currentIndex,
+   };
+
+   if (backPath) {
+     navigate(backPath, { state: nextState });
+     return;
+   }
+   navigate(-1);
-   navigate(location.state?.backPath ?? -1, {
-     state: {
-       mode: location.state?.mode,
-       unitId: location.state?.unitId,
-       currentIndex: location.state?.currentIndex,
-     },
-   });
  };

참고: React Router v7 useNavigate API 문서

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/select-assignment/AssignmentSelectPage.tsx` around lines 52 - 58,
The navigate call currently passes state even when using delta navigation
(navigate(-1)), but React Router v7 ignores state for delta moves; update the
logic around the navigate(location.state?.backPath ?? -1, { state: ... }) call
in AssignmentSelectPage so that if location.state?.backPath exists you call
navigate(backPath, { state: { mode: location.state?.mode, unitId:
location.state?.unitId, currentIndex: location.state?.currentIndex } }),
otherwise call navigate(-1) (no state) to perform a history delta move; adjust
the branch around navigate to separate path navigation from delta navigation and
use the same state object only for path-based navigation.

Comment on lines +155 to +159
{mode === 'editing' && unit && unit.assignmentCount > 0 ? (
<UnitAssignmentList assignmentList={unit.assignments} />
) : assignments.length > 0 ? (
<UnitAssignmentList assignmentList={assignments} />
) : (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

편집 모드에서 다른 단원의 임시 과제가 노출될 수 있습니다.

Line 157-159 분기 때문에 editing인데 unit.assignmentCount === 0이면 전역 store의 assignments가 표시됩니다. 이전 생성 플로우 임시값이 섞여 보여 UX와 데이터 신뢰성을 깨뜨립니다.

✅ 제안 수정안
-            {mode === 'editing' && unit && unit.assignmentCount > 0 ? (
-              <UnitAssignmentList assignmentList={unit.assignments} />
-            ) : assignments.length > 0 ? (
-              <UnitAssignmentList assignmentList={assignments} />
-            ) : (
-              <EmptyState className='mt-4 mb-5'>
-                등록된 문제가 없습니다.
-              </EmptyState>
-            )}
+            {mode === 'editing' && unit ? (
+              unit.assignmentCount > 0 ? (
+                <UnitAssignmentList assignmentList={unit.assignments} />
+              ) : (
+                <EmptyState className='mt-4 mb-5'>
+                  등록된 문제가 없습니다.
+                </EmptyState>
+              )
+            ) : assignments.length > 0 ? (
+              <UnitAssignmentList assignmentList={assignments} />
+            ) : (
+              <EmptyState className='mt-4 mb-5'>
+                등록된 문제가 없습니다.
+              </EmptyState>
+            )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/unit-editor/ui/UnitForm.tsx` around lines 155 - 159, The current
conditional in UnitForm.tsx renders the global `assignments` when `mode ===
'editing'` and `unit.assignmentCount === 0`, leaking temporary assignments into
the edit UI; update the render logic so that when `mode === 'editing'` you
always use `unit.assignments` (even if empty) or otherwise do not fall through
to the global `assignments`. Concretely, change the branching around `mode`,
`unit`, `unit.assignmentCount`, and `assignments` so `UnitAssignmentList
assignmentList={unit.assignments}` is chosen whenever `mode === 'editing' &&
unit` (or add an explicit `mode !== 'editing'` guard before showing
`assignments`) to prevent global `assignments` from being shown in edit mode.

Comment on lines 81 to 85
onSuccess: () => {
invalidateUnitList();
setMode('idle'); // 삭제 후 대기 모드로 전환
setSelectedUnitId(null); // 선택된 단원 초기화
setMode('creating');
alert('단원이 성공적으로 삭제되었습니다.');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

삭제 후 생성 모드 전환 시 store 초기화도 같이 필요합니다.

Line 84에서 생성 모드로 바꾸지만 resetStore()가 없어 이전 임시 입력값이 새 단원 폼에 남을 수 있습니다. create 성공 시와 동일하게 초기화해 상태 일관성을 맞춰주세요.

🧹 제안 수정안
     onSuccess: () => {
       invalidateUnitList();
       setSelectedUnitId(null); // 선택된 단원 초기화
+      resetStore(); // 임시 단원 폼 상태 초기화
       setMode('creating');
       alert('단원이 성공적으로 삭제되었습니다.');
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onSuccess: () => {
invalidateUnitList();
setMode('idle'); // 삭제 후 대기 모드로 전환
setSelectedUnitId(null); // 선택된 단원 초기화
setMode('creating');
alert('단원이 성공적으로 삭제되었습니다.');
onSuccess: () => {
invalidateUnitList();
setSelectedUnitId(null); // 선택된 단원 초기화
resetStore(); // 임시 단원 폼 상태 초기화
setMode('creating');
alert('단원이 성공적으로 삭제되었습니다.');
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/unit-editor/UnitEditorPage.tsx` around lines 81 - 85, After
deleting a unit you switch UI to creating mode but forget to clear the editor
store, causing residual form values to persist; update the onSuccess handler to
call resetStore() (the same store reset used after create) before or immediately
after setMode('creating'), keeping invalidateUnitList(),
setSelectedUnitId(null), setMode('creating'), and then resetStore() so the
create form is cleared and state stays consistent.

@suminb99 suminb99 changed the title Feat/52 select manage assignment api #52 feat: 문제 선택 페이지 구현 및 과제 API 연동 Feb 26, 2026
@suminb99 suminb99 self-assigned this Feb 26, 2026
@suminb99 suminb99 added 🧩 feature 기능 개발 🛠️ refactor 코드 리팩토링 labels Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧩 feature 기능 개발 🛠️ refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 과제 API 연동

1 participant