Feat(Client): 카테고리 수정 팝업 checkbox 추가 및 api 연결#279
Feat(Client): 카테고리 수정 팝업 checkbox 추가 및 api 연결#279jjangminii wants to merge 6 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Walkthrough카테고리 공유 기능을 추가하기 위해 API를 v1에서 v3로 업그레이드하고, PUT을 PATCH로 변경하며, isPublic 파라미터를 추가했습니다. PopupPortal과 Popup 컴포넌트를 확장하여 체크박스 옵션을 지원하고, 관련 훅과 상태 관리를 업데이트했습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant User as 사용자
participant UI as PopupPortal
participant Popup as Popup Component
participant Hook as useCategoryActions
participant API as API (axios)
User->>UI: 카테고리 생성/수정 시작
UI->>Popup: checkboxOption props 전달 (체크박스 활성화)
Popup->>Popup: 체크박스 렌더링 (shareToJobUsers)
User->>Popup: 카테고리명 입력 + 체크박스 선택
Popup->>UI: onCreateConfirm(shareToJobUsers) 또는<br/>onEditConfirm(id, name, isPublic)
UI->>Hook: handleCreateCategory(isPublic) 또는<br/>handlePatchCategory(id, name, isPublic)
Hook->>API: postCategory(name, isPublic) 또는<br/>patchCategory(id, name, isPublic)
API-->>Hook: 응답
Hook->>Hook: 캐시 무효화, UI 상태 업데이트
Hook-->>UI: 완료 콜백
UI-->>User: 팝업 닫기, UI 갱신
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
|
✅ Storybook chromatic 배포 확인: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/client/src/shared/components/sidebar/PopupPortal.tsx`:
- Around line 44-50: The effect in PopupPortal (useEffect watching popup)
unconditionally calls setShareToJobUsers(false), which resets the checkbox for
edit flows and overwrites existing visibility; change the logic in the effect to
initialize shareToJobUsers based on popup when popup.kind === 'edit' (e.g., read
the existing visibility flag from popup or popup.shareToJobUsers) and only
default to false for create flows, updating the setShareToJobUsers call in the
useEffect that references popup so edit restores the current value and create
sets false; ensure any other places that set shareToJobUsers on open (calls
around lines where shareToJobUsers/setShareToJobUsers are used, and the confirm
handler that passes the value at line ~95) are consistent with this
initialization.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/client/src/shared/apis/axios.tsapps/client/src/shared/apis/queries.tsapps/client/src/shared/components/sidebar/PopupPortal.tsxapps/client/src/shared/components/sidebar/Sidebar.tsxapps/client/src/shared/components/sidebar/hooks/useCategoryActions.tspackages/design-system/src/components/checkbox/Checkbox.tsxpackages/design-system/src/components/popup/Popup.tsx
| const [shareToJobUsers, setShareToJobUsers] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (!popup) return; | ||
| setDraft(popup.kind === 'edit' ? (popup.name ?? '') : ''); | ||
| setShareToJobUsers(false); | ||
| }, [popup]); |
There was a problem hiding this comment.
수정 팝업 체크박스 초기값이 항상 false로 덮여서 기존 공개 설정이 깨집니다.
Line 49에서 edit/create 구분 없이 setShareToJobUsers(false)를 호출해, 수정 팝업이 현재 값을 반영하지 못합니다. 그 상태로 확인하면 Line 95 경로로 false가 전달되어 공개 카테고리가 비공개로 바뀔 수 있습니다.
수정 제안 diff
interface Props {
@@
- categoryList?: { id: number; name: string }[];
+ categoryList?: { id: number; name: string; isPublic?: boolean }[];
@@
useEffect(() => {
if (!popup) return;
setDraft(popup.kind === 'edit' ? (popup.name ?? '') : '');
- setShareToJobUsers(false);
- }, [popup]);
+ if (popup.kind === 'edit') {
+ const current = categoryList?.find((c) => c.id === popup.id);
+ setShareToJobUsers(current?.isPublic ?? false);
+ } else {
+ setShareToJobUsers(false);
+ }
+ }, [popup, categoryList]);Also applies to: 95-95, 150-156
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/client/src/shared/components/sidebar/PopupPortal.tsx` around lines 44 -
50, The effect in PopupPortal (useEffect watching popup) unconditionally calls
setShareToJobUsers(false), which resets the checkbox for edit flows and
overwrites existing visibility; change the logic in the effect to initialize
shareToJobUsers based on popup when popup.kind === 'edit' (e.g., read the
existing visibility flag from popup or popup.shareToJobUsers) and only default
to false for create flows, updating the setShareToJobUsers call in the useEffect
that references popup so edit restores the current value and create sets false;
ensure any other places that set shareToJobUsers on open (calls around lines
where shareToJobUsers/setShareToJobUsers are used, and the confirm handler that
passes the value at line ~95) are consistent with this initialization.
📌 Related Issues
📄 Tasks
⭐ PR Point (To Reviewer)
📷 Screenshot
Summary by CodeRabbit
릴리스 노트