-
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
10주차 코드리뷰 #124
10주차 코드리뷰 #124
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 |
---|---|---|
@@ -1,26 +1 @@ | ||
# 🍪 내가 먹은 쿠키 - 18조 FE | ||
|
||
## 🙋♂️ 9주차 코드리뷰 질문 | ||
|
||
컴포넌트에는 개발하면서 페이지 내에서 임시로 만들어 사용하는 컴포넌트가 있고, 공통 컴포넌트로 개발해둔 것이 있고, 라이브러리에서 가져와서 사용하는 컴포넌트가 있습니다. 그런데 이런 컴포넌트를 필요에 따라 혼용해서 사용하니까 헷갈리기도 합니다. 이런 컴포넌트 사용에 있어서 지키면 좋을 규칙같은 게 있을까요? | ||
|
||
예를 들어 아래에서 Section은 제가 해당 컴포넌트 내에서만 사용하려고 만든 컴포넌트이고, Typo는 공통컴포넌트로 이전에 개발한 컴포넌트입니다. | ||
```tsx | ||
<Section> | ||
<Typo bold element="h3" size="20px" style={{ marginBottom: '24px' }}> | ||
내가 지원한 공고 | ||
</Typo> | ||
{myRecruitList && <MyRecruitList myRecruitList={myRecruitList} />} | ||
</Section> | ||
</InnerContainer> | ||
</Layout> | ||
); | ||
} | ||
|
||
const Section = styled.div` | ||
width: 100%; | ||
direction: column; | ||
align-items: center; | ||
margin-bottom: 52px; | ||
`; | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getDynamicAPIPath } from '@/apis/apiPath'; | ||
import { clientInstance } from '@/apis/instance'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
type IdProps = { | ||
resumeId: number; | ||
applyId: number; | ||
}; | ||
|
||
export const getProfileInfo = async ({ resumeId, applyId }: IdProps) => { | ||
const response = await clientInstance.get(getDynamicAPIPath.getApplicantProfile(resumeId, applyId)); | ||
return response.data; | ||
}; | ||
|
||
export const useGetProfileInfo = ({ resumeId, applyId }: IdProps) => | ||
useQuery({ | ||
queryKey: [getDynamicAPIPath.getApplicantProfile(resumeId, applyId)], | ||
queryFn: () => getProfileInfo({ resumeId, applyId }), | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { APIPath } from '@/apis/apiPath'; | ||
import { foreigner } from '@/features/applicants/ApplicantList/ContractModal/ContractModal.mock'; | ||
import { foreigner } from './foreigner.mock'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
export const foreignerMockHandler = [http.get(APIPath.getForeigner, () => HttpResponse.json(foreigner))]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { http, HttpResponse } from 'msw'; | ||
import { APIPath } from '@/apis/apiPath'; | ||
|
||
const mockData = { | ||
applicantName: '임세빈', | ||
address: '충남대학교', | ||
phoneNumber: '010-1111-1111', | ||
career: `카페에서 1년 알바했습니다. 클럽에서 30년 근무했습니다.`, | ||
koreanLanguageLevel: '고급', | ||
introduction: `맡은 업무에 항상 최선을 다하는 인재입니다. 안녕하세용안녕하세용안녕하세용안녕하세용안녕하세용안녕하세용`, | ||
motivation: '돈', | ||
}; | ||
|
||
export const getProfileInfoHandler = [ | ||
http.get(APIPath.getApplicantProfile, () => { | ||
return HttpResponse.json(mockData); | ||
}), | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { APIPath } from '@/apis/apiPath'; | ||
import { applicantList } from '@/pages/applicants/Applicants.mock'; | ||
import { applicantList } from './applicants.mock'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
export const myApplicantsMockHandler = [http.get(APIPath.getMyApplicants, () => HttpResponse.json(applicantList))]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { APIPath } from '@/apis/apiPath'; | ||
import { getDynamicAPIPath } from '@/apis/apiPath'; | ||
import { clientInstance } from '@/apis/instance'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
// import { useNavigate } from 'react-router-dom'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const getApply = () => `${APIPath.registerSign}`; | ||
export const getApply = (recruitmentId: number) => `${getDynamicAPIPath.apply(recruitmentId)}`; | ||
|
||
export const Apply = async ({ req, recruitmentId }: { req: string; recruitmentId: string }) => { | ||
const response = await clientInstance.post(`${getApply()}/${recruitmentId}`, req); | ||
export const Apply = async ({ req, recruitmentId }: { req: string; recruitmentId: number }) => { | ||
const response = await clientInstance.post(`${getApply(recruitmentId)}`, req); | ||
return response.data; | ||
}; | ||
|
||
export const FetchApply = () => { | ||
// const nav = useNavigate(); | ||
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. 이건 왜 대문자일까요... use가 붙어야하지 않을까요? |
||
const nav = useNavigate(); | ||
|
||
return useMutation({ | ||
mutationFn: ({ data, recruitmentId }: { data: string; recruitmentId: string }) => | ||
mutationFn: ({ data, recruitmentId }: { data: string; recruitmentId: number }) => | ||
Apply({ req: data, recruitmentId }), | ||
onSuccess: () => { | ||
// nav('/'); | ||
nav('/'); | ||
}, | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { clientInstance } from '@apis/instance'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { AxiosError } from 'axios'; | ||
import { OAuthRequest } from '../../types/request'; | ||
import { OAuthResponse } from '../../types/response'; | ||
import { APIPath } from '@/apis/apiPath'; | ||
|
||
const postOAuth = async ({ code }: OAuthRequest): Promise<OAuthResponse> => { | ||
const res = await clientInstance.post(APIPath.postOAuth, { code }); | ||
|
||
const authorizationHeader = res.headers['authorization']; | ||
const accessToken = authorizationHeader.replace('Bearer ', ''); | ||
|
||
if (!accessToken) { | ||
throw new Error('Authorization header is missing in the response'); | ||
} | ||
Comment on lines
+11
to
+16
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. 헤더에 Bearer로 전달해주네요..? 서버에서 그렇게 해주는걸까요? |
||
|
||
return { | ||
accessToken, | ||
type: res.data.type, | ||
profileImage: res.data.profileImage, | ||
name: res.data.name, | ||
}; | ||
}; | ||
|
||
export function useGoogleOAuthMutation() { | ||
return useMutation<OAuthResponse, AxiosError, OAuthRequest>({ | ||
mutationFn: postOAuth, | ||
}); | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export interface OAuthRequest { | ||
token: string; | ||
code: string; | ||
} | ||
|
||
export interface RegisterRequest { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { APIPath } from '@/apis/apiPath'; | ||
import { companyList } from '@/pages/myPage/employer/EmployerMyPage.mock'; | ||
import { companyList } from './myCompanies.mock'; | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
export const myCompaniesMockHandler = [http.get(APIPath.getMyCompanies, () => HttpResponse.json(companyList))]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getDynamicAPIPath } from '@/apis/apiPath'; | ||
import { clientInstance } from '@/apis/instance'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const getContractImgPath = (applyId: number) => `${getDynamicAPIPath.downloadContract(applyId)}`; | ||
const getContractImg = async (applyId: number) => { | ||
const res = await clientInstance.get(getContractImgPath(applyId)); | ||
return res.data; | ||
}; | ||
|
||
export const useGetContractImg = (applyId: number) => | ||
useQuery({ | ||
queryKey: [getContractImgPath], | ||
queryFn: () => getContractImg(applyId), | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { AxiosError } from 'axios'; | ||
import { RecruitmentResponse } from '../../types/response'; | ||
import { useSuspenseQuery, UseSuspenseQueryResult } from '@tanstack/react-query'; | ||
import { clientInstance } from '@apis/instance'; | ||
import { QUERY_KEYS } from './queryKeys'; | ||
import { getDynamicAPIPath } from '@/apis/apiPath'; | ||
|
||
const getRecruitments = async (filter: string, page: number): Promise<RecruitmentResponse[]> => { | ||
const url = `${getDynamicAPIPath.getRecruitments(filter)}?page=${page}`; | ||
const res = await clientInstance.get<RecruitmentResponse[]>(url); | ||
return res.data; | ||
}; | ||
|
||
export const useFetchRecruitments = ( | ||
filter: string, | ||
page: number, | ||
): UseSuspenseQueryResult<RecruitmentResponse[], AxiosError> => { | ||
return useSuspenseQuery<RecruitmentResponse[], AxiosError>({ | ||
queryKey: [QUERY_KEYS.RECRUITMENTS, filter, page], | ||
queryFn: () => getRecruitments(filter, page), | ||
}); | ||
}; |
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.
이 친구는 export 를 해주지 않아도 무방해보여요.