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

[# 263] 주소 검색 결과 없을시 UI 수정 및 선택 UI 추가 #264

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/components/register/RegionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { useGetRegions } from '@/queries/useGetRegions.ts';
import { regions } from '@/mocks/mockDatas/regions.ts';
import { useCallback, useEffect, useState } from 'react';
import { debounce } from 'es-toolkit';
import { cn } from '@/utils.ts';

interface RegionListProps {
search: string;
selectedLocation: { id: number; name: string } | null;
onSelectLocation: (location: (typeof regions)[number]) => void;
}

export const RegionList = ({ onSelectLocation, search }: RegionListProps) => {
export const RegionList = ({ onSelectLocation, search, selectedLocation }: RegionListProps) => {
const [deferredSearch, setSearch] = useState(search);
const { data: locationList } = useGetRegions(deferredSearch);

Expand All @@ -24,9 +26,15 @@ export const RegionList = ({ onSelectLocation, search }: RegionListProps) => {

return (
<ul className={'h-full overflow-auto hide-scrollbar'}>
{locationList?.length === 0 && (
<li className={'py-4 text-regular-body font-medium text-Gray600'}>검색 결과가 없습니다.</li>
)}
{locationList.map((location) => (
<li
className={'py-4 text-regular-body text-Gray800 font-medium'}
className={cn(
'py-4 text-regular-body font-medium transition-colors',
selectedLocation?.id === location.id ? 'text-BloomingGreen500' : 'text-Gray800',
)}
key={`searched-location-list-${location.id}`}
onClick={() => onSelectLocation(location)}
>
Expand Down
7 changes: 5 additions & 2 deletions src/funnel/register/LocationFunnel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const LocationFunnel = ({ toNotificationTimeFunnel, goBack }: LocationFunnelProp

const onSelectLocation = (location: (typeof regions)[number]) => {
setSelectedLocation(location);
setSearch(location.name);
};

const changeSearchHandler = (e: ChangeEvent<HTMLInputElement>) => {
Expand Down Expand Up @@ -67,7 +66,11 @@ const LocationFunnel = ({ toNotificationTimeFunnel, goBack }: LocationFunnelProp
</div>
}
>
<RegionList search={search} onSelectLocation={onSelectLocation} />
<RegionList
selectedLocation={selectedLocation}
search={search}
onSelectLocation={onSelectLocation}
/>
</Suspense>
<CTAButton
text={'다음'}
Expand Down
Loading