Skip to content
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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

yookeunbyul
Copy link
Collaborator

๐Ÿ“„ ์ž‘์—… ํŽ˜์ด์ง€ ๋ฐ ๋‚ด์šฉ ์š”์•ฝ

ex) ๋ฉ”์ธํŽ˜์ด์ง€ - ๋ผ์šฐํŠธ ์—ฐ๊ฒฐ

useFunnel, useLoadingState, useSuveyState, useUserName์ด๋ผ๋Š” ์ปค์Šคํ…€ํ›…์„ ์ƒ์„ฑํ•˜๊ณ  ๋ถ„๋ฆฌํ•ด์„œ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
์ƒ์œ„์—์„œ step์„ ๊ด€๋ฆฌํ•˜๊ณ  Object.assign์„ ํ†ตํ•ด Funnel ์•ˆ์— Step์ด ์žˆ๋„๋ก(์ข…์†์„ฑ์ด ์žˆ๋„๋ก)ํ•˜์—ฌ
ํ† ์Šค์˜ ํŒจ๋„ ํŒจํ„ด์„ ๊ตฌํ˜„ํ•˜๊ณ  ์ ์šฉํ•ด๋ดค์Šต๋‹ˆ๋‹ค.

๐Ÿ“Œ ์ด์Šˆ ๋„˜๋ฒ„

ex) #์ด์Šˆ๋ฒˆํ˜ธ, #์ด์Šˆ๋ฒˆํ˜ธ

๐Ÿ“ย ์ž‘์—… ๋‚ด์šฉ

๐Ÿ“ธ ์Šคํฌ๋ฆฐ์ƒท(์„ ํƒ)

๐Ÿ’ฌ๋ฆฌ๋ทฐ ์š”๊ตฌ์‚ฌํ•ญ(์„ ํƒ)

๋ฆฌ๋ทฐ์–ด๊ฐ€ ํŠน๋ณ„ํžˆ ๋ด์ฃผ์—ˆ์œผ๋ฉด ํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”

ex) ๋ฉ”์„œ๋“œ XXX์˜ ์ด๋ฆ„์„ ๋” ์ž˜ ์ง“๊ณ  ์‹ถ์€๋ฐ ํ˜น์‹œ ์ข‹์€ ๋ช…์นญ์ด ์žˆ์„๊นŒ์š”?

@yookeunbyul yookeunbyul added the ๐Ÿ”จ Refactor ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง label Jan 25, 2025
@yookeunbyul yookeunbyul self-assigned this Jan 25, 2025
Copy link

vercel bot commented Jan 25, 2025

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Updated (UTC)
web-1-1-do-it-together-fe โœ… Ready (Inspect) Visit Preview Jan 26, 2025 6:49am

Copy link
Owner

@Eugeeun Eugeeun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ณ ์ƒํ•˜์…จ์–ด์š”! ์ฝ”๋“œ ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค! useFunnel ํŒŒ์ผ์—์„œ Funnel ๋ณ€์ˆ˜ ๋งŒ๋“œ์‹  ๋ถ€๋ถ„์—์„œ ์‹ค๋ ฅ์ด ๋ณด์ด๋„ค์š”..๋Œ€๋ฐ•

Copy link
Owner

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์— ๋ชจ๋“  ์š”์†Œ๊ฐ€ ๋“ค์–ด๊ฐ€ ์žˆ๋Š” ์ƒํƒœ์—ฌ์„œ ์ œ ์ƒ๊ฐ์—๋Š” ๊ตณ์ด ์‚ฌ์šฉํ•  ํ•„์š”๊ฐ€ ์—†์–ด๋ณด์—ฌ์„œ์š”!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ ๊ทธ ์ตœ์ƒ์œ„ motion.div ์•ˆ์— ๋ฒ„ํŠผ์ด ๋“ค์–ด์žˆ์ง€์•Š์•„์„œ ํ•œ๋ฒˆ ๋ฌถ์–ด์ค„ <></> ํƒœ๊ทธ๊ฐ€ ํ•„์š”ํ•ด์„œ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋„ ์‚ฌ์‹ค ๋˜‘๊ฐ™์€ UI๋ฅผ ๋ฐ˜๋ณตํ•ด์„œ ์“ด๋‹ค๋Š”๊ฒŒ ๋ถˆํŽธํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ํ† ์Šค์ฒ˜๋Ÿผ ๋‹ค์–‘ํ•œ UI๊ฐ€ ์ถ”๊ฐ€๋  ๊ฒƒ์•„๋‹ˆ๊ณ ..
๊ทผ๋ฐ ์ง€๊ธˆ์€ ์ œ๊ฐ€ ์ƒ๊ฐํ–ˆ์„ ๋• ์žฌ์‚ฌ์šฉ์„ฑ๋ณด๋‹ค๋Š” ์ข€ ๋‹จ๊ณ„๋งˆ๋‹ค ๋ถ„๋ฆฌํ•˜๊ณ  ๊ตฌ์กฐ๋ฅผ ํ•œ ๋ˆˆ์— ๋ณด๋ฉด์„œ ํŒŒ์•…ํ•˜๋Š”๊ฒŒ ์ค‘์š”ํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•ด์„œ ์ด๋ ‡๊ฒŒ ๊ตฌํ˜„์„ ํ•˜๊ฒŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! ๋‚˜์ค‘์—.. ๋˜ ํ•œ๋ฒˆ ๊ณ ๋ ค๋ฅผํ•ด๋ณผ๊ฒŒ์šฉ..ํ•˜ํ•˜

Copy link
Owner

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๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๊ตฌ์š”..!

Copy link
Collaborator Author

@yookeunbyul yookeunbyul Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆซ์ž๋กœ ๋ฐ”๊พธ๋ฉด ๋กœ์ง์ด ๊ฐ„๋‹จํ•ด์ง€๊ฒ ์ง€๋งŒ ๋ฌธ์ž์—ด๋กœ ์‚ฌ์šฉํ•  ๋•Œ ํƒ€์ž… ์•ˆ์ •์„ฑ๋„ ๋ณด์žฅ๋˜๊ณ  ๋‹จ๊ณ„๊ฐ€ ๋ช…ํ™•ํ•˜๊ฒŒ ๋ณด์ธ๋‹ค๋Š” ์ , ์ค‘๊ฐ„์— ์ถ”๊ฐ€ํ•˜๊ธฐ๋„ ์ข‹๋‹ค๋Š” ์ ์—์„œ ๋ฌธ์ž์—ด์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹น!!

Copy link
Owner

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๋กœ ์ •์˜ํ•˜์‹œ๊ณ  ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋” ๊ฐ„๊ฒฐํ•˜์งˆ ๊ฑฐ์—์š”!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StepProps๋ง๊ณ ๋Š” ์œ ๋‹ˆ์˜จ ํƒ€์ž…๊ณผ, ํŠœํ”Œ ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ type์„ ์‚ฌ์šฉํ–‡์Šต๋‹ˆ๋‹น.. StepProps๋Š” ๋‹จ์ˆœํ•œ ๊ฐ์ฒด ๊ตฌ์กฐ์ด๋‹ˆ interface๋กœ ์ˆ˜์ •ํ•˜๊ฒŸ์Šต๋‹ˆ๋‹ค!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type importํ•ด์„œ ์‚ฌ์šฉํ•˜๋„๋ก ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค~

</motion.div>
);
const [Funnel, setStep, currentStep] = useFunnel<
'์ฒซ๋ฒˆ์งธ' | '๋‘๋ฒˆ์งธ' | '์„ธ๋ฒˆ์งธ' | '๋„ค๋ฒˆ์งธ' | '์„ค๋ฌธ๊ฒฐ๊ณผ'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„๋„ ๋”ฐ๋กœ ์ •์˜๋ฅผ ํ•ด๋‘” type์„ importํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ๋” ์ข‹์•„๋ณด์—ฌ์š”! ์—ฌ๋Ÿฌ ๊ตฐ๋ฐ์— ํฉ์–ด์ ธ์žˆ์œผ๋ฉด ๋‚˜์ค‘์— ์ˆ˜์ •์‚ฌํ•ญ์ด ์ƒ๊ธฐ๋ฉด ์ฐพ๊ธฐ ํž˜๋“ค์ž–์•„์š”~~!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜ค ์ข‹์Šต๋‹ˆ๋‹ค ๋”ฐ๋กœ type์œผ๋กœ ๋นผ์„œ ์‚ฌ์šฉํ•˜๊ฒ ์Šต๋‹ˆ๋‹น!!

Copy link
Owner

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๊ฐ€ ์ค‘๋ณต๋˜๋ฏ€๋กœ ์ œ๊ฑฐํ•˜๋ฉด ๊ฐ€๋…์„ฑ์— ๋” ๋„์›€์ด ๋  ๊ฒƒ ๊ฐ™์•„์š”!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ— ๋งž๋„ค์š” ์ œ๊ฐ€ ๊ฑ ๋ณต๋ถ™ํ•˜๋ฉด์„œ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋ฅผ ๊นŒ๋จน์€๊ฑฐ๊ฐ™์• ์š” page์— ์žˆ๋Š” motion.div๋Š” ์‚ญ์ œํ•˜๊ฒ ์Šต๋‹ˆ๋‹น..!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
๐Ÿ”จ Refactor ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants