-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from Kernel360/page-car-wash-details
페이지 UI: 세차 부가정보 페이지
- Loading branch information
Showing
13 changed files
with
206 additions
and
21 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,94 @@ | ||
/* eslint-disable @typescript-eslint/no-misused-promises */ | ||
|
||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { useForm } from 'react-hook-form'; | ||
|
||
import CarDetails from '@components/additional-info/car-details/CarDetails'; | ||
import DetailsLoading from '@components/additional-info/details-loading/DetailsLoading'; | ||
import useCarWashCost from '@remote/queries/additional-info/car-wash-details/useCarWashCost'; | ||
import useCarWashFrequency from '@remote/queries/additional-info/car-wash-details/useCarWashFrequency'; | ||
import useCarWashInterest from '@remote/queries/additional-info/car-wash-details/useCarWashInterest'; | ||
import Header from '@shared/header/Header'; | ||
import ProgressBar from '@shared/progress-bar/ProgressBar'; | ||
import Spacing from '@shared/spacing/Spacing'; | ||
|
||
function CarWashDetailsPage() { | ||
const { data: carWashFrequencyData } = useCarWashFrequency(); | ||
const { data: carWashCostData } = useCarWashCost(); | ||
const { data: carWashInterestData } = useCarWashInterest(); | ||
|
||
const [step, setStep] = useState(1); | ||
|
||
const { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
register, getValues, formState: { dirtyFields }, | ||
} = useForm(); | ||
|
||
const onNext = () => { | ||
setStep((currentStep) => { return currentStep + 1; }); | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
const onSubmit = async () => { | ||
onNext(); | ||
// TODO: 쿼리훅 제작 | ||
// console.log(getValues()); | ||
}; | ||
|
||
// TODO: Loader 컴포넌트 제작 | ||
if (carWashFrequencyData == null | ||
|| carWashCostData == null | ||
|| carWashInterestData == null | ||
) { | ||
return <div>로딩중 입니다..</div>; | ||
} | ||
|
||
return ( | ||
<> | ||
{step <= 3 && ( | ||
<> | ||
<Header isDisplayLogo={false} /> | ||
<Spacing size={16} /> | ||
<ProgressBar progressCount={3} currentStep={step} /> | ||
<Spacing size={32} /> | ||
</> | ||
)} | ||
{step === 1 && ( | ||
<CarDetails | ||
onClick={onNext} | ||
main="세차 빈도는 어떤가요?" | ||
sub="월 평균 세차 빈도를 선택해주세요." | ||
options={carWashFrequencyData} | ||
register={register} | ||
dirtyFields={dirtyFields} | ||
/> | ||
)} | ||
{step === 2 && ( | ||
<CarDetails | ||
onClick={onNext} | ||
main="지출하시는 세차 비용을 알려주세요" | ||
sub="용품 구매비용을 포함한 세차 비용을 선택해주세요." | ||
options={carWashCostData} | ||
register={register} | ||
dirtyFields={dirtyFields} | ||
/> | ||
)} | ||
{step === 3 && ( | ||
<CarDetails | ||
onClick={onSubmit} | ||
main="주요 관심사는 무엇인가요?" | ||
sub="주요 관심사를 선택해주세요." | ||
options={carWashInterestData} | ||
register={register} | ||
dirtyFields={dirtyFields} | ||
/> | ||
|
||
)} | ||
{step === 4 && <DetailsLoading />} | ||
</> | ||
); | ||
} | ||
|
||
export default CarWashDetailsPage; |
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,7 @@ | ||
function CarWashDetailsPageLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<div style={{ padding: '0 24px' }}>{children}</div> | ||
); | ||
} | ||
|
||
export default CarWashDetailsPageLayout; |
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 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
// app/hydratedPosts.jsx | ||
import { dehydrate, Hydrate } from '@tanstack/react-query'; | ||
|
||
import getQueryClient from '@lib/getQueryClient'; | ||
import { | ||
getCarWashFrequency, getCarWashCost, getCarWashInterest, | ||
} from '@remote/api/requests/additional-info/additional-info.get.api'; | ||
|
||
import CarWashDetailsPage from './hydrated-page'; | ||
|
||
const HydratedCarWashDetails = async () => { | ||
const queryClient = getQueryClient(); | ||
|
||
await Promise.all([ | ||
queryClient.prefetchQuery({ queryKey: ['car-wash-frequency'], queryFn: getCarWashFrequency }), | ||
queryClient.prefetchQuery({ queryKey: ['car-wash-cost'], queryFn: getCarWashCost }), | ||
queryClient.prefetchQuery({ queryKey: ['car-wash-interest'], queryFn: getCarWashInterest }), | ||
]); | ||
|
||
const dehydratedState = dehydrate(queryClient); | ||
|
||
return ( | ||
<Hydrate state={dehydratedState}> | ||
<CarWashDetailsPage /> | ||
</Hydrate> | ||
); | ||
}; | ||
|
||
export default HydratedCarWashDetails; |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.container { | ||
position: relative; | ||
width: 185px; | ||
height: 24px; | ||
margin: 0 auto; | ||
|
||
|
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
10 changes: 10 additions & 0 deletions
10
src/remote/queries/additional-info/car-wash-details/useCarWashCost.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,10 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { getCarWashCost } from '@remote/api/requests/additional-info/additional-info.get.api'; | ||
import { IAdditionalInfo } from '@remote/api/types/additional-info'; | ||
|
||
function useCarWashCost() { | ||
return useQuery<IAdditionalInfo[]>({ queryKey: ['car-wash-cost'], queryFn: getCarWashCost }); | ||
} | ||
|
||
export default useCarWashCost; |
10 changes: 10 additions & 0 deletions
10
src/remote/queries/additional-info/car-wash-details/useCarWashFrequency.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,10 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { getCarWashFrequency } from '@remote/api/requests/additional-info/additional-info.get.api'; | ||
import { IAdditionalInfo } from '@remote/api/types/additional-info'; | ||
|
||
function useCarWashFrequency() { | ||
return useQuery<IAdditionalInfo[]>({ queryKey: ['car-wash-frequency'], queryFn: getCarWashFrequency }); | ||
} | ||
|
||
export default useCarWashFrequency; |
10 changes: 10 additions & 0 deletions
10
src/remote/queries/additional-info/car-wash-details/useCarWashInterest.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,10 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { getCarWashInterest } from '@remote/api/requests/additional-info/additional-info.get.api'; | ||
import { IAdditionalInfo } from '@remote/api/types/additional-info'; | ||
|
||
function useCarWashInterest() { | ||
return useQuery<IAdditionalInfo[]>({ queryKey: ['car-wash-interest'], queryFn: getCarWashInterest }); | ||
} | ||
|
||
export default useCarWashInterest; |