Files
TREK/client/src/components/Settings/WebPushCard.tsx
T
Maurice 94ac7673a5 feat(settings): one look for every user and admin settings page
The settings pages had grown into a mix of styles: folds, dialogs behind
rows, full-width rows next to boxed ones, pills for every figure and buttons
in four sizes. Every page now uses the same kit.

- Cards keep their tinted head band; every part of a card is a rounded block
  with its own small head (SettingsBlock), and rows sit in rounded boxes.
- Nothing folds and nothing hides behind a dialog: the MCP config, OAuth
  scopes, mail how-to, AI privacy note and addon sub-options are all shown.
- Each page is split into two columns balanced by length (SettingsColumns).
- Long explanations moved into an info mark next to the label (HintMark).
- One button size everywhere (text-control); tab names are one word.
- Admin: the old Settings tab is split into Security and Services
  (?tab=settings still opens Security, and the phone keeps its single
  Settings section for both); the Integration group is gone, live flights
  and mail import sit next to the addons they configure.
- Addons: one card per type with rows, no search, filter or fold.
- Quota, TREK API facts, mail import status and Google's daily limit are
  compact lines and strips instead of tiles and pills.
- Language is a select; routing has its own card under the defaults;
  storage saves from the foot of its categories card.
- Unused keys, FoldSummary and the page-width wrapper are removed.
2026-11-13 23:18:28 +01:00

53 lines
1.9 KiB
TypeScript

import React from 'react'
import { BellRing } from 'lucide-react'
import { useTranslation } from '../../i18n'
import { useWebPush } from '../../hooks/useWebPush'
import { fs } from '../shared/DialogShell'
import { SettingsCard, SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY } from './settingsKit'
/**
* The "Push notifications on this device" card of the Notifications tab. Only
* markup: the logic is `useWebPush`, shared with the phone's `MWebPushCard`.
* The tab renders it while the admin has the push channel switched on.
*/
export default function WebPushCard(): React.ReactElement {
const { t } = useTranslation()
const push = useWebPush()
return (
<SettingsCard icon={BellRing} title={t('settings.webPush.title')} hint={t('settings.webPush.hint')}>
{(push.stateText || push.canSwitch) && (
<div className="flex flex-wrap items-center gap-x-4 gap-y-3 rounded-[12px] border border-edge-faint bg-surface-card px-3.5 py-3">
{push.stateText
? (
<p role="status" className="m-0 min-w-0 flex-1 basis-56 text-content-secondary" style={fs(12.5, 'body')}>
{push.stateText}
</p>
)
: <span className="flex-1" />}
{push.canSwitch && (
<div className="flex flex-none flex-wrap items-center gap-2">
<button
type="button"
onClick={push.sendTest}
disabled={!push.canTest}
className={SETTINGS_BUTTON}
>
{t('settings.notificationPreferences.sendTest')}
</button>
<button
type="button"
onClick={push.toggle}
disabled={push.busy}
className={push.on ? SETTINGS_BUTTON : SETTINGS_BUTTON_PRIMARY}
>
{push.switchLabel}
</button>
</div>
)}
</div>
)}
</SettingsCard>
)
}