-
Notifications
You must be signed in to change notification settings - Fork 2
✨ feat: 컬럼 관리 기능 (생성/수정/삭제) #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
69a2d1b
Merge branch 'develop' into feature/dashboard_id-column
LeeCh0129 1193737
🐛 fix: API 인증 오류 해결 - 호출에서 testAxios를 authHttpClient로 통일
LeeCh0129 6208f4e
✨ feat: 컬럼 관리 기능 (생성/수정/삭제)
LeeCh0129 8fff1a2
♻️ refactor: 컬럼 모달 타입 가드
LeeCh0129 c585882
✨ feat: 컬럼 관리 모달 반응형 적용
LeeCh0129 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import authHttpClient from '@/app/shared/lib/axios' | ||
|
|
||
| export async function deleteColumn(columnId: number): Promise<void> { | ||
| await authHttpClient.delete( | ||
| `/${process.env.NEXT_PUBLIC_TEAM_ID}/columns/${columnId}`, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import authHttpClient from '@/app/shared/lib/axios' | ||
|
|
||
| import { CreateColumnRequest, CreateColumnResponse } from '../type/Column.type' | ||
|
|
||
| export async function postColumn( | ||
| payload: CreateColumnRequest, | ||
| ): Promise<CreateColumnResponse> { | ||
| const response = await authHttpClient.post<CreateColumnResponse>( | ||
| `/${process.env.NEXT_PUBLIC_TEAM_ID}/columns`, | ||
| payload, | ||
| ) | ||
| return response.data | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import authHttpClient from '@/app/shared/lib/axios' | ||
|
|
||
| import { UpdateColumnRequest, UpdateColumnResponse } from '../type/Column.type' | ||
|
|
||
| export async function updateColumn( | ||
| columnId: number, | ||
| payload: UpdateColumnRequest, | ||
| ): Promise<UpdateColumnResponse> { | ||
| const response = await authHttpClient.put<UpdateColumnResponse>( | ||
| `/${process.env.NEXT_PUBLIC_TEAM_ID}/columns/${columnId}`, | ||
| payload, | ||
| ) | ||
| return response.data | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/app/features/dashboard_Id/components/ColumnModalRenderer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| 'use client' | ||
|
|
||
| import { useColumnModalStore } from '../store/useColumnModalStore' | ||
| import CreateColumnModal from './CreateColumnModal' | ||
| import DeleteColumnConfirmModal from './DeleteColumnConfirmModal' | ||
| import EditColumnModal from './EditColumnModal' | ||
|
|
||
| export default function ColumnModalRenderer() { | ||
| const { modalType } = useColumnModalStore() | ||
|
|
||
| if (modalType === 'create') return <CreateColumnModal /> | ||
| if (modalType === 'edit') return <EditColumnModal /> | ||
| if (modalType === 'deleteConfirm') return <DeleteColumnConfirmModal /> | ||
|
|
||
| return null | ||
| } |
151 changes: 151 additions & 0 deletions
151
src/app/features/dashboard_Id/components/CreateColumnModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| 'use client' | ||
|
|
||
| import { useEffect, useState } from 'react' | ||
|
|
||
| import useColumns from '../api/useColumns' | ||
| import { useCreateColumn } from '../hooks/useCreateColumn' | ||
| import { useColumnModalStore } from '../store/useColumnModalStore' | ||
|
|
||
| export default function CreateColumnModal() { | ||
| const { modalType, modalData, closeModal } = useColumnModalStore() | ||
| const isModalOpen = modalType === 'create' | ||
|
|
||
| const [title, setTitle] = useState('') | ||
| const [isSubmitting, setIsSubmitting] = useState(false) | ||
|
|
||
| // 기존 컬럼 목록 가져오기 (중복 체크용) | ||
| const { data: columns } = useColumns(modalData?.dashboardId || 0) | ||
| const createColumnMutation = useCreateColumn() | ||
|
|
||
| useEffect(() => { | ||
| if (!isModalOpen) { | ||
| setTitle('') | ||
| setIsSubmitting(false) | ||
| } | ||
| }, [isModalOpen]) | ||
|
|
||
| if (!isModalOpen) { | ||
| return null | ||
| } | ||
|
|
||
| // 중복 컬럼명 체크 | ||
| const isDuplicate = columns?.some( | ||
| (column) => column.title.toLowerCase() === title.toLowerCase(), | ||
| ) | ||
|
|
||
| // 컬럼 최대 개수 체크 (10개) | ||
| const isMaxColumns = columns && columns.length >= 10 | ||
|
|
||
| // 에러 메시지 표시 여부에 따른 높이 계산 | ||
| const hasError = isDuplicate || isMaxColumns | ||
| const modalHeight = hasError ? 'h-286' : 'h-266' | ||
|
|
||
| // 생성 버튼 활성화 조건 | ||
| const isCreateDisabled = | ||
| !title.trim() || isDuplicate || isMaxColumns || isSubmitting | ||
|
|
||
| const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => { | ||
| e.preventDefault() | ||
|
|
||
| if (!title.trim() || isDuplicate || isMaxColumns) { | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| setIsSubmitting(true) | ||
|
|
||
| await createColumnMutation.mutateAsync({ | ||
| title: title.trim(), | ||
| dashboardId: modalData!.dashboardId, | ||
| }) | ||
|
|
||
| closeModal() | ||
| } catch (error) { | ||
| // 에러는 useCreateColumn에서 toast로 처리됨 | ||
| } finally { | ||
| setIsSubmitting(false) | ||
| } | ||
| } | ||
|
|
||
| // 입력값 변경 처리 | ||
| const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| setTitle(e.target.value) | ||
| } | ||
|
|
||
| // 모달 외부 클릭 시 닫기 | ||
| const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => { | ||
| if (e.target === e.currentTarget) { | ||
| closeModal() | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| // 모달 백드롭 | ||
| <div | ||
| className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50" | ||
| onClick={handleBackdropClick} | ||
| > | ||
| {/* 모달 컨테이너 - 에러 메시지에 따른 동적 높이 */} | ||
| <div className={`BG-white ${modalHeight} w-568 rounded-8 p-24`}> | ||
| <h2 className="Text-black mb-24 text-24 font-bold">새 컬럼 생성</h2> | ||
|
|
||
| <form onSubmit={handleSubmit}> | ||
| {/* 제목 입력 */} | ||
| <div className="mb-24"> | ||
| <label htmlFor="title" className="Text-black mb-8 block text-18"> | ||
| 이름 | ||
| </label> | ||
| <input | ||
| type="text" | ||
| id="title" | ||
| name="title" | ||
| value={title} | ||
| onChange={handleChange} | ||
| placeholder="새로운 프로젝트" | ||
| className={`w-full rounded-8 px-12 py-10 text-16 outline-none ${ | ||
| hasError ? 'Border-error' : 'Border-section' | ||
| }`} | ||
| maxLength={30} | ||
| autoFocus | ||
| required | ||
| /> | ||
|
|
||
| {/* 에러 메시지 표시 */} | ||
| {isDuplicate && ( | ||
| <p className="mt-8 text-14 text-red-500"> | ||
| 중복된 컬럼 이름입니다 | ||
| </p> | ||
| )} | ||
| {isMaxColumns && ( | ||
| <p className="mt-8 text-14 text-red-500"> | ||
| 컬럼은 최대 10개까지 생성 가능합니다 | ||
| </p> | ||
| )} | ||
| </div> | ||
|
|
||
| {/* 하단 버튼 */} | ||
| <div className="flex justify-end gap-10"> | ||
| <button | ||
| type="button" | ||
| onClick={closeModal} | ||
| className="Border-btn Text-black h-54 w-256 rounded-8 px-16 py-10 text-16 font-semibold" | ||
| > | ||
| 취소 | ||
| </button> | ||
| <button | ||
| type="submit" | ||
| disabled={isCreateDisabled} | ||
| className={`BG-violet h-54 w-256 rounded-8 px-16 py-10 text-16 font-semibold text-white transition-opacity ${ | ||
| isCreateDisabled | ||
| ? 'cursor-not-allowed opacity-50' | ||
| : 'hover:opacity-90' | ||
| }`} | ||
| > | ||
| 생성 | ||
| </button> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.