-
Notifications
You must be signed in to change notification settings - Fork 2
feature/#266 데이터 패치 에러 컴포넌트 적용 #268
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
The head ref may contain hidden characters: "feature/#266_\uB370\uC774\uD130-\uD328\uCE58\uB370\uC774\uD130-\uD328\uCE58-\uC5D0\uB7EC-\uCEF4\uD3EC\uB10C\uD2B8-\uC801\uC6A9"
Merged
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ import ImageUploadModal from '@/components/Modal/ImageUploadModal'; | |
| import TextEditor from '@/components/TextEditor'; | ||
| import { useMutation } from '@tanstack/react-query'; | ||
| import { useSnackbar } from 'context/SnackBarContext'; | ||
| import ErrorMessage from '@/components/ErrorMessage'; | ||
| import Modal from '@/components/Modal/Modal'; | ||
|
|
||
| // 제목 글자수 제한 | ||
| const MAX_TITLE = 30; | ||
|
|
@@ -21,7 +23,8 @@ const MAX_TITLE = 30; | |
| export default function Addboard() { | ||
| const [title, setTitle] = useState(''); | ||
| const [content, setContent] = useState(''); | ||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [isThumbnailOpen, setIsThumbnailOpen] = useState(false); | ||
| const [isErrorOpen, setIsErrorOpen] = useState(false); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
| const [imageFile, setImageFile] = useState<File | null>(null); | ||
| const { showSnackbar } = useSnackbar(); | ||
|
|
@@ -45,6 +48,7 @@ export default function Addboard() { | |
| }, | ||
| onError: (err) => { | ||
| console.error('--- 썸네일 업로드 에러:', err); | ||
| showSnackbar('썸네일 등록에 실패하였습니다.', 'fail'); | ||
| }, | ||
| }); | ||
| // 글작성 tanstack | ||
|
|
@@ -54,11 +58,12 @@ export default function Addboard() { | |
| return res; | ||
| }, | ||
| onSuccess: (data) => { | ||
| router.push('/boards/' + data.id); | ||
| showSnackbar('게시물이 등록되었습니다.', 'success'); | ||
| router.push('/boards/' + data.id); | ||
| }, | ||
| onError: (err) => { | ||
| console.error('--- 게시물 등록 에러:', err); | ||
| showSnackbar('게시물 등록에 실패하였습니다.', 'fail'); | ||
| }, | ||
| }); | ||
|
|
||
|
|
@@ -68,11 +73,14 @@ export default function Addboard() { | |
| }; | ||
| // 썸네일 이미지 클릭 콜백 함수 | ||
| const handleAddThumbnail = () => { | ||
| setIsModalOpen(true); | ||
| setIsThumbnailOpen(true); | ||
| }; | ||
| // 이미지 모달 닫기 | ||
| const handleImageModalClose = () => { | ||
| setIsModalOpen(false); | ||
| setIsThumbnailOpen(false); | ||
| }; | ||
| const handleErrorModalClose = () => { | ||
| setIsErrorOpen(false); | ||
| }; | ||
| // 이미지 파일 가져오기 | ||
| const getImageFile = (file: File | null) => { | ||
|
|
@@ -174,10 +182,34 @@ export default function Addboard() { | |
|
|
||
| <ImageUploadModal | ||
| imageFile={imageFile} | ||
| isOpen={isModalOpen} | ||
| isOpen={isThumbnailOpen} | ||
| onClose={handleImageModalClose} | ||
| onGetImageFile={getImageFile} | ||
| /> | ||
|
|
||
| <Modal | ||
| isOpen={isErrorOpen} | ||
| onClose={handleErrorModalClose} | ||
| width="w-[520px]" | ||
| > | ||
| <ErrorMessage | ||
| title="게시글 등록에 실패하였습니다." | ||
| buttonPosition="right" | ||
| > | ||
| 이용에 불편을 드려 죄송합니다. 잠시 후 다시 시도해 주십시오. | ||
| <br /> | ||
| 오류 현상이 반복되면 코드잇 서버 개발 부서에 연락 부탁 드립니다. | ||
| <div className="text-14sb text-gray-400"> | ||
| · 11-7팀에는 아무 잘못이 없습니다. | ||
| </div> | ||
| <a | ||
| href="mailto:[email protected]" | ||
| className="text-14sb hover:underline" | ||
| > | ||
| 📧 [email protected] | ||
| </a> | ||
| </ErrorMessage> | ||
| </Modal> | ||
| </div> | ||
| ); | ||
| } | ||
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
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.