mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
94ac7673a5
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.
64 lines
2.8 KiB
TypeScript
64 lines
2.8 KiB
TypeScript
import { Check } from 'lucide-react'
|
|
import { useTranslation } from '../../i18n'
|
|
import { NumericInput } from '../shared/NumericInput'
|
|
import { fs } from '../shared/DialogShell'
|
|
import { INPUT } from '../shared/dialogParts'
|
|
import { HintMark, SETTINGS_BUTTON_PRIMARY } from '../Settings/settingsKit'
|
|
import { useGoogleQuota } from './useGoogleQuota'
|
|
|
|
/**
|
|
* The daily ceiling on Google calls (#1582), as one row of the Google options:
|
|
* today's count as a quiet line under the name, the number on the right, a save
|
|
* button only while there is something to save. Laid out like settingsKit's
|
|
* SettingRow; the count stays outside the <label>, so the field keeps the plain
|
|
* name as its accessible name.
|
|
*/
|
|
export default function GoogleDailyLimitRow() {
|
|
const { t } = useTranslation()
|
|
const { status, draft, setDraft, dirty, saving, save } = useGoogleQuota()
|
|
|
|
return (
|
|
<div className={`px-4 py-3 ${saving ? 'opacity-60' : ''}`}>
|
|
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
|
|
<div className="min-w-0 flex-1 basis-56">
|
|
<div className="flex min-w-0 items-center gap-1.5">
|
|
<label htmlFor="admin-google-daily-limit" className="font-medium text-content" style={fs(13, 'body')}>{t('admin.googleQuota.title')}</label>
|
|
<HintMark hint={t('admin.googleQuota.subtitle')} />
|
|
</div>
|
|
{/* Today's count as plain text under the name; in the warning colour once the day is used up. */}
|
|
{status && (
|
|
<p className={`m-0 mt-0.5 tabular-nums ${status.exhausted ? 'text-warning' : 'text-content-faint'}`} style={fs(11.5)}>
|
|
{status.exhausted
|
|
? t('admin.googleQuota.reached', { used: status.used_today })
|
|
: status.daily_limit == null
|
|
? t('admin.googleQuota.usedToday', { used: status.used_today })
|
|
: t('admin.googleQuota.usedOfLimit', { used: status.used_today, limit: status.daily_limit })}
|
|
</p>
|
|
)}
|
|
</div>
|
|
<div className="flex flex-none items-center gap-2">
|
|
<div className="w-32">
|
|
<NumericInput
|
|
id="admin-google-daily-limit"
|
|
mode="integer"
|
|
value={draft}
|
|
onValueChange={setDraft}
|
|
onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); void save() } }}
|
|
placeholder={t('admin.googleQuota.placeholder')}
|
|
disabled={status === null || saving}
|
|
className={`${INPUT} text-end font-geist tabular-nums`}
|
|
/>
|
|
</div>
|
|
{dirty && (
|
|
<button type="button" onClick={() => void save()} disabled={saving}
|
|
className={SETTINGS_BUTTON_PRIMARY}>
|
|
<Check size={14} strokeWidth={2.2} />
|
|
{t('common.save')}
|
|
</button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|