import { useId } from 'react' import { ListPlus, Loader2 } from 'lucide-react' import ToggleSwitch from '../Settings/ToggleSwitch' import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell' import { EditorField, INPUT, Segmented } from '../shared/dialogParts' import type { SidebarState } from './usePlacesSidebar' type ListProvider = SidebarState['listImportProvider'] export function ListImportModal(S: SidebarState) { const { setListImportOpen, setListImportUrl, t, hasMultipleListImportProviders, availableListImportProviders, listImportProvider, setListImportProvider, listImportUrl, listImportLoading, handleListImport, listImportEnrich, setListImportEnrich, canEnrichImport, } = S const titleId = useId() const urlId = useId() const enrichHintId = useId() const close = () => { setListImportOpen(false); setListImportUrl('') } const google = listImportProvider === 'google' const cannotImport = !listImportUrl.trim() || listImportLoading const providerLabel = (provider: ListProvider) => provider === 'google' ? t('places.importGoogleList') : t('places.importNaverList') return ( } tint={NEUTRAL_TINT} labelId={titleId} onClose={close} title={t('places.importList')} /> )} footer={( {t('common.cancel')} : undefined} > {listImportLoading ? t('common.loading') : t('common.import')} )} > {hasMultipleListImportProviders && ( fill label={t('settings.aiParsing.provider')} value={listImportProvider} onChange={setListImportProvider} options={availableListImportProviders.map(provider => ({ value: provider, label: providerLabel(provider) }))} /> )} {t(google ? 'places.googleListHint' : 'places.naverListHint')} {/* Same box, same Share button: which screen the link came from is the URL's business, and until it said so nobody knew a route could be pasted here. */} {google && {t('places.googleDirHint')}} )} > setListImportUrl(e.target.value)} onKeyDown={e => { if (e.key === 'Enter' && !listImportLoading) void handleListImport() }} placeholder={google ? 'https://maps.app.goo.gl/...' : 'https://naver.me/...'} autoFocus className={INPUT} /> {canEnrichImport && (
{t('places.enrichOnImport')}
{t('places.enrichOnImportHint')}
setListImportEnrich(!listImportEnrich)} label={t('places.enrichOnImport')} describedBy={enrichHintId} />
)}
) }