Skip to content

[network] #101 템플릿 조회 API 연결 - #102

Merged
dearosmar merged 12 commits into
mainfrom
network/#101
Jul 30, 2026
Merged

[network] #101 템플릿 조회 API 연결#102
dearosmar merged 12 commits into
mainfrom
network/#101

Conversation

@dearosmar

@dearosmar dearosmar commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

☘️ 작업한 이슈


🍀 작업한 내용

  1. 템플릿 조회 API(GET /api/templates) 연동을 위한 useTemplates 훅을 구현했습니다. (VITE_USE_MOCK 플래그로 목업/실서버 전환, type 파라미터 지원 — 기본값 BASIC)
  2. 명세 예시와 동일한 템플릿 목업 데이터(mockTemplates.js)를 추가했습니다.
  3. 템플릿 작성 폼의 하드코딩된 항목(기본 정보/활동 내용/성찰 및 성장)을 API 응답 values 배열 기반 동적 렌더링으로 변경했습니다. "증빙 자료" 항목은 디자인대로 업로드 영역으로 표시됩니다.
  4. 글 작성 페이지에 훅을 연결하고 로딩(Spinner) / 에러·빈 상태(EmptyState)를 처리했습니다. 다음 단계 미리보기는 작성한 항목을 템플릿 순서대로 병합해 보여줍니다.

🍃 작업 포인트

  • 응답의 data.values가 항목 "이름 문자열 배열"이라, 폼 상태를 고정 키(basicInfo 등) 객체 대신 항목 이름을 키로 쓰는 객체로 바꿨습니다. 백엔드에서 템플릿 항목이 바뀌어도 프론트 수정 없이 그대로 반영됩니다.
const { values: templateFields, isLoading, error } = useTemplates();

<TemplateWriteForm
  fields={templateFields}
  value={templateContent}
  onChange={setTemplateContent}
/>

Summary by CodeRabbit

  • 새 기능
    • 선택한 템플릿 유형에 따라 템플릿 목록과 항목을 동적으로 불러옵니다.
    • 템플릿 항목을 정의된 순서대로 자동 구성해 텍스트/증빙 업로드 입력을 지원합니다.
    • 템플릿 로딩 중에는 로딩 표시, 실패 또는 항목 없음 시 안내 화면을 표시합니다.
  • 개선 사항
    • 템플릿 작성 단계에서 필수 조건 미충족 시 다음 버튼이 비활성화되며 스타일이 강화됩니다.
    • 미리보기는 템플릿 항목 순서대로 여러 블록으로 결합해 표시됩니다.
    • 제출 시 로그인 이동/에러 표시/제출 버튼 비활성화가 추가되었습니다.

@dearosmar dearosmar self-assigned this Jul 26, 2026
@dearosmar dearosmar linked an issue Jul 26, 2026 that may be closed by this pull request
5 tasks
@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
sprout-efub Ready Ready Preview Jul 30, 2026 5:51am

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

템플릿 조회 훅과 목업 데이터가 추가되었습니다. 작성 페이지는 조회 상태에 따라 로딩·빈 상태·입력 폼을 표시하고, 동적 필드와 업로드 파일을 게시글 미리보기 및 제출 흐름에 반영합니다.

Changes

템플릿 작성 흐름

Layer / File(s) Summary
템플릿 데이터 조회
src/mocks/mockTemplates.js, src/features/post/api/useTemplates.js
목업 또는 템플릿 목록 API에서 필드를 조회하고 로딩·에러·값 상태를 반환합니다.
동적 템플릿 입력 폼
src/features/post/components/TemplateWriteForm.jsx
필드 목록에 따라 텍스트 영역과 증빙 파일 업로드 UI를 렌더링하고 입력값과 파일을 전달합니다.
작성 페이지 연동 및 제출
src/pages/PostWritePage.jsx
조회 상태에 따라 화면을 분기하고, 업로드 파일과 필드 값을 누적·결합하여 미리보기와 게시글 제출에 사용합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: 🍃 feat

Suggested reviewers: nayeon653

Sequence Diagram(s)

sequenceDiagram
  participant PostWritePage
  participant useTemplates
  participant TemplateWriteForm
  participant PreviewBox
  participant createPost
  PostWritePage->>useTemplates: 템플릿 필드 조회
  useTemplates-->>PostWritePage: 필드 목록과 조회 상태 전달
  PostWritePage->>TemplateWriteForm: fields, value, onUpload 전달
  TemplateWriteForm-->>PostWritePage: 입력값 및 선택 파일 전달
  PostWritePage->>PreviewBox: 필드 순서대로 값을 결합해 표시
  PostWritePage->>createPost: 최종 content와 업로드 파일 제출
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 템플릿 조회 API 연동이라는 핵심 변경을 짧고 명확하게 요약합니다.
Linked Issues check ✅ Passed useTemplates, mock/실서버 분기, 폼 연동, 로딩·에러·빈 상태 처리가 요구사항과 일치합니다.
Out of Scope Changes check ✅ Passed 추가 변경도 템플릿 조회와 작성 흐름을 지원하는 범위에 있어 명백한 범위 이탈로 보이지 않습니다.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch network/#101

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/pages/PostWritePage.jsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/features/post/api/useTemplates.js (1)

13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Boolean 변수 이름을 is 접두사로 변경해주세요.

ignore는 Boolean 상태이므로 isIgnored처럼 의도가 드러나는 이름으로 바꾸고 모든 참조를 함께 갱신해주세요. As per path instructions, “Boolean 값은 is / has / should 로 시작”.

🤖 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/post/api/useTemplates.js` at line 13, Rename the Boolean
variable ignore to isIgnored in useTemplates and update every reference
consistently, preserving the existing behavior.

Source: Path instructions

src/pages/PostWritePage.jsx (1)

24-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

로딩 Boolean 이름을 is 접두사로 통일해주세요.

templateLoading은 Boolean 값이므로 isTemplateLoading으로 변경하고 렌더링 조건도 함께 갱신해주세요. As per path instructions, “Boolean 값은 is / has / should 로 시작”.

Also applies to: 70-70

🤖 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/PostWritePage.jsx` around lines 24 - 28, Rename the Boolean
returned as templateLoading from useTemplates to isTemplateLoading, following
the is/has/should naming convention, and update all rendering conditions and
references in PostWritePage accordingly.

Source: Path instructions

🤖 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/post/api/useTemplates.js`:
- Line 7: useTemplates 함수의 type 매개변수에 기본값 BASIC을 지정해, 인자 없이 호출되는
PostWritePage에서도 API 요청에 type 쿼리가 포함되도록 수정하세요.

In `@src/features/post/components/TemplateWriteForm.jsx`:
- Around line 13-16: Update the upload-field rendering in TemplateWriteForm so
UploadArea triggers real file selection and upload behavior instead of being a
passive button. Either accept and invoke an onUpload callback connected to the
parent attachment state, or implement UploadArea as a label associated with an
input[type="file"], while preserving the displayed field name.

In `@src/pages/PostWritePage.jsx`:
- Around line 72-73: Update the conditional rendering in PostWritePage so
templateError and an empty templateFields array use separate branches. Keep the
existing failure message only for templateError, and add the appropriate
empty-template 안내 message for successful responses with no templates.
- Around line 70-79: 템플릿 작성 모드에서 templateLoading이 true이거나 templateError가 있거나
templateFields가 비어 있는 동안에는 다음 단계 버튼을 disabled 처리하세요. 해당 조건이 해소되면 기존처럼 활성화되도록
`PostWritePage`의 다음 버튼 상태 로직을 업데이트하세요.

---

Nitpick comments:
In `@src/features/post/api/useTemplates.js`:
- Line 13: Rename the Boolean variable ignore to isIgnored in useTemplates and
update every reference consistently, preserving the existing behavior.

In `@src/pages/PostWritePage.jsx`:
- Around line 24-28: Rename the Boolean returned as templateLoading from
useTemplates to isTemplateLoading, following the is/has/should naming
convention, and update all rendering conditions and references in PostWritePage
accordingly.
🪄 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 Plus

Run ID: 4a244fcf-bf51-4b5a-b1e2-f4d9b74c52e1

📥 Commits

Reviewing files that changed from the base of the PR and between 51bd26e and 21e591c.

📒 Files selected for processing (4)
  • src/features/post/api/useTemplates.js
  • src/features/post/components/TemplateWriteForm.jsx
  • src/mocks/mockTemplates.js
  • src/pages/PostWritePage.jsx

Comment thread src/features/post/api/useTemplates.js Outdated
Comment thread src/features/post/components/TemplateWriteForm.jsx
Comment thread src/pages/PostWritePage.jsx Outdated
Comment thread src/pages/PostWritePage.jsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/post/components/TemplateWriteForm.jsx`:
- Around line 66-87: Update HiddenInput to use a visually hidden technique
instead of display: none so keyboard users can reach the file input, and add a
:focus-within style to UploadArea using the project’s focus-color token to
provide a visible focus state.
🪄 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 Plus

Run ID: a20b9af7-ff39-416d-bf84-72423dc62a34

📥 Commits

Reviewing files that changed from the base of the PR and between 21e591c and 8b41600.

📒 Files selected for processing (3)
  • src/features/post/api/useTemplates.js
  • src/features/post/components/TemplateWriteForm.jsx
  • src/pages/PostWritePage.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/PostWritePage.jsx

Comment thread src/features/post/components/TemplateWriteForm.jsx Outdated
# Conflicts:
#	src/pages/PostWritePage.jsx
nayeon653
nayeon653 previously approved these changes Jul 28, 2026
# Conflicts:
#	src/pages/PostWritePage.jsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (3)
src/pages/PostWritePage.jsx (3)

36-40: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

템플릿 모드 전환 시 조회를 다시 시작해야 합니다.

PostWritePage는 자유 작성 모드에서도 useTemplates()를 호출합니다. 제공된 훅은 type만 의존하므로 최초 요청이 실패하거나 빈 응답이면 사용자가 템플릿 모드로 전환해도 재요청되지 않아 오류/빈 상태가 그대로 남습니다. enabled 옵션으로 템플릿 모드 진입 시 조회하도록 하거나, 템플릿 전용 feature 컴포넌트 안에서 훅을 마운트해주세요. 자유 모드의 불필요한 API 요청도 제거할 수 있습니다.

🤖 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/PostWritePage.jsx` around lines 36 - 40, Update the useTemplates
call in PostWritePage so template data is fetched when entering template mode
and retried after an initial failure or empty response; use the hook’s enabled
option if supported, or move the hook into a template-only component. Avoid
issuing the templates API request while free-writing mode is active.

83-99: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

첨부 파일을 미리보기와 제출 payload에 전달해야 합니다.

filesphotos는 로컬 미리보기에서만 사용되고, 2단계 PreviewBoxcreatePost payload에는 포함되지 않습니다. 현재 선택한 증빙 파일이 성공적으로 게시된 것처럼 보여도 실제 게시글에는 조용히 누락됩니다. 백엔드 계약에 맞는 첨부 필드 또는 FormData로 제출하고, 2단계에서도 첨부 내역을 확인할 수 있게 해주세요.

Also applies to: 159-166

🤖 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/PostWritePage.jsx` around lines 83 - 99, PostWritePage의 files와
photos가 로컬 미리보기에만 사용되어 PreviewBox와 createPost 제출 데이터에서 누락되지 않도록 수정하세요. 2단계
PreviewBox에 첨부 내역을 전달하고, createPost 호출 시 백엔드 계약에 맞는 첨부 필드 또는 FormData로 선택 파일과
사진을 함께 제출하세요.

174-174: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

오류 안내 문구의 띄어쓰기를 수정해주세요.

시도해주세요시도해 주세요로 수정하면 자연스러운 사용자 안내가 됩니다.

수정 예시
- 게시글을 등록하지 못했습니다. 다시 시도해주세요.
+ 게시글을 등록하지 못했습니다. 다시 시도해 주세요.
🤖 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/PostWritePage.jsx` at line 174, Update the error message rendered
by the error conditional in PostWritePage so the Korean phrase uses “시도해 주세요”
instead of “시도해주세요”, leaving the rest of the user-facing message unchanged.
🧹 Nitpick comments (1)
src/pages/PostWritePage.jsx (1)

68-101: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

페이지의 도메인 로직과 복잡한 UI 분기를 features/post로 분리해주세요.

현재 페이지가 인증 리다이렉트, 콘텐츠 직렬화, 카테고리 변환, 게시글 payload 생성, 템플릿 상태별 렌더링, 폼 연결까지 모두 담당합니다. 제출 로직은 전용 훅으로, 템플릿 상태/UI는 feature 컴포넌트로 옮겨 PostWritePage를 얇게 유지하는 편이 테스트와 변경에 유리합니다.

As per path instructions: src/pages/** 페이지 컴포넌트는 얇게 유지하고, 비즈니스 로직이나 복잡한 UI는 features/ 하위 도메인 폴더로 분리해야 합니다.

Also applies to: 110-147

🤖 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/PostWritePage.jsx` around lines 68 - 101, Move the post submission
domain logic from PostWritePage, including authentication redirect, content
serialization, category mapping, payload construction, and createPost handling,
into a dedicated hook under features/post. Move template state and conditional
UI rendering into feature components there, then keep PostWritePage focused on
composing the feature UI and connecting the form; preserve the existing
submission behavior and success toast.

Source: Path instructions

🤖 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.

Outside diff comments:
In `@src/pages/PostWritePage.jsx`:
- Around line 36-40: Update the useTemplates call in PostWritePage so template
data is fetched when entering template mode and retried after an initial failure
or empty response; use the hook’s enabled option if supported, or move the hook
into a template-only component. Avoid issuing the templates API request while
free-writing mode is active.
- Around line 83-99: PostWritePage의 files와 photos가 로컬 미리보기에만 사용되어 PreviewBox와
createPost 제출 데이터에서 누락되지 않도록 수정하세요. 2단계 PreviewBox에 첨부 내역을 전달하고, createPost 호출 시
백엔드 계약에 맞는 첨부 필드 또는 FormData로 선택 파일과 사진을 함께 제출하세요.
- Line 174: Update the error message rendered by the error conditional in
PostWritePage so the Korean phrase uses “시도해 주세요” instead of “시도해주세요”, leaving
the rest of the user-facing message unchanged.

---

Nitpick comments:
In `@src/pages/PostWritePage.jsx`:
- Around line 68-101: Move the post submission domain logic from PostWritePage,
including authentication redirect, content serialization, category mapping,
payload construction, and createPost handling, into a dedicated hook under
features/post. Move template state and conditional UI rendering into feature
components there, then keep PostWritePage focused on composing the feature UI
and connecting the form; preserve the existing submission behavior and success
toast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c9c73018-b5a0-46d8-b3b2-f015ae7d3926

📥 Commits

Reviewing files that changed from the base of the PR and between c5fa57c and 3fc903f.

📒 Files selected for processing (1)
  • src/pages/PostWritePage.jsx

@dearosmar
dearosmar merged commit 047e410 into main Jul 30, 2026
3 checks passed
@dearosmar
dearosmar deleted the network/#101 branch July 30, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[network] 템플릿 조회 API 연동

2 participants