All files / src/components/pages/create-group/modals/location-search-modal index.tsx

0% Statements 0/35
0% Branches 0/1
0% Functions 0/1
0% Lines 0/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
'use client';

import DaumPostcodeEmbed, { Address } from 'react-daum-postcode';

import { AnyFieldApi } from '@tanstack/react-form';

import { ModalContent, ModalTitle, useModal } from '@/components/ui';

interface Props {
  LocationField: AnyFieldApi;
}

export const LocationSearchModal = ({ LocationField }: Props) => {
  const { close } = useModal();

  const handleComplete = (data: Address) => {
    const fullAddress = `${data.sido} ${data.sigungu} ${data.bname}`;
    LocationField.handleChange(fullAddress);
    close();
  };

  return (
    <ModalContent className='max-w-[330px]'>
      <ModalTitle>모임 장소</ModalTitle>
      <section className='mt-2'>
        <DaumPostcodeEmbed
          minWidth={200}
          style={{ height: '470px' }}
          autoClose={false}
          onComplete={handleComplete}
        />
      </section>
    </ModalContent>
  );
};