-
Notifications
You must be signed in to change notification settings - Fork 1
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
리뷰 페이지 작성 #97
Merged
Merged
리뷰 페이지 작성 #97
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eae4bdc
리뷰 페이지 작성 중
YOOJS1205 5e54e85
리뷰 등록 쿼리 작성 및 리뷰 페이지 작성
YOOJS1205 aa77cf5
헤더 컴포넌트 header 태그로 변경
YOOJS1205 8493982
usePostLog mutationKey 수정
YOOJS1205 e2c0dea
제출 버튼 mutation 추가
YOOJS1205 99b0b9b
button disabled 조건 추가
YOOJS1205 b0ebe50
feature/#83, main 충돌 해결
YOOJS1205 3ac5766
경로 수정
YOOJS1205 2cfe390
Merge branch 'main' of https://github.com/depromeet/14th-team4-FE int…
YOOJS1205 b64872e
api hooks 경로 수정
YOOJS1205 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Header from '@components/common/Header'; | ||
|
||
interface ReviewLayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default function layout({ children }: ReviewLayoutProps) { | ||
return ( | ||
<div className="bg-gray-100"> | ||
<Header className="fixed top-0 bg-gray-100"> | ||
<p className="body-16-bold">로그 작성</p> | ||
</Header> | ||
<div className="px-[16px]">{children}</div> | ||
</div> | ||
); | ||
} |
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,55 @@ | ||
'use client'; | ||
|
||
import { useState, useCallback, ChangeEvent } from 'react'; | ||
|
||
import { usePostLog } from '@hooks/api/usePostLog'; | ||
import ImageUploader from '@components/review/ImageUploader'; | ||
import StarRating from '@components/review/StarRating'; | ||
import TextArea from '@components/review/TextArea'; | ||
import NavigationButton from '@components/terms/NavigationButton'; | ||
|
||
export default function Page({ params }: { params: { slug: string } }) { | ||
const { mutate: postLog } = usePostLog(); | ||
const [rating, setRating] = useState(0); | ||
const [description, setDescription] = useState(''); | ||
|
||
const storeId = params.slug; | ||
|
||
const handleRating = useCallback( | ||
(index: number) => () => { | ||
setRating(index + 1); | ||
}, | ||
[], | ||
); | ||
|
||
const handleChangeDescription = (e: ChangeEvent<HTMLTextAreaElement>) => { | ||
setDescription(e.target.value); | ||
}; | ||
|
||
const handleClickSubmitButton = () => { | ||
// TODO: 이미지 기능 구현 | ||
postLog({ storeId, rating, storeImgUrl: '', description }); | ||
}; | ||
|
||
return ( | ||
<div className="h-[100dvh] pt-[56px] pb-[104px] overflow-y-scroll"> | ||
<h1 className="header-22 py-[16px]"> | ||
가게 이름에 <br /> | ||
<strong className="text-primary-500">NN번째</strong> 방문이에요! | ||
</h1> | ||
<div className="flex flex-col py-[8px] gap-[16px]"> | ||
<StarRating rating={rating} onClick={handleRating} /> | ||
<ImageUploader /> | ||
<TextArea value={description} onChange={handleChangeDescription} /> | ||
</div> | ||
<NavigationButton | ||
className="bg-transparent fixed bottom-0 left-[50%] -translate-x-[50%]" | ||
// TODO: 추후 storeImgUrl 조건 추가 | ||
disabled={!rating || !description} | ||
onClick={handleClickSubmitButton} | ||
> | ||
작성완료 | ||
</NavigationButton> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
import { UseMutationResult, useMutation } from '@tanstack/react-query'; | ||
import { AxiosError } from 'axios'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
import { axiosRequest } from '../../api/api-config'; | ||
|
||
// TODO: api spec 확정되면 변경 | ||
interface Log { | ||
storeId: string; | ||
rating: number; | ||
storeImgUrl: string; | ||
description: string; | ||
} | ||
|
||
const postLog = ({ ...props }: Log): Promise<void> => { | ||
const body = { | ||
...props, | ||
}; | ||
return axiosRequest('post', `/endpoint`, body); | ||
}; | ||
|
||
export const usePostLog = (): UseMutationResult<void, AxiosError, Log> => { | ||
const { push } = useRouter(); | ||
return useMutation({ | ||
mutationKey: ['post-log'], | ||
mutationFn: ({ ...props }) => postLog({ ...props }), | ||
onSuccess: () => { | ||
// TODO: 확정되면 변경 | ||
push('/'); | ||
}, | ||
}); | ||
}; |
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.
여기는 나중에 서버에서 보내주는 가게 이름 데이터랑 방문 수 데이터로 대체할 예정이신걸까용?
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.
이거 서버랑 얘기해봐야해서... 아마 저희가 데이터 물고 페이지 넘어가야하지 않을까 싶어서 일단 뒀습니다...