Gym check-in: Settings switch to turn the feature off

Off hides the Home card and the /checkin route; saved cards stay. On by default,
profiles without the key read as on. pt-BR: trailing comma the MR's last override
line was missing, override count 600.
This commit is contained in:
Duarte Santos committed 2026-09-04 14:42:48 +02:00
1 parent 3197f9e9be
commit 0af9f55528
20 files changed
+64 -7

No files matched your search

+3 -3
View File
@@ -116,9 +116,9 @@ function Shell() {
<Routes>
<Route path="/home" element={<Home />} />
{/* Gym check-in is mobile-only — it needs the native scanner and showing a QR to
a turnstile makes no sense in a browser tab. Off mobile the route falls through
to the catch-all redirect below. */}
{MOBILE && <Route path="/checkin" element={<CheckIn />} />}
a turnstile makes no sense in a browser tab. Off mobile (or switched off in
Settings) the route falls through to the catch-all redirect below. */}
{MOBILE && S.checkIn !== false && <Route path="/checkin" element={<CheckIn />} />}
<Route path="/plan" element={<Plan />} />
<Route path="/plan/r/:id" element={<RoutineEdit />} />
<Route path="/workout" element={<Workout />} />
+1 -1
View File
@@ -27,7 +27,7 @@ describe('Brazilian Portuguese locale', () => {
.sort(byCodeUnit)
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(598)
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(600)
expect(inherited).toHaveLength(565)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
+2
View File
@@ -1124,4 +1124,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'Zum Scannen wird die Kamera-Berechtigung benötigt. Aktiviere sie in den Einstellungen.',
'Scanning is not available on this device.': 'Scannen ist auf diesem Gerät nicht verfügbar.',
'Could not start the scanner': 'Scanner konnte nicht gestartet werden',
'Gym check-in': 'Gym-Check-in',
'Show a card on Home with your membership QR codes.': 'Zeigt auf Start eine Karte mit deinen Mitglieds-QR-Codes.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'Se necesita permiso de cámara para escanear. Actívalo en Ajustes.',
'Scanning is not available on this device.': 'El escaneo no está disponible en este dispositivo.',
'Could not start the scanner': 'No se pudo iniciar el escáner',
'Gym check-in': 'Check-in del gimnasio',
'Show a card on Home with your membership QR codes.': 'Muestra en Inicio una tarjeta con tus códigos QR de socio.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'L’autorisation caméra est nécessaire pour scanner. Active-la dans les Réglages.',
'Scanning is not available on this device.': 'Le scan n’est pas disponible sur cet appareil.',
'Could not start the scanner': 'Impossible de démarrer le scanner',
'Gym check-in': 'Enregistrement à la salle',
'Show a card on Home with your membership QR codes.': 'Affiche sur l’Accueil une carte avec vos codes QR d’abonné.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'स्कैन करने के लिए कैमरा अनुमति चाहिए। इसे सेटिंग्स में चालू करें।',
'Scanning is not available on this device.': 'इस डिवाइस पर स्कैनिंग उपलब्ध नहीं है।',
'Could not start the scanner': 'स्कैनर शुरू नहीं हो सका',
'Gym check-in': 'जिम चेक-इन',
'Show a card on Home with your membership QR codes.': 'होम पर आपके सदस्यता QR कोड वाला कार्ड दिखाता है।',
}
+2
View File
@@ -1108,4 +1108,6 @@ export default {
'What should change?': 'Mi változzon?',
'Coach is thinking…': 'Az Edző gondolkodik…',
'Message the Coach…': 'Üzenet az Edzőnek…',
'Gym check-in': 'Bejelentkezés a teremben',
'Show a card on Home with your membership QR codes.': 'A Kezdőlapon egy kártyát mutat a tagsági QR-kódjaiddal.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'Per scansionare serve l’autorizzazione alla fotocamera. Attivala nelle Impostazioni.',
'Scanning is not available on this device.': 'La scansione non è disponibile su questo dispositivo.',
'Could not start the scanner': 'Impossibile avviare lo scanner',
'Gym check-in': 'Check-in in palestra',
'Show a card on Home with your membership QR codes.': 'Mostra nella Home una scheda con i tuoi codici QR di iscrizione.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': '스캔하려면 카메라 권한이 필요합니다. 설정에서 켜세요.',
'Scanning is not available on this device.': '이 기기에서는 스캔을 사용할 수 없습니다.',
'Could not start the scanner': '스캐너를 시작할 수 없습니다',
'Gym check-in': '헬스장 체크인',
'Show a card on Home with your membership QR codes.': '홈 화면에 회원 QR 코드 카드를 표시합니다.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'Do skanowania potrzebne jest pozwolenie na aparat. Włącz je w Ustawieniach.',
'Scanning is not available on this device.': 'Skanowanie nie jest dostępne na tym urządzeniu.',
'Could not start the scanner': 'Nie udało się uruchomić skanera',
'Gym check-in': 'Zameldowanie na siłowni',
'Show a card on Home with your membership QR codes.': 'Pokazuje na Starcie kartę z Twoimi kodami QR członkowskimi.',
}
+3 -1
View File
@@ -621,7 +621,9 @@ export const PT_BR_OVERRIDES = {
'Could not read that image': 'Não foi possível ler essa imagem',
'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmera para escanear. Ative-a nos Ajustes.',
'Scanning is not available on this device.': 'O escaneamento não está disponível neste dispositivo.',
'Could not start the scanner': 'Não foi possível iniciar o scanner'
'Could not start the scanner': 'Não foi possível iniciar o scanner',
'Gym check-in': 'Check-in na academia',
'Show a card on Home with your membership QR codes.': 'Mostra no Início um cartão com seus códigos QR de sócio.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'É necessária a permissão da câmara para digitalizar. Ativa-a nas Definições.',
'Scanning is not available on this device.': 'A digitalização não está disponível neste dispositivo.',
'Could not start the scanner': 'Não foi possível iniciar o scanner',
'Gym check-in': 'Check-in no ginásio',
'Show a card on Home with your membership QR codes.': 'Mostra no Início um cartão com os teus códigos QR de sócio.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'Для сканирования нужен доступ к камере. Включите его в настройках.',
'Scanning is not available on this device.': 'Сканирование недоступно на этом устройстве.',
'Could not start the scanner': 'Не удалось запустить сканер',
'Gym check-in': 'Отметка в зале',
'Show a card on Home with your membership QR codes.': 'Показывает на Главной карточку с вашими QR-кодами абонемента.',
}
+2
View File
@@ -1116,4 +1116,6 @@ export default {
'What should change?': 'ควรเปลี่ยนอะไร',
'Coach is thinking…': 'โค้ชกำลังคิด…',
'Message the Coach…': 'ส่งข้อความถึงโค้ช…',
'Gym check-in': 'เช็คอินที่ยิม',
'Show a card on Home with your membership QR codes.': 'แสดงการ์ดพร้อม QR โค้ดสมาชิกของคุณบนหน้าหลัก',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': 'Taramak için kamera izni gerekir. Ayarlar’dan etkinleştir.',
'Scanning is not available on this device.': 'Tarama bu cihazda kullanılamıyor.',
'Could not start the scanner': 'Tarayıcı başlatılamadı',
'Gym check-in': 'Salon girişi',
'Show a card on Home with your membership QR codes.': 'Ana sayfada üyelik QR kodlarınızı içeren bir kart gösterir.',
}
+2
View File
@@ -1105,4 +1105,6 @@ export default {
'Camera permission is needed to scan. Enable it in Settings.': '扫描需要相机权限。请在设置中开启。',
'Scanning is not available on this device.': '此设备不支持扫描。',
'Could not start the scanner': '无法启动扫描器',
'Gym check-in': '健身房签到',
'Show a card on Home with your membership QR codes.': '在首页显示一张包含会员二维码的卡片。',
}
@@ -67,3 +67,21 @@ describe('gymCards state', () => {
expect(useStore.getState().S.gymCards.map(c => c.id)).toEqual(['1', '2', '3'])
})
})
// The Settings switch. On by default; an older profile that predates the key must read as on
// too, and off only hides the feature — the cards themselves survive the round trip.
describe('checkIn switch', () => {
it('is on for a fresh profile', () => {
expect(useStore.getState().S.checkIn).toBe(true)
})
it('turning it off keeps the saved cards', () => {
useStore.getState().update(s => {
s.gymCards.push({ id: 'c1', label: 'FitZone', value: 'ABC123', fmt: 'qrcode' })
s.checkIn = false
}, false)
const S = useStore.getState().S
expect(S.checkIn).toBe(false)
expect(S.gymCards).toHaveLength(1)
})
})
+4
View File
@@ -42,6 +42,10 @@ export const DEF = {
// kind of code the gym issued. Just data, so it syncs and backs up like everything else.
// [{ id, label, value, fmt }]
gymCards: [],
// Whether the check-in feature is on at all (Settings toggle, mobile-only). Off hides the Home
// card and the /checkin route; the saved gymCards stay so turning it back on restores them.
// Defaults on; an older profile without the key reads as on (`!== false`).
checkIn: true,
}
const clone = o => JSON.parse(JSON.stringify(o))
+3 -2
View File
@@ -96,8 +96,9 @@ export default function Home() {
</div>
{/* Mobile-only: jump to the gym check-in cards (QR membership codes). Shown here as a quick
tap on arrival at the gym; the whole feature folds away in web/demo builds via MOBILE. */}
{MOBILE && (
tap on arrival at the gym; the whole feature folds away in web/demo builds via MOBILE,
and per user via the "Gym check-in" switch in Settings. */}
{MOBILE && S.checkIn !== false && (
<div className="card tappable" style={{ cursor: 'pointer' }} {...tappable(() => nav('/checkin'))}>
<div className="row between">
<div className="row" style={{ gap: 9 }}>
+6
View File
@@ -140,6 +140,12 @@ export default function Settings() {
options={[{ value: MONDAY, label: t('Monday') }, { value: SUNDAY, label: t('Sunday') }]}
value={weekStartOf(S)} onChange={v => update(s => { s.weekStart = v })} />
</Row>
{/* Membership QR codes on Home (views/CheckIn.jsx). Only the app can scan and show them
at a turnstile, so the switch exists only there; off = no Home card, no route. */}
{MOBILE && <Row icon="qr" iconTint="var(--blue)" title={t('Gym check-in')}
subtitle={t('Show a card on Home with your membership QR codes.')}>
<Switch checked={S.checkIn !== false} onChange={v => update(s => { s.checkIn = v })} />
</Row>}
</Section>
{/* ---------- during a workout ---------- */}