-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature/BAR-236] 저장하는 페이지 폴더 수정/삭제 기능 구현 #66
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d31530c
feat(domain/저장하는): 폴더 삭제 기능 구현
dmswl98 3dc851d
feat(domain/저장하는): 폴더 수정 기능 구현
dmswl98 a3ccba8
refactor(EditFolder): 로그 제거
dmswl98 b816d41
refactor(WriteInput): 공통 Button 컴포넌트로 변경
dmswl98 1f9f3db
feat(Modal): section 태그로 변경
dmswl98 5136043
feat(NotFoundArchiveCard): 저장된 템플릿이 없을 경우, 메인으로 이동
dmswl98 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 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 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 @@ | ||
const MEMO_FOLDERS = 'memo-folders'; | ||
|
||
export const MEMO_FOLDERS_KEY = { | ||
all: [MEMO_FOLDERS] as const, | ||
list: () => [...MEMO_FOLDERS_KEY.all, 'list'] as const, | ||
item: (args: unknown[]) => [...MEMO_FOLDERS_KEY.list(), ...args] as const, | ||
}; |
This file contains 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 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,25 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { useToastStore } from '@stores/toast'; | ||
|
||
import { deleteMemoFolders } from '..'; | ||
import { MEMO_FOLDERS_KEY } from '../constants/queryKey'; | ||
|
||
const useDeleteMemoFolder = () => { | ||
const { showToast } = useToastStore(); | ||
|
||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: deleteMemoFolders, | ||
onSuccess: () => { | ||
showToast({ message: '선택한 폴더가 삭제되었어요' }); | ||
|
||
queryClient.invalidateQueries({ | ||
queryKey: MEMO_FOLDERS_KEY.all, | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
export default useDeleteMemoFolder; |
This file contains 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,25 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { useToastStore } from '@stores/toast'; | ||
|
||
import { patchMemoFolders } from '..'; | ||
import { MEMO_FOLDERS_KEY } from '../constants/queryKey'; | ||
|
||
const useUpdateMemoFolder = () => { | ||
const { showToast } = useToastStore(); | ||
|
||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: patchMemoFolders, | ||
onSuccess: () => { | ||
showToast({ message: '폴더 이름이 수정되었어요' }); | ||
|
||
queryClient.invalidateQueries({ | ||
queryKey: MEMO_FOLDERS_KEY.all, | ||
}); | ||
}, | ||
}); | ||
}; | ||
|
||
export default useUpdateMemoFolder; |
This file contains 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 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 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 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 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,34 @@ | ||
import { type HTMLAttributes, type PropsWithChildren } from 'react'; | ||
|
||
import * as styles from '../style.css'; | ||
|
||
interface ModalProps extends HTMLAttributes<HTMLDivElement> {} | ||
|
||
export const ModalHeader = ({ | ||
children, | ||
...props | ||
}: PropsWithChildren<ModalProps>) => { | ||
return ( | ||
<header {...props} className={styles.modalHeader}> | ||
{children} | ||
</header> | ||
); | ||
}; | ||
|
||
export const ModalBody = ({ | ||
children, | ||
...props | ||
}: PropsWithChildren<ModalProps>) => { | ||
return ( | ||
<main {...props} className={styles.modalBody}> | ||
{children} | ||
</main> | ||
); | ||
}; | ||
|
||
export const ModalFooter = ({ | ||
children, | ||
...props | ||
}: PropsWithChildren<ModalProps>) => { | ||
return <footer {...props}>{children}</footer>; | ||
}; |
This file contains 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 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,107 @@ | ||
import { type ChangeEvent, useState } from 'react'; | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
import { assignInlineVars } from '@vanilla-extract/dynamic'; | ||
import { AxiosError } from 'axios'; | ||
import clsx from 'clsx'; | ||
|
||
import useUpdateMemoFolder from '@api/memoFolder/mutations/useUpdateMemoFolder'; | ||
import Button from '@components/Button'; | ||
import Icon from '@components/Icon'; | ||
import { useModalStore } from '@stores/modal'; | ||
import { COLORS } from '@styles/tokens'; | ||
|
||
import ModalContainer from '../components/ModalContainer'; | ||
import * as styles from '../style.css'; | ||
|
||
const EditFolder = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
const { closeModal, memoFolderId, folderName } = useModalStore(); | ||
const [value, setValue] = useState(folderName); | ||
const [errorMessage, setErrorMessage] = useState(''); | ||
|
||
const { mutateAsync } = useUpdateMemoFolder(); | ||
|
||
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
setErrorMessage(''); | ||
setValue(e.target.value); | ||
}; | ||
|
||
const handleFolderNameEdit = async () => { | ||
if (value.length > 10) return setErrorMessage('10자 내로 입력해주세요!'); | ||
|
||
await mutateAsync( | ||
{ memoFolderId, folderName: value }, | ||
{ | ||
onSuccess: async () => { | ||
await queryClient.invalidateQueries({ | ||
queryKey: ['memo-folders'], | ||
}); | ||
closeModal(); | ||
}, | ||
onError: (e) => { | ||
if (!(e instanceof AxiosError) || !e.response) throw e; | ||
if ( | ||
(e.response.data as { errorCode: string; message: string }) | ||
.errorCode === 'MF01' | ||
) | ||
return setErrorMessage('이미 사용 중인 폴더 이름이에요!'); | ||
throw e; | ||
}, | ||
}, | ||
); | ||
}; | ||
|
||
return ( | ||
<ModalContainer> | ||
<strong className={styles.makeFolderTitle}>폴더 수정하기</strong> | ||
<label htmlFor="makeFolder" className={styles.makeFolderDescription}> | ||
폴더 이름 | ||
</label> | ||
<div className={styles.makeFolderInputWrapper}> | ||
<input | ||
id="makeFolder" | ||
className={clsx( | ||
styles.makeFolderInput, | ||
errorMessage && styles.errorInput, | ||
)} | ||
value={value} | ||
onChange={handleInputChange} | ||
/> | ||
</div> | ||
{errorMessage && ( | ||
<span className={styles.errorMessage}> | ||
<div className={styles.errorIcon}> | ||
<Icon width={20} height={20} icon="error" /> | ||
</div> | ||
{errorMessage} | ||
</span> | ||
)} | ||
<div className={styles.makeFolderButtonWrapper}> | ||
<Button | ||
className={styles.button} | ||
style={assignInlineVars({ | ||
[styles.buttonColor]: COLORS['Grey/600'], | ||
[styles.buttonBackgroundColor]: COLORS['Grey/150'], | ||
})} | ||
onClick={closeModal} | ||
> | ||
취소 | ||
</Button> | ||
<Button | ||
className={clsx(styles.button, !value && styles.buttonDisabled)} | ||
disabled={!value} | ||
style={assignInlineVars({ | ||
[styles.buttonColor]: COLORS['Grey/White'], | ||
[styles.buttonBackgroundColor]: COLORS['Blue/Default'], | ||
})} | ||
onClick={handleFolderNameEdit} | ||
> | ||
저장하기 | ||
</Button> | ||
</div> | ||
</ModalContainer> | ||
); | ||
}; | ||
|
||
export default EditFolder; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
보통 모달에는 header/main/footer 태그를 안 사용하지 않나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 하나의 section으로 볼 수 있을 거 같아서 해두었습니다..!