-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ Feat ] 온보딩 페이지 Mocking API를 연동합니다 (#250)
* feat: 온보딩 mock api 생성 (#249) * feat: url의 이름을 받아오는 api 함수 작성 (#249) * feat: 온보딩 api 함수 작성 (#249) * feat: 온보딩 페이지에서 필요한 상수 정의 (#249) * feat: 리다이렉트 페이지 컴포넌트명 및 리다이렉트 경로 수정 * feat: useFunnel 쿼리 파라미터 없을 경우 처리 코드 추가 * feat: 가독성을 위해서 BoxAllowedService 네이밍 수정 및 컴파운드 컴포넌트 방식으로 수정 (#249) * feat: favicon 받아오는 유틸 함수 추가 (#249) * feat: 온보딩 최상위페이지 타입 수정 및 Service Step에서 현재 선택된 분야를 받을 수 있게 prop 추가 (#249) * feat: 분야 별로 제공하는 서비스를 선택할 수 있는 ButtonService 컴포넌트 로직 추가 (#249) * feat: 통일성을 위해 Tabs Object.assign 방식으로 수정 (#249) * feat: 분야 선택 스탭, 허용 서비스 선택 스탭 api 로직 추가 (#249)
- Loading branch information
1 parent
b8ad72a
commit d1602ad
Showing
27 changed files
with
570 additions
and
163 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HttpResponse, http } from 'msw'; | ||
|
||
import { COMMON_RES } from './common.responses'; | ||
|
||
export const COMMON_MOCK_URL = { | ||
GET_URL_NAME: 'api/v2/tabName', | ||
}; | ||
|
||
export const commonResolvers = [ | ||
http.get(COMMON_MOCK_URL.GET_URL_NAME, async ({ request }) => { | ||
const url = new URL(request.url); | ||
const tabName = url.searchParams.get('tabName'); | ||
|
||
if (!tabName) { | ||
console.error('경로 파라미터에 tabName이 없습니다.'); | ||
throw new HttpResponse(null, { status: 400 }); | ||
} | ||
|
||
return HttpResponse.json(COMMON_RES.GET_URL_NAME); | ||
}), | ||
]; |
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,9 @@ | ||
export const COMMON_RES = { | ||
GET_URL_NAME: { | ||
status: 200, | ||
message: '요청이 성공했습니다.', | ||
data: { | ||
tabName: 'NAVER', | ||
}, | ||
}, | ||
}; |
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,3 +1,5 @@ | ||
import { commonResolvers } from './common/common.resolvers'; | ||
import { homeResolvers } from './home/resolvers/homeResolvers'; | ||
import { onboardingResolvers } from './onboarding/onboarding.resolvers'; | ||
|
||
export const handlers = [...homeResolvers]; | ||
export const handlers = [...homeResolvers, ...onboardingResolvers, ...commonResolvers]; |
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,31 @@ | ||
import { HttpResponse, http } from 'msw'; | ||
|
||
import { ONBOARDING_RES } from './onboarding.responses'; | ||
|
||
export const ONBOARDING_MOCK_URL = { | ||
POST_INTEREST_AREA: 'api/v2/onboard', | ||
}; | ||
|
||
export const onboardingResolvers = [ | ||
http.post<never, { siteName: string; siteUrl: string }[]>( | ||
ONBOARDING_MOCK_URL.POST_INTEREST_AREA, | ||
async ({ request }) => { | ||
const url = new URL(request.url); | ||
const interestArea = url.searchParams.get('interestArea'); | ||
|
||
const body = await request.json(); | ||
|
||
if (body.length === 0) return HttpResponse.json(ONBOARDING_RES.POST_INTEREST_AREA); | ||
|
||
if ( | ||
!(body.length > 0 && (typeof body[0].siteName === 'string' || typeof body[0].siteUrl === 'string')) || | ||
!interestArea | ||
) { | ||
console.error('요청 바디 값과, 쿼리스트링 값을 확인해주세요'); | ||
throw new HttpResponse(null, { status: 400 }); | ||
} | ||
|
||
return HttpResponse.json(ONBOARDING_RES.POST_INTEREST_AREA); | ||
}, | ||
), | ||
]; |
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,6 @@ | ||
export const ONBOARDING_RES = { | ||
POST_INTEREST_AREA: { | ||
status: 200, | ||
message: '요청이 성공했습니다.', | ||
}, | ||
}; |
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
87 changes: 87 additions & 0 deletions
87
src/pages/OnboardingPage/StepService/AllowedServices/AllowedServices.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { ButtonHTMLAttributes, ReactNode } from 'react'; | ||
|
||
import HomeLargeBtn from '@/shared/components/ButtonHomeLarge/ButtonHomeLarge'; | ||
|
||
import { HomeLargeBtnVariant } from '@/shared/types/global'; | ||
|
||
import ColorIcon from '@/shared/assets/svgs/ic_color.svg?react'; | ||
import MinusIcon from '@/shared/assets/svgs/ic_minus.svg?react'; | ||
import PencilIcon from '@/shared/assets/svgs/ic_pencil.svg?react'; | ||
|
||
import { getServiceFavicon } from '../../utils/serviceUrl'; | ||
|
||
interface AllowedServicesRootProps { | ||
children: ReactNode; | ||
} | ||
|
||
const AllowedServicesRoot = ({ children }: AllowedServicesRootProps) => { | ||
return ( | ||
<div className="flex h-screen w-[48.7rem] flex-shrink-0 pb-[4.8rem] pr-[4.2rem] pt-[11.8rem]"> | ||
<div className="grid w-full grid-rows-[auto,1fr,auto] rounded-[18px] bg-gray-bg-03 p-[2.8rem]">{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const AllowedServiceHeader = () => { | ||
return ( | ||
<div className="flex items-center"> | ||
<button> | ||
<ColorIcon /> | ||
</button> | ||
<h2 className="ml-[1rem] text-white head-bold-30">나의 허용서비스</h2> | ||
<button className="ml-[1.7rem]"> | ||
<PencilIcon /> | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
interface AllowedServiceListProps { | ||
children: ReactNode; | ||
} | ||
|
||
const AllowedServiceList = ({ children }: AllowedServiceListProps) => { | ||
return <ul className="mt-[2rem] overflow-auto">{children}</ul>; | ||
}; | ||
|
||
interface AllowedServiceItemProps { | ||
siteUrl: string; | ||
siteName: string; | ||
onClick: (url: string) => void; | ||
} | ||
|
||
const AllowedServiceItem = ({ siteUrl, siteName, onClick }: AllowedServiceItemProps) => { | ||
return ( | ||
<li className="flex h-[5.4rem] w-full items-center border-b border-b-gray-bg-04 px-[1rem] py-[1.2rem]"> | ||
<img src={getServiceFavicon(siteUrl)} alt={`${siteName} 아이콘`} className="h-[2rem] w-[2rem]" /> | ||
<h3 className="ml-[1.2rem] p-0 text-white body-med-16">{siteName}</h3> | ||
<div className="ml-[4.2rem] h-[3.1rem] w-[23.1rem] truncate rounded-[20px] bg-gray-bg-04 px-[1rem] py-[0.6rem] text-gray-04 body-reg-16"> | ||
{siteUrl} | ||
</div> | ||
<button | ||
onClick={() => { | ||
onClick(siteUrl); | ||
}} | ||
> | ||
<MinusIcon className="ml-[1.25rem]" /> | ||
</button> | ||
</li> | ||
); | ||
}; | ||
|
||
const AllowedServiceBottomButton = (props: ButtonHTMLAttributes<HTMLButtonElement>) => { | ||
return ( | ||
<HomeLargeBtn variant={HomeLargeBtnVariant.MIDDLE} className="mt-[2rem]" {...props}> | ||
{props.children} | ||
</HomeLargeBtn> | ||
); | ||
}; | ||
|
||
const AllowedService = Object.assign(AllowedServicesRoot, { | ||
Header: AllowedServiceHeader, | ||
List: AllowedServiceList, | ||
Item: AllowedServiceItem, | ||
BottomButton: AllowedServiceBottomButton, | ||
}); | ||
|
||
export default AllowedService; |
68 changes: 0 additions & 68 deletions
68
src/pages/OnboardingPage/StepService/BoxAllowedService/BoxAllowedService.tsx
This file was deleted.
Oops, something went wrong.
14 changes: 8 additions & 6 deletions
14
src/pages/OnboardingPage/StepService/ButtonService/ButtonService.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
Oops, something went wrong.