[feat] 고정 스케줄 관리 페이지 API 연동#34
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthrough고정 작업자 일정 CRUD API·타입을 추가하고 React Query 쿼리/뮤테이션 훅, 워커 DTO 확장, 뷰모델 반환 구조(workTime) 리팩토링 및 페이지·컴포넌트 분리, 그리고 홈 훅들의 API 임포트 경로를 상위로 중앙화했습니다. Changes고정 작업자 일정 기능 통합
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
src/features/manager/worker-schedule/api/fixedWorkerSchdule.ts (1)
2-8: ⚡ Quick win내부 구현에서 feature 배럴(
@/features/manager) 의존을 제거해주세요.Line 2-8은 feature 내부 모듈이 상위 feature 배럴에 의존하고 있어 계층 경계를 깨고 결합도를 높입니다. 이 파일은 로컬 타입 모듈(
worker-schedule/types/...)을 직접 import하도록 바꾸는 게 안전합니다.As per coding guidelines
src/features/**: "entities, shared 레이어만 import하는지".🤖 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/manager/worker-schedule/api/fixedWorkerSchdule.ts` around lines 2 - 8, The import block at the top pulls several types from the feature barrel '`@/features/manager`' (ResponseGetFixedWorkerSchdules, RequestPostFixedWorkerSchdules, ResponsePostFixedWorkerSchdules, ResponseDeleteFixedWorkerSchdules, RequestPatchFixedWorkerSchdules); replace that barrel import by importing each type directly from the local worker-schedule type modules (e.g. the module(s) under worker-schedule/types or equivalent local path within this feature) so the file no longer depends on the upper-level feature barrel and instead references the concrete type files used by fixedWorkerSchdule.ts.src/features/manager/worker-schedule/hooks/query/useWorkspaceWorkers.ts (1)
2-4: ⚡ Quick winworker-schedule 훅이 다른 feature(
home) 타입에 직접 의존하고 있습니다.Line 2-4는
worker-schedule이home타입까지 참조해 feature 경계가 섞입니다. 공통 DTO를entities/shared(또는 worker-schedule 로컬 타입)로 이동하고, 해당 경로만 참조하도록 정리하는 걸 권장합니다.As per coding guidelines
src/features/**: "entities, shared 레이어만 import하는지".🤖 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/manager/worker-schedule/hooks/query/useWorkspaceWorkers.ts` around lines 2 - 4, The useWorkspaceWorkers hook imports the WorkersApiResponse type from the home feature which violates feature boundaries; update imports so worker-schedule no longer depends on home by moving the shared DTO (WorkersApiResponse) into a common layer (entities or shared) or by creating a local equivalent type in the worker-schedule feature, then change the import used in useWorkspaceWorkers (alongside existing imports like fetchWorkspaceWorkers and queryKeys) to reference the new shared/entities location (or local type) and remove the direct import from the home feature.
🤖 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/features/manager/worker-schedule/hooks/useWorkerScheduleManageViewModel.ts`:
- Line 4: The hook useWorkerScheduleManageViewModel imports StoreWorkerRole
directly from the home feature causing a feature-layer coupling; instead move or
re-export the type to a shared/public API and update the import: either (a)
relocate StoreWorkerRole into a common place (entities or shared) and import
from there, or (b) re-export StoreWorkerRole from the home feature's index.ts
(Public API) and change the import in useWorkerScheduleManageViewModel to
reference that public API; update any import paths to the new module and run
type checks to ensure no other direct cross-feature imports remain.
- Around line 47-58: The effect reading selectedWorkerColorCode currently only
sets selectedColor when a mapping is found, leaving previous color when
selectedWorker has no colorCode or map fails; update the useEffect for
selectedWorkerColorCode so it explicitly clears selectedColor (e.g. call
setSelectedColor(undefined or null)) when selectedWorkerColorCode is falsy or
when Object.entries(ScheduleColor).find(...) returns no match, ensuring
selectedColor does not persist across workers; modify the useEffect that
references selectedWorkerColorCode, ScheduleColor, and setSelectedColor
accordingly.
In `@src/pages/manager/worker-schedule/index.tsx`:
- Line 3: The page imports the hook useWorkerScheduleManageViewModel directly
from a feature internal path; update the import to use the feature's public API
instead (re-exported from src/features/manager or the feature's index.ts) so the
page references the public entrypoint (e.g., import {
useWorkerScheduleManageViewModel } from '`@/features/manager`')—modify the import
statement in src/pages/manager/worker-schedule/index.tsx to point at the
feature's public API export rather than the internal path.
- Around line 147-150: 현재 workers.map((w, index) => (...) 내부 button에
key={index}를 사용하고 있어 재사용 버그가 발생할 수 있습니다; workers 배열의 각 항목에 있는 고유 식별자(id)를 사용하도록
key를 변경하세요 (참조: workers, w, index, button, key prop) — 즉 map 콜백에서 w.id를 key로
사용하도록 수정하여 순서 변경/필터링 시 React가 안정적으로 요소를 식별하게 만드세요.
---
Nitpick comments:
In `@src/features/manager/worker-schedule/api/fixedWorkerSchdule.ts`:
- Around line 2-8: The import block at the top pulls several types from the
feature barrel '`@/features/manager`' (ResponseGetFixedWorkerSchdules,
RequestPostFixedWorkerSchdules, ResponsePostFixedWorkerSchdules,
ResponseDeleteFixedWorkerSchdules, RequestPatchFixedWorkerSchdules); replace
that barrel import by importing each type directly from the local
worker-schedule type modules (e.g. the module(s) under worker-schedule/types or
equivalent local path within this feature) so the file no longer depends on the
upper-level feature barrel and instead references the concrete type files used
by fixedWorkerSchdule.ts.
In `@src/features/manager/worker-schedule/hooks/query/useWorkspaceWorkers.ts`:
- Around line 2-4: The useWorkspaceWorkers hook imports the WorkersApiResponse
type from the home feature which violates feature boundaries; update imports so
worker-schedule no longer depends on home by moving the shared DTO
(WorkersApiResponse) into a common layer (entities or shared) or by creating a
local equivalent type in the worker-schedule feature, then change the import
used in useWorkspaceWorkers (alongside existing imports like
fetchWorkspaceWorkers and queryKeys) to reference the new shared/entities
location (or local type) and remove the direct import from the home feature.
🪄 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: 0ac4805b-c8bd-4bcf-a25a-ff06e9c24cc7
📒 Files selected for processing (27)
src/features/manager/api/posting.tssrc/features/manager/api/schedule.tssrc/features/manager/api/substitute.tssrc/features/manager/api/worker.tssrc/features/manager/api/workspace.tssrc/features/manager/home/hooks/useManagedPostingsViewModel.tssrc/features/manager/home/hooks/useManagedWorkspacesQuery.tssrc/features/manager/home/hooks/useMonthlySchedulesViewModel.tssrc/features/manager/home/hooks/useSubstituteRequestsViewModel.tssrc/features/manager/home/hooks/useTodaySchedulesViewModel.tssrc/features/manager/home/hooks/useWorkerScheduleManageViewModel.tssrc/features/manager/home/hooks/useWorkspaceDetailQuery.tssrc/features/manager/home/hooks/useWorkspaceWorkersViewModel.tssrc/features/manager/home/types/worker.tssrc/features/manager/index.tssrc/features/manager/worker-schedule/api/fixedWorkerSchdule.tssrc/features/manager/worker-schedule/hooks/mutation/index.tssrc/features/manager/worker-schedule/hooks/mutation/useCreateFixedWorkerSchedule.tssrc/features/manager/worker-schedule/hooks/mutation/useDeleteFixedWorkerSchedule.tssrc/features/manager/worker-schedule/hooks/mutation/useUpdateFixedWorkerSchedule.tssrc/features/manager/worker-schedule/hooks/query/index.tssrc/features/manager/worker-schedule/hooks/query/useFixedWorkerSchedules.tssrc/features/manager/worker-schedule/hooks/query/useWorkspaceWorkers.tssrc/features/manager/worker-schedule/hooks/useWorkerScheduleManageViewModel.tssrc/features/manager/worker-schedule/types/fixedWorkerSchdules.tssrc/pages/manager/worker-schedule/index.tsxsrc/shared/lib/queryKeys.ts
💤 Files with no reviewable changes (1)
- src/features/manager/home/hooks/useWorkerScheduleManageViewModel.ts
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/pages/manager/worker-schedule/components/ScheduleSaveButton.tsx (1)
15-15: ⚡ Quick win배경색 하드코딩 대신 디자인 토큰 클래스로 교체해주세요.
bg-[#07c079]처럼 TSX에 직접 색상 리터럴을 두면 테마/디자인 일관성 관리가 어려워집니다. Tailwind 설정의 토큰 클래스로 치환하는 편이 안전합니다.Based on learnings: In the alter-client repository, avoid hardcoding colors in TSX files.
🤖 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/manager/worker-schedule/components/ScheduleSaveButton.tsx` at line 15, The component currently hardcodes a hex background color in ScheduleSaveButton.tsx via the className "bg-[`#07c079`]"; replace that literal with the project's Tailwind design-token class (e.g., the established success/primary token such as bg-success-500 or the project's equivalent token class used elsewhere) so theming is consistent. Update the className on the ScheduleSaveButton component (where "className='h-12 w-full rounded-2xl bg-[`#07c079`] typography-body01-semibold text-white disabled:opacity-50'" appears) to use the token class and run a quick grep in the repo for similar buttons to ensure you pick the canonical token name.
🤖 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/worker-schedule/components/ScheduleDateRow.tsx`:
- Around line 1-4: The TypeScript error occurs because the code uses
React.ChangeEvent<HTMLInputElement> without importing React's type definitions;
fix by importing the event type and updating the annotation: add "import type {
ChangeEvent } from 'react'" at the top of ScheduleDateRow.tsx and replace
occurrences of "React.ChangeEvent<HTMLInputElement>" with
"ChangeEvent<HTMLInputElement>" (or alternatively import the React namespace
with "import React from 'react'" if you prefer keeping the React.ChangeEvent
form).
In `@src/pages/manager/worker-schedule/index.tsx`:
- Around line 78-87: Currently the conditional combines workersLoading and
!worker causing a permanent Spinner when loading finishes but worker is absent;
change the branching so that if (workersLoading) returns the Spinner UI (using
Spinner and Navbar as now), and add a separate branch for when (!worker) to
render a “not found” / error state or redirect (e.g. show a message or navigate
away) instead of the spinner; update the component around the existing
workersLoading, worker checks to implement these two distinct paths.
---
Nitpick comments:
In `@src/pages/manager/worker-schedule/components/ScheduleSaveButton.tsx`:
- Line 15: The component currently hardcodes a hex background color in
ScheduleSaveButton.tsx via the className "bg-[`#07c079`]"; replace that literal
with the project's Tailwind design-token class (e.g., the established
success/primary token such as bg-success-500 or the project's equivalent token
class used elsewhere) so theming is consistent. Update the className on the
ScheduleSaveButton component (where "className='h-12 w-full rounded-2xl
bg-[`#07c079`] typography-body01-semibold text-white disabled:opacity-50'"
appears) to use the token class and run a quick grep in the repo for similar
buttons to ensure you pick the canonical token name.
🪄 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: 99f124b6-e4b4-4527-9fa3-02381273b588
📒 Files selected for processing (16)
src/pages/manager/worker-schedule/components/CollapsibleScheduleSection.tsxsrc/pages/manager/worker-schedule/components/ColorSelectSection.tsxsrc/pages/manager/worker-schedule/components/FixedScheduleDateSection.tsxsrc/pages/manager/worker-schedule/components/GeneralScheduleDateSection.tsxsrc/pages/manager/worker-schedule/components/RecurrenceSelect.tsxsrc/pages/manager/worker-schedule/components/ScheduleDateRow.tsxsrc/pages/manager/worker-schedule/components/ScheduleSaveButton.tsxsrc/pages/manager/worker-schedule/components/ScheduleTabBar.tsxsrc/pages/manager/worker-schedule/components/WeekdayPicker.tsxsrc/pages/manager/worker-schedule/components/WorkTimeRangeField.tsxsrc/pages/manager/worker-schedule/components/WorkerSelectSection.tsxsrc/pages/manager/worker-schedule/index.tsxsrc/pages/manager/worker-schedule/lib/formatKoreanWorkTime.tssrc/pages/manager/worker-schedule/lib/scheduleDateParts.tssrc/pages/manager/worker-schedule/types/workTime.tssrc/shared/ui/schedule/ManagerMonthCalendar.tsx
✅ Files skipped from review due to trivial changes (1)
- src/pages/manager/worker-schedule/types/workTime.ts
| import { | ||
| buildDateFromParts, | ||
| dateToPartStrings, | ||
| } from '@/pages/manager/worker-schedule/lib/scheduleDateParts' |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 목적: React namespace 타입 사용 파일 중 react import 누락 가능성 확인 (read-only)
python - <<'PY'
from pathlib import Path
import re
for p in Path(".").rglob("*.tsx"):
text = p.read_text(encoding="utf-8")
if "React." not in text:
continue
has_react_import = re.search(r"from\s+['\"]react['\"]", text) is not None
if not has_react_import:
print(p)
PYRepository: alter-app/alter-client
Length of output: 154
🏁 Script executed:
cat -n src/pages/manager/worker-schedule/components/ScheduleDateRow.tsxRepository: alter-app/alter-client
Length of output: 3521
🏁 Script executed:
# Check TypeScript/React configuration
find . -maxdepth 2 -name "tsconfig*.json" -o -name "next.config.*" | head -5 | xargs -I {} cat {}Repository: alter-app/alter-client
Length of output: 1682
🏁 Script executed:
# Also check for any JSX pragma or React imports at the top of the file more carefully
head -30 src/pages/manager/worker-schedule/components/ScheduleDateRow.tsxRepository: alter-app/alter-client
Length of output: 648
React.ChangeEvent 네임스페이스 참조가 없어 TypeScript 컴파일 에러가 발생합니다.
Line 23에서 React.ChangeEvent<HTMLInputElement>를 사용하지만 React 네임스페이스를 import하지 않아 Cannot find namespace 'React' 컴파일 에러가 발생합니다. jsx: "react-jsx"와 strict: true 설정에서는 JSX 문법만 React import 없이 작동하며, 타입 참조는 별도로 import가 필요합니다.
수정
+import type { ChangeEvent } from 'react'
import {
buildDateFromParts,
dateToPartStrings,
} from '`@/pages/manager/worker-schedule/lib/scheduleDateParts`'- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => {🤖 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/manager/worker-schedule/components/ScheduleDateRow.tsx` around
lines 1 - 4, The TypeScript error occurs because the code uses
React.ChangeEvent<HTMLInputElement> without importing React's type definitions;
fix by importing the event type and updating the annotation: add "import type {
ChangeEvent } from 'react'" at the top of ScheduleDateRow.tsx and replace
occurrences of "React.ChangeEvent<HTMLInputElement>" with
"ChangeEvent<HTMLInputElement>" (or alternatively import the React namespace
with "import React from 'react'" if you prefer keeping the React.ChangeEvent
form).
| if (workersLoading || !worker) { | ||
| return ( | ||
| <div className="flex min-h-[100dvh] flex-col bg-bg-light"> | ||
| <Navbar variant="detail" title="근무자 스케줄 관리" /> | ||
| <p className="px-4 pt-8 typography-body01-regular text-text-70"> | ||
| 불러오는 중… | ||
| </p> | ||
| <div className="flex flex-1 items-center justify-center px-4 pt-8"> | ||
| <Spinner /> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
There was a problem hiding this comment.
!worker를 로딩으로 함께 처리하면 영구 스피너가 될 수 있습니다.
Line 78에서 workersLoading || !worker를 한 분기로 처리하면, 로딩 종료 후 worker가 비어 있는 케이스(잘못된 ID/조회 실패)에서 계속 Spinner만 노출될 수 있습니다. 로딩 상태와 미존재 상태를 분리해주세요.
🔧 제안 수정안
- if (workersLoading || !worker) {
+ if (workersLoading) {
return (
<div className="flex min-h-[100dvh] flex-col bg-bg-light">
<Navbar variant="detail" title="근무자 스케줄 관리" />
<div className="flex flex-1 items-center justify-center px-4 pt-8">
<Spinner />
</div>
</div>
)
}
+
+ if (!worker) {
+ return <Navigate to={ROUTES.MANAGER.HOME} replace />
+ }🤖 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/manager/worker-schedule/index.tsx` around lines 78 - 87, Currently
the conditional combines workersLoading and !worker causing a permanent Spinner
when loading finishes but worker is absent; change the branching so that if
(workersLoading) returns the Spinner UI (using Spinner and Navbar as now), and
add a separate branch for when (!worker) to render a “not found” / error state
or redirect (e.g. show a message or navigate away) instead of the spinner;
update the component around the existing workersLoading, worker checks to
implement these two distinct paths.
| <ScheduleSaveButton | ||
| onClick={() => { | ||
| //Todo: 저장 기능 추가 | ||
| // Todo: 저장 기능 추가 | ||
| }} | ||
| > | ||
| 저장 | ||
| </button> | ||
| </div> | ||
| /> |
There was a problem hiding this comment.
저장 버튼 클릭이 현재 no-op이라 기능이 동작하지 않습니다.
Line 142-144는 TODO만 있고 실제 저장 로직이 없어 사용자의 저장 액션이 유실됩니다. 머지 전 최소한 생성/수정 mutation 연결 또는 임시 비활성화 처리가 필요합니다.
원하시면 현재 상태(activeTab, workTime, 날짜/반복 정보) 기준으로 저장 핸들러 골격과 mutation 연결 코드까지 바로 제안드릴게요.
ID
변경 내용
구현 사항
features/worker-schedule/api/에 고정 근무 api를 추가하였습니다features/worker-schedule/hooks/에 고정 근무 query와 mutation 로직을 작성하였습니다참고 사항 (필요 시)
Summary by CodeRabbit
새 기능
개선