-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FIX] 질문에 대한 도메인 용어를 question에서 content로 수정 #44
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import fetcher from './fetcher'; | ||
|
||
import { API_URL } from '@/constants/url'; | ||
import { BalanceContent } from '@/types/balanceContent'; | ||
|
||
export const fetchBalanceContent = async (roomId = 1): Promise<BalanceContent> => { | ||
const res = await fetcher.get({ url: API_URL.balanceContent(roomId) }); | ||
|
||
const data = await res.json(); | ||
|
||
return data; | ||
}; | ||
Comment on lines
+6
to
+12
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. L5 - 참고 의견일단 API가 나오지 않아서 roomId의 기본값을 1로 넣은 건가요? 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. 백엔드와 협의할 때 일단 1을 넣어 API 보내라고 해서 설정한 값입니다!!! |
||
|
||
export const voteBalanceContent = async (optionId: number, roomId = 1, contentId = 1) => { | ||
const res = await fetcher.post({ | ||
url: API_URL.vote(roomId, contentId), | ||
body: { | ||
memberId: 1, | ||
optionId, | ||
}, | ||
}); | ||
|
||
const data = await res.json(); | ||
|
||
return data; | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { layout, fontBold, voteContent } from './RoundVoteResult.styled'; | ||
|
||
import useQuestionQuery from '@/hooks/useQuestionQuery'; | ||
import useBalanceContentQuery from '@/hooks/useBalanceContentQuery'; | ||
|
||
const RoundVoteResult = () => { | ||
const { data: question } = useQuestionQuery(); | ||
const { balanceContent } = useBalanceContentQuery(); | ||
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. L5 - 참고 의견data를 question으로 받는 형식이 아닌 balanceContent로 변경한 이유가 무엇인가요? 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. useQuery를 그대로 반환하고, data는 사용처에서 적절하게 변수명 바꿔주는 게 확장성 측면에서 좋다고 생각하였습니다! |
||
|
||
return ( | ||
<div css={layout({ percentage: 72 })}> | ||
<div css={voteContent}> | ||
<div css={fontBold}>{question?.firstOption.content}</div> | ||
<div css={fontBold}>{balanceContent?.firstOption.name}</div> | ||
<div css={fontBold}>72%</div> | ||
</div> | ||
<span>vs</span> | ||
<div css={voteContent}> | ||
<div css={fontBold}>{question?.secondOption.content}</div> | ||
<div css={fontBold}>{balanceContent?.secondOption.name}</div> | ||
<div>28%</div> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const BASE_URL = process.env.NODE_ENV === 'production' ? process.env.API_BASE_URL : ''; | ||
|
||
export const API_URL = { | ||
question: (roomId: number) => `${BASE_URL}/api/balances/rooms/${roomId}/question`, | ||
vote: (roomId: number, questionId: number) => | ||
`${BASE_URL}/api/balances/rooms/${roomId}/questions/${questionId}/votes`, | ||
balanceContent: (roomId: number) => `${BASE_URL}/api/balances/rooms/${roomId}/content`, | ||
vote: (roomId: number, contentId: number) => | ||
`${BASE_URL}/api/balances/rooms/${roomId}/contents/${contentId}/votes`, | ||
}; | ||
|
||
export const MOCK_API_URL = { | ||
question: '/api/balances/rooms/:roomId/question', | ||
vote: '/api/balances/rooms/:roomId/questions/:questionId/votes', | ||
balanceContent: '/api/balances/rooms/:roomId/content', | ||
vote: '/api/balances/rooms/:roomId/contents/:contentId/votes', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { fetchBalanceContent } from '@/apis/balanceContent'; | ||
|
||
const useBalanceContentQuery = () => { | ||
const balanceContentQuery = useQuery({ | ||
queryKey: ['balanceContent'], | ||
queryFn: async () => await fetchBalanceContent(), | ||
}); | ||
|
||
return { ...balanceContentQuery, balanceContent: balanceContentQuery.data }; | ||
}; | ||
|
||
export default useBalanceContentQuery; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"contentId": 1, | ||
"category": "연애", | ||
"question": "당신의 결혼 상대는?", | ||
"firstOption": { | ||
"optionId": 1, | ||
"name": "100억 빚 송강" | ||
}, | ||
"secondOption": { | ||
"optionId": 2, | ||
"name": "100억 부자 송강호" | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
import BALANCE_CONTENT from '../data/balanceContent.json'; | ||
|
||
import { MOCK_API_URL } from '@/constants/url'; | ||
|
||
const fetchBalanceContentHandler = () => { | ||
return HttpResponse.json(BALANCE_CONTENT); | ||
}; | ||
|
||
export const contentHandler = [http.get(MOCK_API_URL.balanceContent, fetchBalanceContentHandler)]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { questionHandler } from './questionHandler'; | ||
import { contentHandler } from './balanceContentHandler'; | ||
import { voteHandler } from './voteHandler'; | ||
|
||
export const handlers = [...questionHandler, ...voteHandler]; | ||
export const handlers = [...contentHandler, ...voteHandler]; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
export interface Question { | ||
questionId: number; | ||
title: string; | ||
export interface BalanceContent { | ||
contentId: number; | ||
category: string; | ||
question: string; | ||
firstOption: { | ||
content: string; | ||
optionId: number; | ||
name: string; | ||
}; | ||
secondOption: { | ||
content: string; | ||
optionId: number; | ||
name: string; | ||
}; | ||
} |
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.
L5 - 참고 의견
쉘 스크립트의 함수랑 반복문은 사실 처음 봐서 대략 감으로 유추하자면
return 0 정상 동작이고 return 1이 나오면 비정상 동작으로 에러가 발생하는 함수인 것 같군요.
모든 경우의 브랜치 이름 확인하는 거 좋네요 ㅎㅎ
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.
지피티 참고하긴했는데, 기존 로직대로 추가하면 if문이 많아져서 나중에 브랜치 전략이 변경되어도 수정하기 편하도록 정규표현식으로 작성해보았습니다!!