-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Feat/#102] curious api #112
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
20a964b
chore: heart icon추가
ljh0608 e48c136
feat: get curious api 연결
ljh0608 66dcb01
refactor: 주석 제거 코드 간결화
ljh0608 d132beb
feat: curious 생성 api 연결
ljh0608 9290ffd
fix: login api feat useEffect
ljh0608 12ab88a
feat: createPostCurious api 연결
ljh0608 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,28 @@ | ||
import { client } from '../../../utils/apis/axios'; | ||
|
||
interface PostCuriousResponseType { | ||
status: string; | ||
message: string; | ||
data: { | ||
isCurious: boolean; | ||
}; | ||
} | ||
|
||
const createPostCurious = async (postId: string) => { | ||
try { | ||
const token = localStorage.getItem('accessToken'); | ||
const { data } = await client.post<PostCuriousResponseType>( | ||
`api/post/${postId}/curious`, | ||
{}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
); | ||
return data; | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; | ||
export default createPostCurious; |
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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
import { css } from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
|
||
import { useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { QuestioHoverIc, QuestionDefaultIc } from './../../../assets/svgs'; | ||
import { useGetCuriousInfo, usePostCurious } from '../hooks/queries'; | ||
|
||
interface Curious { | ||
curiousNum: number; | ||
} | ||
const CuriousBtn = ({ curiousNum }: Curious) => { | ||
const [isClick, setIsClick] = useState(false); | ||
import { DetailPurpleFavoriteIc, DetailWhiteFavoriteIc } from './../../../assets/svgs'; | ||
|
||
const handleIsClick = () => { | ||
const CuriousBtn = () => { | ||
const [isClick, setIsClick] = useState(false); | ||
const { postId } = useParams(); | ||
const { data } = useGetCuriousInfo(postId || ''); | ||
const { mutate: postCurious } = usePostCurious(postId || ''); | ||
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. p5) 여기서 mutate가 뭐 하는 거에요 ? |
||
const handleBtnClick = () => { | ||
setIsClick((prev) => !prev); | ||
postCurious(); | ||
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. p5) mutate로 불러와서 사용하는 거 아닌가요..?... ? |
||
}; | ||
return ( | ||
<> | ||
<CuriousBtnWrapper onClick={handleIsClick} $isClick={isClick}> | ||
<CuriousBtnWrapper onClick={handleBtnClick} $isClick={isClick}> | ||
<CuriousTextWrapper> | ||
<CuriousTextContainer> | ||
{isClick ? <QuestioHoverIc /> : <QuestionDefaultIc />} | ||
{isClick ? <DetailWhiteFavoriteIc /> : <DetailPurpleFavoriteIc />} | ||
궁금해요 | ||
</CuriousTextContainer> | ||
<CuriousTextWrapper>{curiousNum}</CuriousTextWrapper> | ||
<CuriousTextWrapper>{data?.data?.curiousCount}</CuriousTextWrapper> | ||
</CuriousTextWrapper> | ||
</CuriousBtnWrapper> | ||
</> | ||
|
@@ -63,6 +65,7 @@ const CuriousTextWrapper = styled.div` | |
|
||
const CuriousTextContainer = styled.div` | ||
display: flex; | ||
gap: 0.2rem; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
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
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.
P2) 네이밍컨벤션 지켜주세요~