[feat] 근무자 퇴사 API 연동#48
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthrough두 개의 resignation 기능(관리자의 근무자 퇴사 처리, 사용자의 작업공간 퇴사)을 추가합니다. 공용 UI 컴포넌트(ActionMenu, ConfirmModal)를 먼저 구현하고, 각 기능별로 API, 훅, 페이지 통합을 순차적으로 추가합니다. ChangesWorker and Workspace Resignation Flows
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
@coderabbitai 코드리뷰해줘 |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Fetch PR diff and file list
gh pr view 48 --repo alter-app/alter-client --json files,additions,deletions,changedFiles
echo "---FILES---"
gh pr diff 48 --repo alter-app/alter-clientLength of output: 46282
🔴 버그 / 회귀1.
|
|
래빗이랑 코멘트 확인해주시고 반영사항은 수정 부탁드리겠습니다! |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/features/user/home/workspace/hooks/mutation/useResignWorkspaceMutation.ts (1)
11-19: ⚡ Quick win기본 에러 처리 추가를 권장합니다.
현재 mutation에
onError핸들러가 없어, 호출하는 쪽에서 매번 에러 처리를 구현해야 합니다. workspace-detail 페이지는 per-call onError로 처리하고 있지만, 다른 곳에서 이 훅을 사용할 때 에러 처리를 빠뜨리면 사용자에게 아무 피드백 없이 실패하게 됩니다.mutation 옵션에 기본
onError핸들러를 추가해 최소한의 에러 피드백(토스트 등)을 보장하는 것을 권장합니다.제안: 기본 에러 처리 추가
return useMutation({ mutationFn: (workspaceId: number) => resignWorkspace(workspaceId), onSuccess: () => { queryClient.invalidateQueries({ queryKey: queryKeys.workspace.list(), }) navigate(ROUTES.USER.JOB_LOOKUP_MAP) }, + onError: (error) => { + console.error('퇴사 처리 실패:', error) + // toast.error('퇴사 처리에 실패했습니다.') + }, })참고: 페이지에서 제공한 per-call onError는 이 기본 핸들러 이후에도 실행됩니다.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/features/user/home/workspace/hooks/mutation/useResignWorkspaceMutation.ts` around lines 11 - 19, Add a default onError handler to the useResignWorkspaceMutation hook so failures from resignWorkspace produce minimal user feedback and logging; inside the useMutation call for useResignWorkspaceMutation, add an onError: (error) => { show a toast/error notification and log the error } while keeping the existing onSuccess logic (queryClient.invalidateQueries and navigate(ROUTES.USER.JOB_LOOKUP_MAP)) so callers still can supply per-call onError if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pages/manager/home/index.tsx`:
- Around line 56-57: The resign mutation is being initialized with a fallback
workspaceId (activeWorkspaceId ?? 0) which leads to calls to /workspaces/0/...
when activeWorkspaceId is null; remove the ?? 0 fallback and instead disable the
resign menu when activeWorkspaceId is null (recommended): update the UI logic
that renders the resign menu/button to be disabled/hidden when activeWorkspaceId
is null, and change the useResignWorkerMutation call to only be invoked with a
real id (useResignWorkerMutation(activeWorkspaceId) without ?? 0) so
resignWorker/isResigning are not wired up for a missing workspace; also audit
the onConfirm handler (onConfirm) to ensure it does nothing if activeWorkspaceId
is null as an extra guard.
In `@src/pages/user/workspace-detail/index.tsx`:
- Line 29: The code converts workspaceId with const id = Number(workspaceId) but
doesn't validate it, allowing NaN to reach the resign API; fix by validating
workspaceId before use: ensure Number(workspaceId) is a finite integer (e.g.,
Number.isFinite(id) && id > 0) and either disable the resign button when invalid
or return early in the resign handler (the function that triggers the resign
mutation/API call) to avoid calling /workspaces/NaN/resign; update the UI state
(button disabled) and add a guard in the mutation-invoking code path that
references workspaceId/id to prevent invalid requests.
In `@src/shared/ui/common/ActionMenu.tsx`:
- Around line 51-54: The list key for items.map in ActionMenu.tsx currently uses
key={item.label}, which can cause React reuse bugs when labels duplicate; change
the key to a stable unique identifier from the item (e.g., item.id or item.key)
or ensure each item is assigned a persistent unique id before rendering (only
use array index as a last resort when items are guaranteed never to reorder),
updating the mapping where items.map is rendered (the button/key usage).
---
Nitpick comments:
In
`@src/features/user/home/workspace/hooks/mutation/useResignWorkspaceMutation.ts`:
- Around line 11-19: Add a default onError handler to the
useResignWorkspaceMutation hook so failures from resignWorkspace produce minimal
user feedback and logging; inside the useMutation call for
useResignWorkspaceMutation, add an onError: (error) => { show a toast/error
notification and log the error } while keeping the existing onSuccess logic
(queryClient.invalidateQueries and navigate(ROUTES.USER.JOB_LOOKUP_MAP)) so
callers still can supply per-call onError if needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 48dd596e-265a-43da-82ae-7693a03dc616
⛔ Files ignored due to path filters (1)
src/assets/icons/home/resign.svgis excluded by!**/*.svg
📒 Files selected for processing (13)
src/features/manager/api/worker.tssrc/features/manager/home/hooks/useManagerHomeViewModel.tssrc/features/manager/home/ui/StoreWorkerListItem.tsxsrc/features/manager/worker-list/hooks/mutation/useResignWorkerMutation.tssrc/features/manager/worker-list/types/resign.tssrc/features/user/home/workspace/api/workspace.tssrc/features/user/home/workspace/hooks/mutation/useResignWorkspaceMutation.tssrc/features/user/home/workspace/types/resign.tssrc/pages/manager/home/index.tsxsrc/pages/user/workspace-detail/index.tsxsrc/shared/ui/common/ActionMenu.tsxsrc/shared/ui/common/ConfirmModal.tsxstorybook/stories/ActionMenu.stories.tsx
| @@ -26,6 +29,10 @@ export function WorkspaceDetailPage() { | |||
| const id = Number(workspaceId) | |||
There was a problem hiding this comment.
workspaceId 파라미터 유효성 검증이 필요합니다.
Number(workspaceId)가 NaN이 될 수 있으며, 이 경우 Line 231에서 API 호출 시 /app/users/me/workspaces/NaN/resign과 같은 잘못된 URL을 생성합니다.
퇴사 버튼을 비활성화하거나 최소한 mutation 호출 전에 유효한 숫자인지 검증해야 합니다.
제안: 유효성 검증 추가
방법 1: 버튼 비활성화
+const isValidWorkspaceId = Number.isFinite(id) && id > 0
+
<button
type="button"
className="w-full mt-12 mb-6 py-[14px] rounded-xl bg-error/10 typography-body01-semibold text-error"
onClick={() => setIsResignModalOpen(true)}
+ disabled={!isValidWorkspaceId}
>
퇴사하기
</button>방법 2: mutation 호출 전 검증
onConfirm={() => {
+ if (!Number.isFinite(id) || id <= 0) return
resignWorkspace(id, {
onError: () => {
setIsResignModalOpen(false)
setIsResignErrorOpen(true)
},
})
}}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/pages/user/workspace-detail/index.tsx` at line 29, The code converts
workspaceId with const id = Number(workspaceId) but doesn't validate it,
allowing NaN to reach the resign API; fix by validating workspaceId before use:
ensure Number(workspaceId) is a finite integer (e.g., Number.isFinite(id) && id
> 0) and either disable the resign button when invalid or return early in the
resign handler (the function that triggers the resign mutation/API call) to
avoid calling /workspaces/NaN/resign; update the UI state (button disabled) and
add a guard in the mutation-invoking code path that references workspaceId/id to
prevent invalid requests.
| {items.map((item, index) => ( | ||
| <button | ||
| key={item.label} | ||
| type="button" |
There was a problem hiding this comment.
리스트 key를 label 대신 안정적인 고유값으로 바꿔주세요.
Line 53의 key={item.label}은 라벨 중복 시 React가 항목을 잘못 재사용해 메뉴 항목 렌더/이벤트 매핑이 어긋날 수 있습니다.
수정 예시
export interface ActionMenuItem {
+ id: string
icon: React.ReactNode
label: string
iconColor?: string
onClick: () => void
}
@@
- {items.map((item, index) => (
+ {items.map((item, index) => (
<button
- key={item.label}
+ key={item.id}
type="button"As per coding guidelines, **/*.tsx에서는 실질 이슈인 “리스트 key 오용”을 우선 지적해야 합니다.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/shared/ui/common/ActionMenu.tsx` around lines 51 - 54, The list key for
items.map in ActionMenu.tsx currently uses key={item.label}, which can cause
React reuse bugs when labels duplicate; change the key to a stable unique
identifier from the item (e.g., item.id or item.key) or ensure each item is
assigned a persistent unique id before rendering (only use array index as a last
resort when items are guaranteed never to reorder), updating the mapping where
items.map is rendered (the button/key usage).
Source: Coding guidelines
ID
변경 내용
구현 사항
공통
매니저 — 근무자 퇴사처리
알바생 — 퇴사하기
구현 시연 (필요 시)
사장님
2026-06-06.9.23.07.mov
알바생
2026-06-06.9.44.37.mov
Summary by CodeRabbit
New Features
Refactor
Documentation