-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/#99 - refactor use survey #102
base: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
|
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.
๊ณ ์ํ์ จ์ด์! ์ฝ๋ ์ ๋ดค์ต๋๋ค! useFunnel ํ์ผ์์ Funnel ๋ณ์ ๋ง๋์ ๋ถ๋ถ์์ ์ค๋ ฅ์ด ๋ณด์ด๋ค์..๋๋ฐ
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.
Step1 - 4๊น์ง jsx๋ถ๋ถ์ด ์ค๋ณต์ด ๋ฉ๋๋ค..!
ํ๋์ ์ปดํฌ๋ํธ๋ก ๋ถ๋ฆฌํด์ ์ฌ์ฉํ์๋ฉด ๋ ๊ฐ๊ฒฐํด์ง ๊ฒ ๊ฐ์์
React.Fragment๋ฅผ ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์ผ์ ๊ฐ์?
์ด๋ฏธ motion.div์ ๋ชจ๋ ์์๊ฐ ๋ค์ด๊ฐ ์๋ ์ํ์ฌ์ ์ ์๊ฐ์๋ ๊ตณ์ด ์ฌ์ฉํ ํ์๊ฐ ์์ด๋ณด์ฌ์์!
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.
์ ๊ทธ ์ต์์ motion.div ์์ ๋ฒํผ์ด ๋ค์ด์์ง์์์ ํ๋ฒ ๋ฌถ์ด์ค <></> ํ๊ทธ๊ฐ ํ์ํด์ ์ฌ์ฉํ์ต๋๋ค
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.
์ ๋ ์ฌ์ค ๋๊ฐ์ UI๋ฅผ ๋ฐ๋ณตํด์ ์ด๋ค๋๊ฒ ๋ถํธํ๋ค๊ณ ์๊ฐํ์ต๋๋ค. ํ ์ค์ฒ๋ผ ๋ค์ํ UI๊ฐ ์ถ๊ฐ๋ ๊ฒ์๋๊ณ ..
๊ทผ๋ฐ ์ง๊ธ์ ์ ๊ฐ ์๊ฐํ์ ๋ ์ฌ์ฌ์ฉ์ฑ๋ณด๋ค๋ ์ข ๋จ๊ณ๋ง๋ค ๋ถ๋ฆฌํ๊ณ ๊ตฌ์กฐ๋ฅผ ํ ๋์ ๋ณด๋ฉด์ ํ์
ํ๋๊ฒ ์ค์ํ๋ค๊ณ ์๊ฐํด์ ์ด๋ ๊ฒ ๊ตฌํ์ ํ๊ฒ๋์์ต๋๋ค! ๋์ค์.. ๋ ํ๋ฒ ๊ณ ๋ ค๋ฅผํด๋ณผ๊ฒ์ฉ..ํํ
src/hooks/survey/useSurveyState.ts
Outdated
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.
type StepType = '์ฒซ๋ฒ์งธ' | '๋๋ฒ์งธ' | '์ธ๋ฒ์งธ' | '๋ค๋ฒ์งธ' | '์ค๋ฌธ๊ฒฐ๊ณผ';์ ๊ฐ์ด ๋ฌธ์์ด์ ์ ๋์ธ ํ์ ์ผ๋ก ์ ์ํ์ ์ด์ ๊ฐ ์์ผ์ ๊ฐ์?
step์ ๋ฐ๊พธ๋ if๋ฌธ์ด ๊ฝค ๋ณต์กํด์ง๋ ๊ฒ ๊ฐ๋ค์
์ซ์๋ก ๋ณ๊ฒฝํ๋ฉด handleNextStep ํจ์๋ ์๋์ ๊ฐ์ด ๊ฐ๋จํด์ง ๊ฒ ๊ฐ์์
if (currentStep < 4) {
setProgressStep(currentStep + 1);
setStep((currentStep + 1));
} else if (currentStep === 4) {
setProgressStep(5);
await new Promise(resolve => setTimeout(resolve, 700));
setStep(5);
setIsLoading(true);
...
}
handlePrevStep๋ ๋ง์ฐฌ๊ฐ์ง๊ตฌ์..!
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.
์ซ์๋ก ๋ฐ๊พธ๋ฉด ๋ก์ง์ด ๊ฐ๋จํด์ง๊ฒ ์ง๋ง ๋ฌธ์์ด๋ก ์ฌ์ฉํ ๋ ํ์ ์์ ์ฑ๋ ๋ณด์ฅ๋๊ณ ๋จ๊ณ๊ฐ ๋ช ํํ๊ฒ ๋ณด์ธ๋ค๋ ์ , ์ค๊ฐ์ ์ถ๊ฐํ๊ธฐ๋ ์ข๋ค๋ ์ ์์ ๋ฌธ์์ด์ ์ฌ์ฉํ์ต๋๋น!!
src/hooks/useFunnel.tsx
Outdated
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.
type StepProps<T> = {
children: React.ReactNode;
name: T;
};
type FunnelProps<T> = {
children: React.ReactElement<StepProps<T>>[] | React.ReactElement<StepProps<T>>;
};
์ ๋ถ๋ถ์ type ํค์๋๋ก ์ ์ํ์ ์ด์ ๊ฐ ๋ฌด์์ธ๊ฐ์?
๊ผญ ํ์ํ ๊ณณ์ด ์๋๋ฉด interface๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์ผ๊ด์ฑ์ ๋ ์ข์๋ณด์ฌ์!
const useFunnel = <T extends string>(initialStep: T)
16๋ผ์ธ์ string ๋ถ๋ถ์์
type StepType = '์ฒซ๋ฒ์งธ' | '๋๋ฒ์งธ' | '์ธ๋ฒ์งธ' | '๋ค๋ฒ์งธ' | '์ค๋ฌธ๊ฒฐ๊ณผ';
๋ฅผ ํ์ฉํ์๋ฉด ๋ ๊ฐ๋ ์ฑ์ด ์ข์์ง ๊ฒ ๊ฐ๋ค์
์ฝ์ผ์ จ๊ฒ ์ง๋ง string์ด ์๋๋ผ number๋ก ์ ์ํ์๊ณ ์ฌ์ฉํ์๋ฉด ๋ ๊ฐ๊ฒฐํ์ง ๊ฑฐ์์!
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.
StepProps๋ง๊ณ ๋ ์ ๋์จ ํ์ ๊ณผ, ํํ ํ์ ์ ์ฌ์ฉํ๋ฏ๋ก type์ ์ฌ์ฉํ์ต๋๋น.. StepProps๋ ๋จ์ํ ๊ฐ์ฒด ๊ตฌ์กฐ์ด๋ interface๋ก ์์ ํ๊ฒ์ต๋๋ค!!
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.
type importํด์ ์ฌ์ฉํ๋๋ก ์์ ํ์ต๋๋ค~
src/pages/survey/SurveyPage.tsx
Outdated
</motion.div> | ||
); | ||
const [Funnel, setStep, currentStep] = useFunnel< | ||
'์ฒซ๋ฒ์งธ' | '๋๋ฒ์งธ' | '์ธ๋ฒ์งธ' | '๋ค๋ฒ์งธ' | '์ค๋ฌธ๊ฒฐ๊ณผ' |
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.
์ด ๋ถ๋ถ๋ ๋ฐ๋ก ์ ์๋ฅผ ํด๋ type์ importํด์ ์ฌ์ฉํ๋๊ฒ ๋ ์ข์๋ณด์ฌ์! ์ฌ๋ฌ ๊ตฐ๋ฐ์ ํฉ์ด์ ธ์์ผ๋ฉด ๋์ค์ ์์ ์ฌํญ์ด ์๊ธฐ๋ฉด ์ฐพ๊ธฐ ํ๋ค์์์~~!
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.
์ค ์ข์ต๋๋ค ๋ฐ๋ก type์ผ๋ก ๋นผ์ ์ฌ์ฉํ๊ฒ ์ต๋๋น!!
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.
Step ์ปดํฌ๋ํธ์ ์ด๋ฏธ motion.div๋ก ์ ๋๋ฉ์ด์ ์ด ๋ค์ด๊ฐ์๋๋ฐ ๋ณธ๋ฌธ์์ ์ ๋๋ฉ์ด์ ์ ์ค๋ณตํด์ ๋ฃ์ผ์ ์ด์ ๊ฐ ์๋์?
๋ง์ฝ ์ค๋ณตํด์ ๋ฃ์ ์ด์ ๊ฐ ์๋ค๋ฉด ์ญ์ ํ๊ฑฐ๋ Step1 - 4๊ฐ ์ค๋ณต๋๋ฏ๋ก ์ ๊ฑฐํ๋ฉด ๊ฐ๋ ์ฑ์ ๋ ๋์์ด ๋ ๊ฒ ๊ฐ์์!
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.
ํ ๋ง๋ค์ ์ ๊ฐ ๊ฑ ๋ณต๋ถํ๋ฉด์ ์ฌ์ฉํ๋ ์ด์ ๋ฅผ ๊น๋จน์๊ฑฐ๊ฐ์ ์ page์ ์๋ motion.div๋ ์ญ์ ํ๊ฒ ์ต๋๋น..!
๐ ์์ ํ์ด์ง ๋ฐ ๋ด์ฉ ์์ฝ
useFunnel, useLoadingState, useSuveyState, useUserName์ด๋ผ๋ ์ปค์คํ ํ ์ ์์ฑํ๊ณ ๋ถ๋ฆฌํด์ ์ฌ์ฉํ์ต๋๋ค.
์์์์ step์ ๊ด๋ฆฌํ๊ณ Object.assign์ ํตํด Funnel ์์ Step์ด ์๋๋ก(์ข ์์ฑ์ด ์๋๋ก)ํ์ฌ
ํ ์ค์ ํจ๋ ํจํด์ ๊ตฌํํ๊ณ ์ ์ฉํด๋ดค์ต๋๋ค.
๐ ์ด์ ๋๋ฒ
๐ย ์์ ๋ด์ฉ
๐ธ ์คํฌ๋ฆฐ์ท(์ ํ)
๐ฌ๋ฆฌ๋ทฐ ์๊ตฌ์ฌํญ(์ ํ)