From 0af9f5552816d6e9c6ab66dd5a9497e0cc1b0d7b Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Fri, 4 Sep 2026 14:42:48 +0200 Subject: [PATCH] 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. --- frontend/src/App.jsx | 6 +++--- frontend/src/lib/pt-br-locale.test.js | 2 +- frontend/src/locales/de.js | 2 ++ frontend/src/locales/es.js | 2 ++ frontend/src/locales/fr.js | 2 ++ frontend/src/locales/hi.js | 2 ++ frontend/src/locales/hu.js | 2 ++ frontend/src/locales/it.js | 2 ++ frontend/src/locales/ko.js | 2 ++ frontend/src/locales/pl.js | 2 ++ frontend/src/locales/pt-BR.js | 4 +++- frontend/src/locales/pt.js | 2 ++ frontend/src/locales/ru.js | 2 ++ frontend/src/locales/th.js | 2 ++ frontend/src/locales/tr.js | 2 ++ frontend/src/locales/zh.js | 2 ++ frontend/src/store/useStore.gymcards.test.jsx | 18 ++++++++++++++++++ frontend/src/store/useStore.js | 4 ++++ frontend/src/views/Home.jsx | 5 +++-- frontend/src/views/Settings.jsx | 6 ++++++ 20 files changed, 64 insertions(+), 7 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ae2c41c..bf5ed48 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -116,9 +116,9 @@ function Shell() { } /> {/* 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 && } />} + 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 && } />} } /> } /> } /> diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index a263acd..03b4549 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -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 diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index b8b9335..be72df2 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -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.', } diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index 7c429bb..f0e4d65 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -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.', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 3ab6a7d..a499e85 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -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é.', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 49a7d16..ab24120 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -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 कोड वाला कार्ड दिखाता है।', } diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index 0479a04..649ca29 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -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.', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index be3c8cb..c58bf9b 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -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.', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index 6814e36..881ecf6 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -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 코드 카드를 표시합니다.', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index 31db24d..017f900 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -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.', } diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index 42be41a..c7d366d 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -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 } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 7ca5c1c..aafc1ea 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -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.', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index c7e11d7..1f19344 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -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-кодами абонемента.', } diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index 2a6ba67..83a57ca 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -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 โค้ดสมาชิกของคุณบนหน้าหลัก', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 36c107c..92a7b16 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -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.', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 931b154..a4f7868 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -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.': '在首页显示一张包含会员二维码的卡片。', } diff --git a/frontend/src/store/useStore.gymcards.test.jsx b/frontend/src/store/useStore.gymcards.test.jsx index 8f0fe52..d3fcab9 100644 --- a/frontend/src/store/useStore.gymcards.test.jsx +++ b/frontend/src/store/useStore.gymcards.test.jsx @@ -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) + }) +}) diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js index 802e8f2..09abeec 100644 --- a/frontend/src/store/useStore.js +++ b/frontend/src/store/useStore.js @@ -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)) diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsx index c597218..0cf46b4 100644 --- a/frontend/src/views/Home.jsx +++ b/frontend/src/views/Home.jsx @@ -96,8 +96,9 @@ export default function Home() { {/* 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 && (
nav('/checkin'))}>
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index 5b94d06..7d12f2d 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -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 })} /> + {/* 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 && + update(s => { s.checkIn = v })} /> + } {/* ---------- during a workout ---------- */}