Skip to content

Accommodation

SeongWoo Shin edited this page Aug 7, 2023 · 8 revisions

๐Ÿ“Œ ์ฃผ์š” ๊ธฐ๋Šฅ

โœ” ์ˆ™์†Œ ๋“ฑ๋ก ๋‹จ๊ณ„๋ณ„ ๊ณผ์ • ๊ตฌํ˜„

  • recoil๋กœ ๋‹จ๊ณ„๋ณ„ ํŽ˜์ด์ง€ ์ˆซ์ž ์ „์—ญ ์ƒํƒœ ๊ด€๋ฆฌ - page ์ปดํฌ๋„ŒํŠธ์—์„œ switch๋ฌธ์œผ๋กœ ๊ฐ page contents ์ปดํฌ๋„ŒํŠธ ๋ Œ๋”๋ง
  • ์ˆ™์†Œ ๋“ฑ๋ก ๊ณผ์ • ์‹œ๊ฐํ™”๋ฅผ ์œ„ํ•œ gauge bar - ์ „์—ญ์ƒํƒœ๊ฐ’(recoil)๊ณผ css transition, transform์„ ํ™œ์šฉ
  • ์ˆ™์†Œ ํƒ€์ž… radio button ํ˜•์‹์œผ๋กœ ๊ตฌํ˜„
  • ์ฃผ์†Œ ์ž๋™ ์™„์„ฑ - ๊ตฌ๊ธ€ Maps API์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ฐ์ฒด ๋ฐ ๋ฉ”์„œ๋“œ ํ™œ์šฉ(places๊ฐ์ฒด, AutocompleteService ๋ฉ”์„œ๋“œ), ์ „์—ญ ํƒ€์ž… ์„ ์–ธ
  • geolocation API์„ ํ™œ์šฉํ•˜์—ฌ ํ˜„์žฌ ์œ„์น˜ ์ •๋ณด ์–ป๊ธฐ
  • Kakao Map Web API๋ฅผ ํ™œ์šฉํ•˜์—ฌ ์œ„๋„ ๋ฐ ๊ฒฝ๋„์— ๋”ฐ๋ฅธ ์œ„์น˜ ์ง€๋„ ๊ตฌํ˜„
  • ์ˆ™์†Œ ํŽธ์˜์‹œ์„ค check box ํ˜•์‹์œผ๋กœ ๊ตฌํ˜„
  • ์ˆ™์†Œ ์‚ฌ์ง„ Drag & Drop ,click ์—…๋กœ๋“œ + ์˜ต์…˜ ๋ชจ๋‹ฌ๋กœ ์ˆ˜์ • ๋ฐ ์‚ญ์ œ ๊ตฌํ˜„
  • ์ˆ™์†Œ ์ด๋ฆ„, ์„ค๋ช… textarea ํ™œ์šฉ, ๊ธ€์ž ์ˆ˜ ์ œํ•œ
  • ๊ฐ์‹ค ๋“ฑ๋ก ๋ฐ ์‚ญ์ œ - ์‚ฌ์ง„ ์—…๋กœ๋“œ ๋ฐ ์‚ญ์ œ, ๊ฐ input value ์กฐ๊ฑด์„ ์ถ”๊ฐ€ํ•˜๊ณ  ๊ฐ์‹ค ๋ฐ์ดํ„ฐ ์ „์—ญ ์ƒํƒœ ๊ด€๋ฆฌ(recoil)
  • ์ˆ™์†Œ ๋“ฑ๋ก ์ „ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
  • ์™„๋ฃŒ ํŽ˜์ด์ง€ - react-router์˜ useNavigate hook์„ ํ™œ์šฉํ•œ ์ˆ™์†Œ๊ด€๋ฆฌํŽ˜์ด์ง€(Host)๋กœ ์ด๋™ ๋ฒ„ํŠผ ๊ตฌํ˜„ (footer button)

Code

Accommodation.tsx
export default function Accommodation() {
const stepNumber = useRecoilValue(stepState);

return (
  <StyledContainer>
    <AccommodationHeader />
    <StyledMain>
      {(() => {
        switch (stepNumber) {
          case 0:
            return <StartContents></StartContents>;
          case 1:
            return <StepStartContents step="ONE"></StepStartContents>;
          case 2:
            return <AccommodationTypeContents></AccommodationTypeContents>;
          case 3:
            return <AccommodationAddressContents></AccommodationAddressContents>;
          case 4:
            return <AccommodationAddressCheckContents></AccommodationAddressCheckContents>;
          case 5:
            return <StepStartContents step="TWO"></StepStartContents>;
          case 6:
            return <AccommodationAmenityInfoContents></AccommodationAmenityInfoContents>;
          case 7:
            return <AccommodationAddPictureContents></AccommodationAddPictureContents>;
          case 8:
            return <AccommodationNameContents></AccommodationNameContents>;
          case 9:
            return <AccommodationDetailContents></AccommodationDetailContents>;
          case 10:
            return <StepStartContents step="THR"></StepStartContents>;
          case 11:
            return <AccommodationRoomContents></AccommodationRoomContents>;
          case 12:
            return <StepStartContents step="FOR"></StepStartContents>;
          case 13:
            return <DetailStaticContents></DetailStaticContents>;
          case 14:
            return <AccommodationCompleteContents></AccommodationCompleteContents>;
          default:
            return null;
        }
      })()}
    </StyledMain>
    <AccommodationFooter />
  </StyledContainer>
);
}
StepBar.tsx
interface StepProps {
stepOne?: number;
stepTwo?: number;
stepThree?: number;
progress: number;
}

export default function StepBar() {
const gauge = useRecoilValue(stepGaugeSelector) as number[];

const [stepOne, setStepOne] = useState<number>(0);
const [stepTwo, setStepTwo] = useState<number>(0);
const [stepThree, setStepThree] = useState<number>(0);
const [stepFour, setStepFour] = useState<number>(0);

const progress = Math.floor((gauge[1] / gauge[2]) * 100);

useEffect(() => {
  if (gauge[0] === 1) {
    setStepOne(progress);
    setStepTwo(0);
    setStepThree(0);
    setStepFour(0);
  } else if (gauge[0] === 2) {
    setStepOne(100);
    setStepTwo(progress);
    setStepThree(0);
    setStepFour(0);
  } else if (gauge[0] === 3) {
    setStepOne(100);
    setStepTwo(100);
    setStepThree(progress);
    setStepFour(0);
  } else if (gauge[0] === 4) {
    setStepOne(100);
    setStepTwo(100);
    setStepThree(100);
    setStepFour(progress);
  }
}, [progress, gauge]);

return (
  <Container>
    <Step>
      <Progress stepOne={stepOne} progress={progress}></Progress>
    </Step>
    <Step>
      <Progress stepTwo={stepTwo} progress={progress}></Progress>
    </Step>
    <Step>
      <Progress stepThree={stepThree} progress={progress}></Progress>
    </Step>
    <Step>
      <Progress stepThree={stepFour} progress={progress}></Progress>
    </Step>
  </Container>
);
}

Clone this wiki locally