-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
10주차 코드리뷰
- Loading branch information
Showing
170 changed files
with
3,231 additions
and
2,736 deletions.
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 |
---|---|---|
@@ -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.
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
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 }), | ||
}); |
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
File renamed without changes.
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,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))]; |
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,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); | ||
}), | ||
]; |
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,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))]; |
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,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(); | ||
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('/'); | ||
}, | ||
}); | ||
}; |
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,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'); | ||
} | ||
|
||
return { | ||
accessToken, | ||
type: res.data.type, | ||
profileImage: res.data.profileImage, | ||
name: res.data.name, | ||
}; | ||
}; | ||
|
||
export function useGoogleOAuthMutation() { | ||
return useMutation<OAuthResponse, AxiosError, OAuthRequest>({ | ||
mutationFn: postOAuth, | ||
}); | ||
} |
10 changes: 5 additions & 5 deletions
10
src/apis/auth/mutations/useRegister.tsx → ...h/hooks/mutations/useRegisterMutation.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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export interface OAuthRequest { | ||
token: string; | ||
code: string; | ||
} | ||
|
||
export interface RegisterRequest { | ||
|
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
File renamed without changes.
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,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))]; |
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,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), | ||
}); |
File renamed without changes.
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,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), | ||
}); | ||
}; |
Oops, something went wrong.