import { useState } from 'react' import { Check, ChevronRight, Library, X } from 'lucide-react' import TrekMark from '../../../components/shared/TrekMark' import { TREK_API_SOURCES as SOURCES, trekApiFacts, trekApiFields } from '../../../components/Admin/trekApiModel' import { useTranslation } from '../../../i18n' /** * The API-keys card's two building blocks, in the phone's own material. * * The desktop tab was rebuilt around one idea: a key should be the exception * rather than the thing you are expected to paste. The TREK Places API leads, * the paid providers follow as comparable blocks, and the "recommended" mark * belongs to the free option instead of to the Google field. The phone still * had the older shape, where Google wore the recommendation and TREK was not on * the screen at all, which is the opposite advice on the same setting. * * Rebuilt rather than shared with the desktop component: every surface, radius * and type size here comes from the mobile tokens, and the desktop card is a * two-column layout with a hover-revealed disclosure. What is shared is the * wording, key for key, so the two pages cannot drift in what they claim. */ const chip = 'rounded-full border border-[color:var(--m-rowbr)] px-2 py-[2px] font-geist text-[0.625rem]' /** One group of chips inside the disclosure: what you get, what you do not, where it comes from. */ function ChipGroup({ icon, label, items, note, dashed = false, }: { icon: React.ReactNode label: string items: string[] note: string dashed?: boolean }) { return (

{icon} {label}

{note}

) } /** The TREK Places API, above the paid keys because it is the alternative to them. */ export function MTrekApiBlock() { const { t } = useTranslation() const [open, setOpen] = useState(false) const facts = trekApiFacts(t) // The same fields the desktop card lists, reusing words TREK already has. const fields = trekApiFields(t) return (
{/* The recommendation sits on the border, as on the desktop card, and small: a wide coloured banner would shout over the settings beside it. */} {t('admin.trekApi.badgeDefault')}

{t('admin.trekApi.tagline')}

    {facts.map(({ Icon, text }) => (
  • {text}
  • ))}
{/* A button rather than
: the phone shell styles its own disclosures and Safari draws a marker on the summary that no reset reaches reliably. */} {open && (
} label={t('admin.trekApi.included')} items={fields} note={t('admin.trekApi.includedNote')} /> } label={t('admin.trekApi.notIncluded')} items={[t('admin.trekApi.notRatings'), t('admin.trekApi.notPhotos')]} note={t('admin.trekApi.notIncludedNote')} dashed /> } label={t('admin.trekApi.sourcesLabel')} items={SOURCES} note={t('admin.trekApi.sourcesNote')} />
)}
) } /** * A folded group of settings that belong to the block above them. * * Closed to begin with, and on purpose: the four Google switches are set once * when a key is pasted and never touched again, and open they were longer than * everything else on the card put together. */ export function MBlockDisclosure({ label, children }: { label: string; children: React.ReactNode }) { const [open, setOpen] = useState(false) return (
{open &&
{children}
}
) } /** * One paid provider, in the same shape as the TREK block above it, so the card * reads as a list of comparable options rather than one highlighted thing with * loose fields underneath. */ export function MProviderBlock({ title, badge, tone = 'muted', children, }: { title: string badge?: string /** `caution` marks a provider that costs something other than money. Never `danger`: using a key is a legitimate choice. */ tone?: 'muted' | 'caution' children: React.ReactNode }) { return ( // The ribbon rides on the top border, so the block needs room above it or the // capitals touch whatever ends the block before.
{badge && ( {badge} )}

{title}

{children}
) }