-
Notifications
You must be signed in to change notification settings - Fork 44
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
[김은재] Week19 #489
Merged
lisarnjs
merged 5 commits into
codeit-bootcamp-frontend:part3-김은재
from
rladmswo1715:part4-김은재-week19
Jun 30, 2024
The head ref may contain hidden characters: "part4-\uAE40\uC740\uC7AC-week19"
Merged
[김은재] Week19 #489
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
45 changes: 43 additions & 2 deletions
45
components/common/modal/modalContent/FolderAddModalContent.tsx
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 |
---|---|---|
@@ -1,11 +1,52 @@ | ||
import { useContext, useState } from "react"; | ||
import * as S from "./FolderAddModalContent.styled"; | ||
import Button from "@/components/common/Button"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { addFolder } from "@/api/folder"; | ||
import { UserInfoContext } from "@/context/User"; | ||
|
||
const FolderAddModalContent = () => { | ||
const [folderName, setFolderName] = useState(""); | ||
const userInfo = useContext(UserInfoContext); | ||
|
||
const changeInputFolderName = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
setFolderName(e.target.value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.target vs e.currentTarget의 차이점을 아시나요?! 👇🏻혹시 모르신다면 아래를 참고해주세요! |
||
}; | ||
|
||
const handleFolderAdd = useMutation({ | ||
mutationFn: () => { | ||
if (!userInfo || !userInfo.token) { | ||
return Promise.reject(new Error("UserToken Error!")); | ||
} | ||
return addFolder(folderName, userInfo.token); | ||
}, | ||
onSuccess: () => { | ||
alert("폴더 추가 성공"); | ||
window.location.reload(); | ||
}, | ||
}); | ||
|
||
const handleFolderAddBtnClick = () => { | ||
if (folderName.trim() === "") { | ||
alert("폴더 이름 입력"); | ||
return; | ||
} | ||
handleFolderAdd.mutate(); | ||
}; | ||
|
||
return ( | ||
<S.FolderAddContent> | ||
<input type="text" placeholder="내용 입력" /> | ||
<Button btnType="button" type="folderAdd_modal"> | ||
<input | ||
type="text" | ||
value={folderName} | ||
placeholder="내용 입력" | ||
onChange={changeInputFolderName} | ||
/> | ||
<Button | ||
btnType="button" | ||
type="folderAdd_modal" | ||
handleButtonClick={handleFolderAddBtnClick} | ||
> | ||
추가하기 | ||
</Button> | ||
</S.FolderAddContent> | ||
|
40 changes: 38 additions & 2 deletions
40
components/common/modal/modalContent/FolderDeleteContent.tsx
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
Oops, something went wrong.
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.
HTTP메소드들도 함수 util로 분리한다면 fetch 함수를 사용하는데 더 확장성 있게 사용할 수 있을거에요!