mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
34b9b7b0d0
Split mobile view logic at existing UI boundaries and keep shared calendar hooks outside component modules. Register the phone-only files and make the sheet gesture and final budget assertions independent of scheduling.
94 lines
3.6 KiB
TypeScript
94 lines
3.6 KiB
TypeScript
import { useSubscribeLinks } from './useSubscribeLinks'
|
|
import { Copy, Check, CalendarPlus, Calendar } from 'lucide-react'
|
|
import { useTranslation } from '../../i18n'
|
|
|
|
interface SubscribeLinksProps {
|
|
httpsUrl: string
|
|
webcalUrl: string
|
|
}
|
|
|
|
export function SubscribeLinks({ httpsUrl, webcalUrl }: SubscribeLinksProps) {
|
|
const { t } = useTranslation()
|
|
const { googleUrl, manualLinks } = useSubscribeLinks(httpsUrl, webcalUrl)
|
|
|
|
return (
|
|
<div>
|
|
{/* One-click subscribe actions */}
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 16 }}>
|
|
<a
|
|
href={googleUrl}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
style={{
|
|
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
|
padding: '9px 14px', borderRadius: 9, textDecoration: 'none',
|
|
background: 'var(--accent, #6366f1)', color: 'var(--accent-text, #fff)',
|
|
fontSize: 12, fontWeight: 600, fontFamily: 'inherit',
|
|
}}
|
|
>
|
|
<CalendarPlus size={14} strokeWidth={2} />
|
|
{t('dashboard.ics.addGoogle')}
|
|
</a>
|
|
<a
|
|
href={webcalUrl}
|
|
style={{
|
|
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
|
padding: '9px 14px', borderRadius: 9, textDecoration: 'none',
|
|
background: 'none', border: '1px solid var(--border-primary)',
|
|
color: 'var(--text-primary)', fontSize: 12, fontWeight: 600, fontFamily: 'inherit',
|
|
}}
|
|
>
|
|
<Calendar size={14} strokeWidth={2} />
|
|
{t('dashboard.ics.addApple')}
|
|
</a>
|
|
</div>
|
|
|
|
{/* Manual fallback — raw URLs for any other client / "From URL" boxes */}
|
|
<details style={{ fontSize: 11, color: 'var(--text-muted)' }}>
|
|
<summary style={{ cursor: 'pointer', userSelect: 'none', marginBottom: 8 }}>
|
|
{t('dashboard.ics.copyManually')}
|
|
</summary>
|
|
{manualLinks.map(link => <UrlRow key={link.label} {...link} copyLabel={t('common.copy')} />)}
|
|
</details>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function UrlRow({ label, hint, url, copied, onCopy, copyLabel }: {
|
|
label: string; hint: string; copyLabel: string; url: string; copied: boolean; onCopy: () => void
|
|
}) {
|
|
return (
|
|
<div style={{ marginBottom: 12 }}>
|
|
<div style={{ fontSize: 11, fontWeight: 500, marginBottom: 5, color: 'var(--text-primary)' }}>
|
|
{label} <span style={{ color: 'var(--text-muted)', fontWeight: 400 }}>— {hint}</span>
|
|
</div>
|
|
<div style={{ display: 'flex', gap: 6, alignItems: 'center' }}>
|
|
<div style={{
|
|
flex: 1, fontSize: 10, fontFamily: 'monospace',
|
|
padding: '5px 8px', borderRadius: 6,
|
|
border: '1px solid var(--border-faint)',
|
|
background: 'var(--bg-subtle, #f9fafb)',
|
|
color: 'var(--text-muted)',
|
|
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
|
}}>
|
|
{url}
|
|
</div>
|
|
<button type="button"
|
|
onClick={onCopy}
|
|
title={copyLabel}
|
|
aria-label={copyLabel}
|
|
style={{
|
|
flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
width: 28, height: 28, borderRadius: 6,
|
|
border: '1px solid var(--border-primary)', background: 'none',
|
|
cursor: 'pointer', color: copied ? 'var(--accent, #6366f1)' : 'var(--text-muted)',
|
|
transition: 'color 0.15s',
|
|
}}
|
|
>
|
|
{copied ? <Check size={12} strokeWidth={2.5} /> : <Copy size={12} strokeWidth={2} />}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|