Skip to content

Commit

Permalink
feat: implement SearchList component
Browse files Browse the repository at this point in the history
  • Loading branch information
keemsebin committed Nov 19, 2024
1 parent 34892fb commit 430dca5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const ExtractedList = ({ places, onNext }: Props) => {
</div>
</div>
<ListCard>
{/* TODO 컴포넌트화 */}
{places.places.map((item, index) => (
<>
<div
Expand Down
63 changes: 63 additions & 0 deletions src/components/features/SearchList/SearchList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useState } from 'react';

import { Chip } from '@/components/common/Chip';
import { Icon } from '@/components/common/Icon';
import { ListCard } from '@/components/common/ListCard';
import { Body2, Body4 } from '@/components/common/Typography';
import { Place } from '@/types/naver';

import { Login } from '../LoginModal';

type Props = { places: Place[]; onNext: () => void };
export const SearchList = ({ places, onNext }: Props) => {
const [isOpen, setIsOpen] = useState<boolean>(false);
const [selectedPlace, setSelectedPlace] = useState<Place | null>(null);

const handleSelect = (place: Place) => {
setSelectedPlace((prev) => (prev === place ? null : place));
};

const handleSave = () => {
if (!selectedPlace) {
setIsOpen(true);
return;
}
onNext();
};
// TODO 추가 구현 필요
return (
<div className="flex flex-col gap-4">
<ListCard>
{/* TODO 컴포넌트화 */}
{places.map((item, index) => (
<>
<div
key={`${item.title}-${item.address}`}
className={`flex flex-row justify-between items-center ${index !== places.length - 1 && 'pb-2'}`}
>
<div className="flex flex-col gap-1 py-2">
<div className="flex flex-row gap-3 items-center">
<Body2 className="text-primary">{item.title}</Body2>
{typeof item.category === 'string' && (
<Chip variant="medium">{item.category}</Chip>
)}
</div>
<Body4 className="pt-1 " weight="normal">
{item.address}
</Body4>
</div>
<Icon
name="check"
className="cursor-pointer h-7"
color={selectedPlace === item ? 'primary' : 'gray'}
onClick={() => handleSelect(item)}
/>
</div>
{index < places.length - 1 && <hr className="border-dashed pt-2" />}
</>
))}
</ListCard>
<Login isOpen={isOpen} setIsOpen={setIsOpen} />
</div>
);
};

0 comments on commit 430dca5

Please sign in to comment.