여러 줄 주석이 설명보다 경위(예전·실측·지적)를 적고 있어 읽는 사람이 결론을 찾기 어려웠다. - ts·tsx·js·mjs·css·py 478개: 여러 줄 주석은 첫 문장 한 줄로, 과거형·날짜 문장은 삭제 - 주석 위치는 TypeScript 파서·파이썬 tokenize/ast 로 찾는다 — 문자열 안의 # · /* 는 건드리지 않는다 - eslint·ts·noqa·type: ignore 같은 지시 주석은 그대로 둔다 파이썬 275개 정리 전후 AST 동일, TS 298개 주석 뺀 토큰 동일(빈 JSX 주석 10곳만 차이). site·frontend·admin tsc, site vitest 105 passed Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
106 lines
3.3 KiB
TypeScript
106 lines
3.3 KiB
TypeScript
import {ExternalLink, Link2, Loader2, MapPin} from 'lucide-react';
|
|
import {Button} from '@/components/ui/button';
|
|
import {Input} from '@/components/ui/input';
|
|
import {cn} from '@/lib/utils';
|
|
|
|
/** 자동 상호 검색이 실패했을 때 네이버 지도에서 직접 찾아 URL로 확정하는 fallback. */
|
|
export function PlaceUrlBox({
|
|
value,
|
|
onChange,
|
|
onSubmit,
|
|
isBusy,
|
|
compact,
|
|
searchQuery,
|
|
}: {
|
|
value: string;
|
|
onChange: (next: string) => void;
|
|
onSubmit: () => void;
|
|
isBusy?: boolean;
|
|
/** 후보 목록 아래에 놓일 때는 설명을 줄인다. */
|
|
compact?: boolean;
|
|
/** 자동 검색 실패 시 네이버 지도를 이 검색어로 바로 연다. */
|
|
searchQuery?: string;
|
|
}) {
|
|
const isNaverUrl = /naver\.(com|me)/i.test(value);
|
|
const mapSearchUrl = searchQuery?.trim()
|
|
? `https://map.naver.com/p/search/${encodeURIComponent(searchQuery.trim())}`
|
|
: 'https://map.naver.com/';
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'rounded-2xl border bg-card p-5',
|
|
compact ? 'border-border' : 'border-primary/40 ring-2 ring-primary/10',
|
|
)}
|
|
>
|
|
<p className="flex items-center gap-1.5 text-sm font-bold">
|
|
<MapPin className="size-4 text-primary" />
|
|
네이버 플레이스에서 직접 찾기
|
|
{!compact && (
|
|
<span className="rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary">
|
|
가장 정확
|
|
</span>
|
|
)}
|
|
</p>
|
|
|
|
{!compact && (
|
|
<>
|
|
<p className="mt-2 text-[11px] leading-relaxed text-muted-foreground">
|
|
자동 검색에서 찾지 못했습니다. 네이버 지도에서 내 가게를 연 뒤 [공유] 주소를
|
|
복사해 아래에 붙여넣어 주세요.
|
|
</p>
|
|
</>
|
|
)}
|
|
|
|
<a
|
|
href={mapSearchUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
className="mt-3 flex w-full items-center justify-center gap-1.5 rounded-lg border border-border bg-background px-3 py-2 text-xs font-semibold transition-colors hover:bg-accent"
|
|
>
|
|
<ExternalLink className="size-3.5" />
|
|
<span>
|
|
네이버 지도에서{' '}
|
|
{searchQuery?.trim()
|
|
? `'${searchQuery.trim()}' 검색`
|
|
: compact
|
|
? '이 상호 다시 찾기'
|
|
: '검색'}
|
|
</span>
|
|
</a>
|
|
|
|
<div className="mt-3 flex items-center gap-1.5">
|
|
<Input
|
|
value={value}
|
|
onChange={(e) => onChange(e.target.value)}
|
|
onKeyDown={(e) => {
|
|
if (e.key === 'Enter' && value.trim()) onSubmit();
|
|
}}
|
|
placeholder="https://map.naver.com/p/entry/place/1133638931"
|
|
disabled={isBusy}
|
|
/>
|
|
<Button
|
|
variant="primary"
|
|
onClick={onSubmit}
|
|
disabled={isBusy || !value.trim()}
|
|
className="shrink-0"
|
|
>
|
|
{isBusy ? <Loader2 className="animate-spin" /> : <Link2 />}
|
|
<span>확인</span>
|
|
</Button>
|
|
</div>
|
|
|
|
<p
|
|
className={cn(
|
|
'mt-1.5 text-[11px]',
|
|
value.trim() && !isNaverUrl ? 'text-destructive' : 'text-muted-foreground',
|
|
)}
|
|
>
|
|
{value.trim() && !isNaverUrl
|
|
? '네이버 지도·플레이스 주소를 붙여넣어 주세요.'
|
|
: 'map.naver.com · m.place.naver.com · naver.me 주소를 지원합니다.'}
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|